diff options
Diffstat (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes')
643 files changed, 0 insertions, 66155 deletions
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs deleted file mode 100644 index 141fea0d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs +++ /dev/null @@ -1,692 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using System.Collections.Generic; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public enum eResizeAxis - { - X_AXIS, - Y_AXIS, - ALL - } - - [Serializable] - public sealed class CommentaryNode : ParentNode, ISerializationCallbackReceiver - { - private const string InfoText = "Press Alt + Left Mouse Click/Drag to make all Comment node area interactable.\nDouble click on the Comment at the node body to modify it directly from there."; - - private const string CommentaryTitle = "Comment"; - private const float BORDER_SIZE_X = 50; - private const float BORDER_SIZE_Y = 50; - private const float MIN_SIZE_X = 100; - private const float MIN_SIZE_Y = 100; - private const float COMMENTARY_BOX_HEIGHT = 30; - - private readonly Vector2 ResizeButtonPos = new Vector2( 1, 1 ); - - [SerializeField] - private string m_commentText = "Comment"; - - [SerializeField] - private string m_titleText = string.Empty; - - [SerializeField] - private eResizeAxis m_resizeAxis = eResizeAxis.ALL; - - [SerializeField] - private List<ParentNode> m_nodesOnCommentary = new List<ParentNode>(); - private Dictionary<int, ParentNode> m_nodesOnCommentaryDict = new Dictionary<int, ParentNode>(); - private bool m_reRegisterNodes = false; - - [SerializeField] - private Rect m_resizeLeftIconCoords; - - [SerializeField] - private Rect m_resizeRightIconCoords; - - [SerializeField] - private Rect m_auxHeaderPos; - - [SerializeField] - private Rect m_commentArea; - - private Texture2D m_resizeIconTex; - - private bool m_isResizingRight = false; - private bool m_isResizingLeft = false; - - private Vector2 m_resizeStartPoint = Vector2.zero; - - private string m_focusName = "CommentaryNode"; - private bool m_focusOnTitle = false; - private bool m_graphDepthAnalized = false; - - private bool m_checkCommentText = true; - private bool m_checkTitleText = true; - - public Color m_frameColor = Color.white; - - private List<int> m_nodesIds = new List<int>(); - private bool m_checkContents = false; - - private bool m_isEditing; - private bool m_stopEditing; - private bool m_startEditing; - private double m_clickTime; - private double m_doubleClickTime = 0.3; - - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_reorderLocked = true; - m_rmbIgnore = true; - m_defaultInteractionMode = InteractionMode.Both; - m_headerColor = UIUtils.GetColorFromCategory( "Commentary" ); - m_connStatus = NodeConnectionStatus.Island; - m_textLabelWidth = 90; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_focusName = CommentaryTitle + OutputId; - } - - public void CreateFromSelectedNodes( Vector2 mousePosOnCanvasCoords, ParentNode[] selectedNodes ) - { - if ( selectedNodes.Length == 0 ) - { - m_position = new Rect( mousePosOnCanvasCoords, new Vector2( 100, 100 ) ); - return; - } - - Vector2 minPos = new Vector2( float.MaxValue, float.MaxValue ); - Vector2 maxPos = new Vector2( float.MinValue, float.MinValue ); - - for ( int i = 0; i < selectedNodes.Length; i++ ) - { - //Check min - if ( selectedNodes[ i ].Position.x < minPos.x ) - minPos.x = selectedNodes[ i ].Position.x; - - if ( selectedNodes[ i ].Position.y < minPos.y ) - minPos.y = selectedNodes[ i ].Position.y; - - //check max - float nodeXMax = selectedNodes[ i ].Position.x + selectedNodes[ i ].Position.width; - if ( nodeXMax > maxPos.x ) - { - maxPos.x = nodeXMax; - } - - float nodeYMax = selectedNodes[ i ].Position.y + selectedNodes[ i ].Position.height; - if ( nodeYMax > maxPos.y ) - { - maxPos.y = nodeYMax; - } - - //_nodesOnCommentary.Add( selectedNodes[ i ] ); - //selectedNodes[ i ].OnNodeStoppedMovingEvent += NodeStoppedMoving; - AddNodeToCommentary( selectedNodes[ i ] ); - } - - Vector2 dims = maxPos - minPos + new Vector2( 2 * BORDER_SIZE_X, 2 * BORDER_SIZE_Y ); - m_position = new Rect( minPos.x - BORDER_SIZE_X, minPos.y - BORDER_SIZE_Y, dims.x, dims.y ); - } - - public override void Move( Vector2 delta, bool snap ) - { - if ( m_isResizingRight || m_isResizingLeft ) - return; - - base.Move( delta, snap ); - for ( int i = 0; i < m_nodesOnCommentary.Count; i++ ) - { - if ( !m_nodesOnCommentary[ i ].Selected ) - { - m_nodesOnCommentary[ i ].RecordObject( Constants.UndoMoveNodesId ); - m_nodesOnCommentary[ i ].Move( delta, snap ); - } - } - } - - public void NodeStoppedMoving( ParentNode node, bool testOnlySelected, InteractionMode useTargetInteraction ) - { - if ( !m_position.Contains( node.Vec2Position ) && !m_position.Contains( node.Corner ) ) - { - RemoveNode( node ); - } - } - - public void NodeDestroyed( ParentNode node ) - { - RemoveNode( node ); - } - - public void RemoveNode( ParentNode node ) - { - if ( m_nodesOnCommentaryDict.ContainsKey( node.UniqueId ) ) - { - UIUtils.MarkUndoAction(); - RecordObject( Constants.UndoRemoveNodeFromCommentaryId ); - node.RecordObject( Constants.UndoRemoveNodeFromCommentaryId ); - m_nodesOnCommentary.Remove( node ); - m_nodesOnCommentaryDict.Remove( node.UniqueId ); - node.OnNodeStoppedMovingEvent -= NodeStoppedMoving; - node.OnNodeDestroyedEvent -= NodeDestroyed; - node.CommentaryParent = -1; - } - } - - public void RemoveAllNodes() - { - UIUtils.MarkUndoAction(); - for ( int i = 0; i < m_nodesOnCommentary.Count; i++ ) - { - RecordObject( Constants.UndoRemoveNodeFromCommentaryId ); - m_nodesOnCommentary[ i ].RecordObject( Constants.UndoRemoveNodeFromCommentaryId ); - m_nodesOnCommentary[ i ].OnNodeStoppedMovingEvent -= NodeStoppedMoving; - m_nodesOnCommentary[ i ].OnNodeDestroyedEvent -= NodeDestroyed; - m_nodesOnCommentary[ i ].CommentaryParent = -1; - } - m_nodesOnCommentary.Clear(); - m_nodesOnCommentaryDict.Clear(); - } - - public override void Destroy() - { - base.Destroy(); - RemoveAllNodes(); - } - - public void AddNodeToCommentary( ParentNode node ) - { - if( node.UniqueId == UniqueId ) - return; - - if ( !m_nodesOnCommentaryDict.ContainsKey( node.UniqueId ) ) - { - bool addToNode = false; - - if ( node.CommentaryParent < 0 ) - { - addToNode = true; - if ( node.Depth <= m_depth ) - { - ActivateNodeReordering( node.Depth ); - } - } - else - { - CommentaryNode other = UIUtils.GetNode( node.CommentaryParent ) as CommentaryNode; - if ( other != null ) - { - if ( other.Depth < Depth ) - { - other.RemoveNode( node ); - addToNode = true; - } - - } - } - - if ( addToNode ) - { - UIUtils.MarkUndoAction(); - RecordObject( Constants.UndoAddNodeToCommentaryId ); - node.RecordObject( Constants.UndoAddNodeToCommentaryId ); - - m_nodesOnCommentary.Add( node ); - m_nodesOnCommentaryDict.Add( node.UniqueId, node ); - node.OnNodeStoppedMovingEvent += NodeStoppedMoving; - node.OnNodeDestroyedEvent += NodeDestroyed; - node.CommentaryParent = UniqueId; - } - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr,()=> - { - EditorGUI.BeginChangeCheck(); - m_titleText = EditorGUILayoutTextField( "Frame Title", m_titleText ); - if ( EditorGUI.EndChangeCheck() ) - { - m_checkTitleText = true; - } - EditorGUI.BeginChangeCheck(); - m_commentText = EditorGUILayoutTextField( CommentaryTitle, m_commentText ); - if ( EditorGUI.EndChangeCheck() ) - { - m_checkCommentText = true; - } - - m_frameColor = EditorGUILayoutColorField( "Frame Color", m_frameColor ); - } ); - EditorGUILayout.HelpBox( InfoText, MessageType.Info ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - if ( m_nodesIds.Count > 0 ) - { - for ( int i = 0; i < m_nodesIds.Count; i++ ) - { - ParentNode node = ContainerGraph.GetNode( m_nodesIds[ i ] ); - if ( node ) - { - AddNodeToCommentary( node ); - } - } - m_nodesIds.Clear(); - } - - if ( m_reRegisterNodes ) - { - m_reRegisterNodes = false; - m_nodesOnCommentaryDict.Clear(); - for ( int i = 0; i < m_nodesOnCommentary.Count; i++ ) - { - if ( m_nodesOnCommentary[ i ] != null ) - { - m_nodesOnCommentary[ i ].OnNodeStoppedMovingEvent += NodeStoppedMoving; - m_nodesOnCommentary[ i ].OnNodeDestroyedEvent += NodeDestroyed; - m_nodesOnCommentaryDict.Add( m_nodesOnCommentary[ i ].UniqueId, m_nodesOnCommentary[ i ] ); - } - } - } - - //base.OnLayout( drawInfo ); - CalculatePositionAndVisibility( drawInfo ); - - m_headerPosition = m_globalPosition; - m_headerPosition.height = UIUtils.CurrentHeaderHeight; - - m_auxHeaderPos = m_position; - m_auxHeaderPos.height = UIUtils.HeaderMaxHeight; - - m_commentArea = m_globalPosition; - m_commentArea.height = COMMENTARY_BOX_HEIGHT * drawInfo.InvertedZoom; - m_commentArea.xMin += 10 * drawInfo.InvertedZoom; - m_commentArea.xMax -= 10 * drawInfo.InvertedZoom; - - if ( m_resizeIconTex == null ) - { - m_resizeIconTex = UIUtils.GetCustomStyle( CustomStyle.CommentaryResizeButton ).normal.background; - } - - // LEFT RESIZE BUTTON - m_resizeLeftIconCoords = m_globalPosition; - m_resizeLeftIconCoords.x = m_globalPosition.x + 2; - m_resizeLeftIconCoords.y = m_globalPosition.y + m_globalPosition.height - 2 - ( m_resizeIconTex.height + ResizeButtonPos.y ) * drawInfo.InvertedZoom; - m_resizeLeftIconCoords.width = m_resizeIconTex.width * drawInfo.InvertedZoom; - m_resizeLeftIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom; - - // RIGHT RESIZE BUTTON - m_resizeRightIconCoords = m_globalPosition; - m_resizeRightIconCoords.x = m_globalPosition.x + m_globalPosition.width - 1 - ( m_resizeIconTex.width + ResizeButtonPos.x ) * drawInfo.InvertedZoom; - m_resizeRightIconCoords.y = m_globalPosition.y + m_globalPosition.height - 2 - ( m_resizeIconTex.height + ResizeButtonPos.y ) * drawInfo.InvertedZoom; - m_resizeRightIconCoords.width = m_resizeIconTex.width * drawInfo.InvertedZoom; - m_resizeRightIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom; - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - if ( !m_isVisible ) - return; - - m_colorBuffer = GUI.color; - // Background - GUI.color = Constants.NodeBodyColor * m_frameColor; - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.CommentaryBackground ) ); - - // Header - GUI.color = m_headerColor * m_headerColorModifier * m_frameColor; - GUI.Label( m_headerPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeHeader ) ); - GUI.color = m_colorBuffer; - - // Fixed Title ( only renders when not editing ) - if ( !m_isEditing && !m_startEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( m_commentArea, m_commentText, UIUtils.CommentaryTitle ); - } - - // Buttons - GUI.Label( m_resizeLeftIconCoords, string.Empty, UIUtils.GetCustomStyle( CustomStyle.CommentaryResizeButtonInv ) ); - GUI.Label( m_resizeRightIconCoords, string.Empty, UIUtils.GetCustomStyle( CustomStyle.CommentaryResizeButton ) ); - - // Selection Box - if ( m_selected ) - { - GUI.color = Constants.NodeSelectedColor; - RectOffset cache = UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ).border; - UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ).border = UIUtils.RectOffsetSix; - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ) ); - UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ).border = cache; - GUI.color = m_colorBuffer; - } - - if ( !string.IsNullOrEmpty( m_titleText ) ) - { - Rect titleRect = m_globalPosition; - titleRect.y -= 24; - titleRect.height = 24; - GUI.Label( titleRect, m_titleText, UIUtils.GetCustomStyle( CustomStyle.CommentarySuperTitle ) ); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - // Custom Editable Title - if ( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if ( !m_isEditing && ( ( !ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_commentArea.Contains( drawInfo.MousePosition ) ) ) ) - { - if ( ( EditorApplication.timeSinceStartup - m_clickTime ) < m_doubleClickTime ) - m_startEditing = true; - else - GUI.FocusControl( null ); - m_clickTime = EditorApplication.timeSinceStartup; - } - else if ( m_isEditing && ( ( drawInfo.CurrentEventType == EventType.MouseDown && !m_commentArea.Contains( drawInfo.MousePosition ) ) || !EditorGUIUtility.editingTextField ) ) - { - m_stopEditing = true; - } - - if ( m_isEditing || m_startEditing ) - { - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_focusName ); - m_commentText = EditorGUITextField( m_commentArea, string.Empty, m_commentText, UIUtils.CommentaryTitle ); - if ( EditorGUI.EndChangeCheck() ) - { - m_checkCommentText = true; - } - - if ( m_startEditing ) - EditorGUI.FocusTextInControl( m_focusName ); - } - - if ( drawInfo.CurrentEventType == EventType.Repaint ) - { - if ( m_startEditing ) - { - m_startEditing = false; - m_isEditing = true; - } - - if ( m_stopEditing ) - { - m_stopEditing = false; - m_isEditing = false; - GUI.FocusControl( null ); - } - } - } - - if ( drawInfo.CurrentEventType == EventType.MouseDown && drawInfo.LeftMouseButtonPressed ) - { - // Left Button - if( m_resizeLeftIconCoords.Contains( drawInfo.MousePosition ) && ContainerGraph.ParentWindow.CurrentEvent.modifiers != EventModifiers.Shift ) - { - if ( !m_isResizingLeft ) - { - m_isResizingLeft = true; - ContainerGraph.ParentWindow.ForceAutoPanDir = true; - m_resizeStartPoint = drawInfo.TransformedMousePos; - } - } - - // Right Button - if ( m_resizeRightIconCoords.Contains( drawInfo.MousePosition ) && ContainerGraph.ParentWindow.CurrentEvent.modifiers != EventModifiers.Shift ) - { - if ( !m_isResizingRight ) - { - m_isResizingRight = true; - ContainerGraph.ParentWindow.ForceAutoPanDir = true; - m_resizeStartPoint = drawInfo.TransformedMousePos; - } - } - } - - if ( drawInfo.CurrentEventType == EventType.Repaint || drawInfo.CurrentEventType == EventType.MouseUp ) - { - // Left Button - EditorGUIUtility.AddCursorRect( m_resizeLeftIconCoords, MouseCursor.ResizeUpRight ); - if ( m_isResizingLeft ) - { - if ( drawInfo.CurrentEventType == EventType.MouseUp ) - { - m_isResizingLeft = false; - ContainerGraph.ParentWindow.ForceAutoPanDir = false; - RemoveAllNodes(); - FireStoppedMovingEvent( false, InteractionMode.Target ); - } - else - { - Vector2 currSize = ( drawInfo.TransformedMousePos - m_resizeStartPoint ) /*/ drawInfo.InvertedZoom*/; - m_resizeStartPoint = drawInfo.TransformedMousePos; - if ( m_resizeAxis != eResizeAxis.Y_AXIS ) - { - m_position.x += currSize.x; - m_position.width -= currSize.x; - if ( m_position.width < MIN_SIZE_X ) - { - m_position.x -= ( MIN_SIZE_X - m_position.width ); - m_position.width = MIN_SIZE_X; - } - } - - if ( m_resizeAxis != eResizeAxis.X_AXIS ) - { - m_position.height += currSize.y; - if ( m_position.height < MIN_SIZE_Y ) - { - m_position.height = MIN_SIZE_Y; - } - } - } - } - - // Right Button - EditorGUIUtility.AddCursorRect( m_resizeRightIconCoords, MouseCursor.ResizeUpLeft ); - if ( m_isResizingRight ) - { - if ( drawInfo.CurrentEventType == EventType.MouseUp ) - { - m_isResizingRight = false; - ContainerGraph.ParentWindow.ForceAutoPanDir = false; - RemoveAllNodes(); - FireStoppedMovingEvent( false, InteractionMode.Target ); - } - else - { - Vector2 currSize = ( drawInfo.TransformedMousePos - m_resizeStartPoint ) /*/ drawInfo.InvertedZoom*/; - m_resizeStartPoint = drawInfo.TransformedMousePos; - if ( m_resizeAxis != eResizeAxis.Y_AXIS ) - { - m_position.width += currSize.x; - if ( m_position.width < MIN_SIZE_X ) - { - m_position.width = MIN_SIZE_X; - } - } - - if ( m_resizeAxis != eResizeAxis.X_AXIS ) - { - m_position.height += currSize.y; - if ( m_position.height < MIN_SIZE_Y ) - { - m_position.height = MIN_SIZE_Y; - } - } - } - } - } - - if ( m_checkCommentText ) - { - m_checkCommentText = false; - m_commentText = m_commentText.Replace( IOUtils.FIELD_SEPARATOR, ' ' ); - } - - if ( m_checkTitleText ) - { - m_checkTitleText = false; - m_titleText = m_titleText.Replace( IOUtils.FIELD_SEPARATOR, ' ' ); - } - - if ( m_focusOnTitle && drawInfo.CurrentEventType == EventType.KeyUp ) - { - m_focusOnTitle = false; - m_startEditing = true; - } - } - - public void Focus() - { - m_focusOnTitle = true; - } - - public override void OnAfterDeserialize() - { - base.OnAfterDeserialize(); - m_reRegisterNodes = true; - } - - public override bool OnNodeInteraction( ParentNode node ) - { - if ( node == null || UniqueId == node.UniqueId ) - return false; - - for( int i = 0; i < m_nodesOnCommentary.Count; i++ ) - { - if( m_nodesOnCommentary[ i ] && m_nodesOnCommentary[ i ] != this && m_nodesOnCommentary[ i ].OnNodeInteraction( node ) ) - { - return false; - } - } - - if( m_position.Contains( node.Vec2Position ) && m_position.Contains( node.Corner ) ) - { - AddNodeToCommentary( node ); - return true; - } - return false; - } - - public override void OnSelfStoppedMovingEvent() - { - FireStoppedMovingEvent( false, InteractionMode.Both ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_position.width = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_position.height = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_commentText = GetCurrentParam( ref nodeParams ); - int count = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - for ( int i = 0; i < count; i++ ) - { - m_nodesIds.Add( Convert.ToInt32( GetCurrentParam( ref nodeParams ) ) ); - } - - if ( UIUtils.CurrentShaderVersion() > 5004 ) - m_titleText = GetCurrentParam( ref nodeParams ); - - if ( UIUtils.CurrentShaderVersion() > 12002 ) - { - string[] colorChannels = GetCurrentParam( ref nodeParams ).Split( IOUtils.VECTOR_SEPARATOR ); - if ( colorChannels.Length == 4 ) - { - m_frameColor.r = Convert.ToSingle( colorChannels[ 0 ] ); - m_frameColor.g = Convert.ToSingle( colorChannels[ 1 ] ); - m_frameColor.b = Convert.ToSingle( colorChannels[ 2 ] ); - m_frameColor.a = Convert.ToSingle( colorChannels[ 3 ] ); - } - else - { - UIUtils.ShowMessage( UniqueId, "Incorrect number of color values", MessageSeverity.Error ); - } - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_position.width ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_position.height ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_commentText ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_nodesOnCommentary.Count ); - for ( int i = 0; i < m_nodesOnCommentary.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_nodesOnCommentary[ i ].UniqueId ); - } - - IOUtils.AddFieldValueToString( ref nodeInfo, m_titleText ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_frameColor.r.ToString() + IOUtils.VECTOR_SEPARATOR + m_frameColor.g.ToString() + IOUtils.VECTOR_SEPARATOR + m_frameColor.b.ToString() + IOUtils.VECTOR_SEPARATOR + m_frameColor.a.ToString() ); - } - - public override void ResetNodeData() - { - base.ResetNodeData(); - m_graphDepthAnalized = false; - } - - public override void ReadAdditionalClipboardData( ref string[] nodeParams ) - { - base.ReadAdditionalClipboardData( ref nodeParams ); - m_nodesIds.Clear(); - m_checkContents = true; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( m_checkContents ) - { - m_checkContents = false; - OnSelfStoppedMovingEvent(); - } - } - - public override void CalculateCustomGraphDepth() - { - if ( m_graphDepthAnalized ) - return; - - m_graphDepth = int.MinValue; - int count = m_nodesOnCommentary.Count; - for ( int i = 0; i < count; i++ ) - { - if ( m_nodesOnCommentary[ i ].ConnStatus == NodeConnectionStatus.Island ) - { - m_nodesOnCommentary[ i ].CalculateCustomGraphDepth(); - } - - if ( m_nodesOnCommentary[ i ].GraphDepth >= m_graphDepth ) - { - m_graphDepth = m_nodesOnCommentary[ i ].GraphDepth + 1; - } - } - m_graphDepthAnalized = true; - } - - public override Rect Position { get { return Event.current.alt ? m_position : m_auxHeaderPos; } } - public override bool Contains( Vector3 pos ) - { - return Event.current.alt ? m_globalPosition.Contains( pos ) : ( m_headerPosition.Contains( pos ) || m_resizeRightIconCoords.Contains( pos ) || m_resizeLeftIconCoords.Contains( pos ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs.meta deleted file mode 100644 index 34eb425b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CommentaryNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 08f1d9c1d8cbe5841a6429d565096eab -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants.meta deleted file mode 100644 index 8706d1a2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: e7354e1a2beece044944bc1cba85aebc -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs deleted file mode 100644 index 4321bc10..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs +++ /dev/null @@ -1,506 +0,0 @@ -// 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( "Color", "Constants And Properties", "Color property", null, KeyCode.Alpha5 )] - public sealed class ColorNode : PropertyNode - { - private const string ColorSpaceStr = "Color Space"; - - [SerializeField] -#if UNITY_2018_1_OR_NEWER - [ColorUsage( true, true )] -#else - [ColorUsage( true, true, float.MinValue, float.MinValue, float.MinValue, float.MaxValue )] -#endif - private Color m_defaultValue = new Color( 0, 0, 0, 0 ); - - [SerializeField] -#if UNITY_2018_1_OR_NEWER - [ColorUsage( true, true )] -#else - [ColorUsage( true, true, float.MinValue, float.MinValue, float.MinValue, float.MaxValue )] -#endif - private Color m_materialValue = new Color( 0, 0, 0, 0 ); - - [SerializeField] - private bool m_isHDR = false; - - //[SerializeField] - //private ASEColorSpace m_colorSpace = ASEColorSpace.Auto; -#if !UNITY_2018_1_OR_NEWER - private ColorPickerHDRConfig m_hdrConfig = new ColorPickerHDRConfig( 0, float.MaxValue, 0, float.MaxValue ); -#endif - private GUIContent m_dummyContent; - - private int m_cachedPropertyId = -1; - - private bool m_isEditingFields; - - [SerializeField] - private bool m_autoGammaToLinearConversion = true; - - private const string AutoGammaToLinearConversion = "IsGammaSpace() ? {0} : {1}"; - private const string AutoGammaToLinearStr = "Auto Gamma To Linear"; - - public ColorNode() : base() { } - public ColorNode( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Color" ); - m_insideSize.Set( 100, 50 ); - m_dummyContent = new GUIContent(); - AddOutputColorPorts( "RGBA" ); - m_drawPreview = false; - m_drawPreviewExpander = false; - m_canExpand = false; - m_showHybridInstancedUI = true; - m_selectedLocation = PreviewLocation.BottomCenter; - m_previewShaderGUID = "6cf365ccc7ae776488ae8960d6d134c3"; - m_srpBatcherCompatible = true; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputColor" ); - - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetColor( m_cachedPropertyId, m_materialValue ); - else - PreviewMaterial.SetColor( m_cachedPropertyId, m_defaultValue ); - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - m_textLabelWidth = ( m_currentParameterType == PropertyType.Constant ) ? 152 : 105; - -#if UNITY_2018_1_OR_NEWER - m_defaultValue = EditorGUILayoutColorField( Constants.DefaultValueLabelContent, m_defaultValue, false, true, m_isHDR ); -#else - m_defaultValue = EditorGUILayoutColorField( Constants.DefaultValueLabelContent, m_defaultValue, false, true, m_isHDR, m_hdrConfig ); -#endif - if( m_currentParameterType == PropertyType.Constant ) - { - - m_autoGammaToLinearConversion = EditorGUILayoutToggle( AutoGammaToLinearStr, m_autoGammaToLinearConversion ); - } - } - - //public override void DrawMainPropertyBlock() - //{ - // EditorGUILayout.BeginVertical(); - // { - - // PropertyType parameterType = (PropertyType)EditorGUILayoutEnumPopup( ParameterTypeStr, m_currentParameterType ); - // if( parameterType != m_currentParameterType ) - // { - // ChangeParameterType( parameterType ); - // BeginPropertyFromInspectorCheck(); - // } - - // switch( m_currentParameterType ) - // { - // case PropertyType.Property: - // case PropertyType.InstancedProperty: - // { - // ShowPropertyInspectorNameGUI(); - // ShowPropertyNameGUI( true ); - // ShowVariableMode(); - // ShowPrecision(); - // ShowToolbar(); - // } - // break; - // case PropertyType.Global: - // { - // ShowPropertyInspectorNameGUI(); - // ShowPropertyNameGUI( false ); - // ShowVariableMode(); - // ShowPrecision(); - // ShowDefaults(); - // } - // break; - // case PropertyType.Constant: - // { - // ShowPropertyInspectorNameGUI(); - // ShowPrecision(); - // m_colorSpace = (ASEColorSpace)EditorGUILayoutEnumPopup( ColorSpaceStr, m_colorSpace ); - // ShowDefaults(); - // } - // break; - // } - // } - // EditorGUILayout.EndVertical(); - //} - - public override void DrawMaterialProperties() - { - if( m_materialMode ) - EditorGUI.BeginChangeCheck(); -#if UNITY_2018_1_OR_NEWER - m_materialValue = EditorGUILayoutColorField( Constants.MaterialValueLabelContent, m_materialValue, false, true, m_isHDR ); -#else - m_materialValue = EditorGUILayoutColorField( Constants.MaterialValueLabelContent, m_materialValue, false, true, m_isHDR, m_hdrConfig ); -#endif - if( m_materialMode && EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos = m_globalPosition; - m_propertyDrawPos.x = m_remainingBox.x; - m_propertyDrawPos.y = m_remainingBox.y; - m_propertyDrawPos.width = 80 * drawInfo.InvertedZoom; - m_propertyDrawPos.height = m_remainingBox.height; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - //hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - m_isEditingFields = true; - } - else if( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( !m_isVisible ) - return; - - if( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - EditorGUI.BeginChangeCheck(); -#if UNITY_2018_1_OR_NEWER - m_materialValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_materialValue, false, true, m_isHDR ); -#else - m_materialValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_materialValue, false, true, m_isHDR, m_hdrConfig ); -#endif - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = true; - if( m_currentParameterType != PropertyType.Constant ) - { - BeginDelayedDirtyProperty(); - } - } - } - else - { - EditorGUI.BeginChangeCheck(); -#if UNITY_2018_1_OR_NEWER - m_defaultValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_defaultValue, false, true, m_isHDR ); -#else - m_defaultValue = EditorGUIColorField( m_propertyDrawPos, m_dummyContent, m_defaultValue, false, true, m_isHDR, m_hdrConfig ); -#endif - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - BeginDelayedDirtyProperty(); - } - } - } - else if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - EditorGUIUtility.DrawColorSwatch( m_propertyDrawPos, m_materialValue ); - else - EditorGUIUtility.DrawColorSwatch( m_propertyDrawPos, m_defaultValue ); - - GUI.Label( m_propertyDrawPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - } - - public override void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector ) - { - Color color = m_defaultValue; - //switch( m_colorSpace ) - //{ - // default: - // case ASEColorSpace.Auto: color = m_defaultValue; break; - // case ASEColorSpace.Gamma: color = m_defaultValue.gamma; break; - // case ASEColorSpace.Linear: color = m_defaultValue.linear; break; - //} - - dataCollector.AddLocalVariable( UniqueId, CreateLocalVarDec( color.r + "," + color.g + "," + color.b + "," + color.a ) ); - - m_outputPorts[ 0 ].SetLocalValue( m_propertyName , dataCollector.PortCategory); - m_outputPorts[ 1 ].SetLocalValue( m_propertyName + ".r", dataCollector.PortCategory ); - m_outputPorts[ 2 ].SetLocalValue( m_propertyName + ".g", dataCollector.PortCategory ); - m_outputPorts[ 3 ].SetLocalValue( m_propertyName + ".b", dataCollector.PortCategory ); - m_outputPorts[ 4 ].SetLocalValue( m_propertyName + ".a", dataCollector.PortCategory ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if( m_currentParameterType != PropertyType.Constant ) - return GetOutputVectorItem( 0, outputId, PropertyData( dataCollector.PortCategory ) ); - - // Constant Only Code - - if( m_outputPorts[ outputId ].IsLocalValue(dataCollector.PortCategory) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - if( m_autoGammaToLinearConversion ) - { - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue(dataCollector.PortCategory) ); - - Color linear = m_defaultValue.linear; - - string colorGamma = m_precisionString + "(" + m_defaultValue.r + "," + m_defaultValue.g + "," + m_defaultValue.b + "," + m_defaultValue.a + ")"; - string colorLinear = m_precisionString + "(" + linear.r + "," + linear.g + "," + linear.b + "," + m_defaultValue.a + ")"; - - string result = string.Format( AutoGammaToLinearConversion, colorGamma, colorLinear ); - RegisterLocalVariable( 0, result, ref dataCollector, "color" + OutputId ); - return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - else - { - if( CheckLocalVariable( ref dataCollector ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - Color color = m_defaultValue; - //switch( m_colorSpace ) - //{ - // default: - // case ASEColorSpace.Auto: color = m_defaultValue; break; - // case ASEColorSpace.Gamma: color = m_defaultValue.gamma; break; - // case ASEColorSpace.Linear: color = m_defaultValue.linear; break; - //} - string result = string.Empty; - - switch( outputId ) - { - case 0: - { - result = m_precisionString + "(" + color.r + "," + color.g + "," + color.b + "," + color.a + ")"; - } - break; - - case 1: - { - result = color.r.ToString(); - } - break; - case 2: - { - result = color.g.ToString(); - } - break; - case 3: - { - result = color.b.ToString(); - } - break; - case 4: - { - result = color.a.ToString(); - } - break; - } - return result; - } - } - - protected override void OnAtrributesChanged() - { - CheckIfHDR(); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - CheckIfHDR(); - } - - void CheckIfHDR() - { - int count = m_selectedAttribs.Count; - bool hdrBuffer = m_isHDR; - m_isHDR = false; - for( int i = 0; i < count; i++ ) - { - if( m_selectedAttribs[ i ] == 1 /*HDR Property ID*/) - { - m_isHDR = true; - break; - } - } - - if( hdrBuffer && !m_isHDR ) - { - bool fireDirtyProperty = false; - - if( m_defaultValue.r > 1 || m_defaultValue.g > 1 || m_defaultValue.b > 1 ) - { - float defaultColorLength = Mathf.Sqrt( m_defaultValue.r * m_defaultValue.r + m_defaultValue.g * m_defaultValue.g + m_defaultValue.b * m_defaultValue.b ); - m_defaultValue.r /= defaultColorLength; - m_defaultValue.g /= defaultColorLength; - m_defaultValue.b /= defaultColorLength; - fireDirtyProperty = true; - } - - if( m_materialValue.r > 1 || m_materialValue.g > 1 || m_materialValue.b > 1 ) - { - float materialColorLength = Mathf.Sqrt( m_materialValue.r * m_materialValue.r + m_materialValue.g * m_materialValue.g + m_materialValue.b * m_materialValue.b ); - m_materialValue.r /= materialColorLength; - m_materialValue.g /= materialColorLength; - m_materialValue.b /= materialColorLength; - fireDirtyProperty = true; - } - - if( fireDirtyProperty ) - BeginDelayedDirtyProperty(); - } - } - - public override string GetPropertyValue() - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Color) = (" + m_defaultValue.r + "," + m_defaultValue.g + "," + m_defaultValue.b + "," + m_defaultValue.a + ")"; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetColor( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( m_materialMode && fetchMaterialValues ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - MaterialValue = mat.GetColor( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - MaterialValue = material.GetColor( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToColor( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_materialValue = IOUtils.StringToColor( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15900 ) - { - m_autoGammaToLinearConversion = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - else - { - m_autoGammaToLinearConversion = false; - } - //if( UIUtils.CurrentShaderVersion() > 14202 ) - //{ - // m_colorSpace = (ASEColorSpace)Enum.Parse( typeof( ASEColorSpace ), GetCurrentParam( ref nodeParams ) ); - //} - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.ColorToString( m_defaultValue ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.ColorToString( m_materialValue ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoGammaToLinearConversion ); - //IOUtils.AddFieldValueToString( ref nodeInfo, m_colorSpace ); - } - - public override void SetGlobalValue() { Shader.SetGlobalColor( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalColor( m_propertyName ); } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue.r.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.g.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.b.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.a.ToString( Constants.PropertyVectorFormatLabel ) : - m_defaultValue.r.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.g.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.b.ToString( Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.a.ToString( Constants.PropertyVectorFormatLabel ); - } - - private Color MaterialValue - { - set - { - if( !m_isHDR && ( value.r > 1 || value.g > 1 || value.r > 1 ) ) - { - float materialColorLength = Mathf.Sqrt( value.r * value.r + value.g * value.g + value.b * value.b ); - m_materialValue.r = value.r / materialColorLength; - m_materialValue.g = value.g / materialColorLength; - m_materialValue.b = value.b / materialColorLength; - m_materialValue.a = value.a; - } - else - { - m_materialValue = value; - } - } - } - - public Color Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs.meta deleted file mode 100644 index 1a21bb5c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ColorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4b99bcf4cd965c648bbbc1de0d1b152a -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs deleted file mode 100644 index d224465f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs +++ /dev/null @@ -1,486 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Global Array -// Donated by Johann van Berkel - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Global Array", "Constants And Properties", "The node returns a value from a global array, which you can configure by entering the name of the array in the node's settings.", null, KeyCode.None, true, false, null, null, "Johann van Berkel" )] - public sealed class GlobalArrayNode : ParentNode - { - private const string DefaultArrayName = "MyGlobalArray"; - private const string TypeStr = "Type"; - private const string AutoRangeCheckStr = "Range Check"; - private const string ArrayFormatStr = "{0}[{1}]"; - private const string JaggedArrayFormatStr = "{0}[{1}][{2}]"; - private const string IsJaggedStr = "Is Jagged"; - private const string AutoRegisterStr = "Auto-Register"; - - private readonly string[] AvailableTypesLabel = { "Float", "Color", "Vector4", "Matrix4" }; - private readonly WirePortDataType[] AvailableTypesValues = { WirePortDataType.FLOAT, WirePortDataType.COLOR, WirePortDataType.FLOAT4, WirePortDataType.FLOAT4x4 }; - - [SerializeField] - private string m_name = DefaultArrayName; - - [SerializeField] - private int m_indexX = 0; - - [SerializeField] - private int m_indexY = 0; - - [SerializeField] - private int m_arrayLengthX = 1; - - [SerializeField] - private int m_arrayLengthY = 1; - - [SerializeField] - private int m_type = 0; - - [SerializeField] - private bool m_autoRangeCheck = false; - - [SerializeField] - private bool m_isJagged = false; - - [SerializeField] - private bool m_autoRegister = false; - - ////////////////////////////////////////////////////////////////// - private readonly Color ReferenceHeaderColor = new Color( 0.6f, 3.0f, 1.25f, 1.0f ); - - [SerializeField] - private TexReferenceType m_referenceType = TexReferenceType.Object; - - [SerializeField] - private int m_referenceArrayId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - private GlobalArrayNode m_referenceNode = null; - - private bool m_updated = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - - AddInputPort( WirePortDataType.INT, false, "Index", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.INT, false, "Index Y", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.INT, false, "Array Length", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.INT, false, "Array Length Y", -1, MasterNodePortCategory.Fragment, 3 ); - - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - - m_textLabelWidth = 95; - SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, m_name ) ); - UpdatePorts(); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.CurrentWindow.OutsideGraph.GlobalArrayNodes.AddNode( this ); - } - - public override void Destroy() - { - base.Destroy(); - UIUtils.CurrentWindow.OutsideGraph.GlobalArrayNodes.RemoveNode( this ); - } - - void UpdatePorts() - { - InputPort indexXPort = GetInputPortByUniqueId( 0 ); - InputPort arrayLengthPortX = GetInputPortByUniqueId( 1 ); - InputPort indexYPort = GetInputPortByUniqueId( 2 ); - InputPort arrayLengthPortY = GetInputPortByUniqueId( 3 ); - if( m_referenceType == TexReferenceType.Object ) - { - m_headerColorModifier = Color.white; - SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, m_name ) ); - arrayLengthPortX.Visible = true; - if( m_isJagged ) - { - indexXPort.Name = "Index X"; - arrayLengthPortX.Name = "Array Length X"; - indexYPort.Visible = true; - arrayLengthPortY.Visible = true; - } - else - { - indexXPort.Name = "Index"; - arrayLengthPortX.Name = "Array Length"; - indexYPort.Visible = false; - arrayLengthPortY.Visible = false; - } - } - else if( m_referenceNodeId > -1 ) - { - m_headerColorModifier = ReferenceHeaderColor; - if( m_referenceNode == null ) - m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode; - - if( m_referenceNode != null ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, m_referenceNode.DataToArray ) ); - arrayLengthPortX.Visible = false; - arrayLengthPortY.Visible = false; - if( m_referenceNode.IsJagged ) - { - indexXPort.Name = "Index X"; - indexYPort.Visible = true; - } - else - { - indexXPort.Name = "Index"; - indexYPort.Visible = false; - } - } - } - m_sizeIsDirty = true; - } - - void DrawObjectProperties() - { - EditorGUI.BeginChangeCheck(); - m_name = EditorGUILayoutStringField( "Name", m_name ); - if( EditorGUI.EndChangeCheck() ) - { - m_updated = true; - m_name = UIUtils.RemoveInvalidCharacters( m_name ); - if( string.IsNullOrEmpty( m_name ) ) - m_name = DefaultArrayName; - UIUtils.UpdateGlobalArrayDataNode( UniqueId, m_name ); - SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, m_name ) ); - } - - - m_autoRegister = EditorGUILayoutToggle( AutoRegisterStr, m_autoRegister ); - - EditorGUI.BeginChangeCheck(); - m_isJagged = EditorGUILayoutToggle( IsJaggedStr, m_isJagged ); - if( EditorGUI.EndChangeCheck() ) - { - m_updated = true; - UpdatePorts(); - } - - InputPort indexXPort = GetInputPortByUniqueId( 0 ); - if( !indexXPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_indexX = EditorGUILayoutIntField( indexXPort.Name, m_indexX ); - if( EditorGUI.EndChangeCheck() ) - { - m_indexX = Mathf.Clamp( m_indexX, 0, ( m_arrayLengthX - 1 ) ); - } - } - - if( m_isJagged ) - { - InputPort indexYPort = GetInputPortByUniqueId( 2 ); - if( !indexYPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_indexY = EditorGUILayoutIntField( indexYPort.Name, m_indexY ); - if( EditorGUI.EndChangeCheck() ) - { - m_indexY = Mathf.Clamp( m_indexY, 0, ( m_arrayLengthY - 1 ) ); - } - } - } - - InputPort arrayLengthXPort = GetInputPortByUniqueId( 1 ); - if( !arrayLengthXPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_arrayLengthX = EditorGUILayoutIntField( arrayLengthXPort.Name, m_arrayLengthX ); - if( EditorGUI.EndChangeCheck() ) - { - m_arrayLengthX = Mathf.Max( 1, m_arrayLengthX ); - } - } - - if( m_isJagged ) - { - InputPort arrayLengthYPort = GetInputPortByUniqueId( 3 ); - if( !arrayLengthYPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_arrayLengthY = EditorGUILayoutIntField( arrayLengthYPort.Name, m_arrayLengthY ); - if( EditorGUI.EndChangeCheck() ) - { - m_arrayLengthY = Mathf.Max( 1, m_arrayLengthY ); - } - } - } - - EditorGUI.BeginChangeCheck(); - m_type = EditorGUILayoutPopup( TypeStr, m_type, AvailableTypesLabel ); - if( EditorGUI.EndChangeCheck() ) - { - m_outputPorts[ 0 ].ChangeType( (WirePortDataType)AvailableTypesValues[ m_type ], false ); - } - - m_autoRangeCheck = EditorGUILayoutToggle( AutoRangeCheckStr, m_autoRangeCheck ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - m_updated = false; - if( m_referenceType == TexReferenceType.Instance ) - { - if( m_referenceNodeId > -1 && m_referenceNode == null ) - { - m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode; - if( m_referenceNode == null ) - { - m_referenceNodeId = -1; - } - } - if( m_referenceNode != null && m_referenceNode.Updated) - { - UpdatePorts(); - } - } - } - - void DrawInstancedProperties() - { - string[] arr = UIUtils.GlobalArrayNodeArr(); - bool guiEnabledBuffer = GUI.enabled; - if( arr != null && arr.Length > 0 ) - { - GUI.enabled = true; - } - else - { - m_referenceArrayId = -1; - m_referenceNodeId = -1; - m_referenceNode = null; - GUI.enabled = false; - } - EditorGUI.BeginChangeCheck(); - m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId, arr ); - if( EditorGUI.EndChangeCheck() ) - { - m_referenceNode = UIUtils.GetGlobalArrayNode( m_referenceArrayId ); - if( m_referenceNode != null ) - { - m_referenceNodeId = m_referenceNode.UniqueId; - } - UpdatePorts(); - } - - GUI.enabled = guiEnabledBuffer; - - InputPort indexXPort = GetInputPortByUniqueId( 0 ); - if( !indexXPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_indexX = EditorGUILayoutIntField( indexXPort.Name, m_indexX ); - if( EditorGUI.EndChangeCheck() ) - { - m_indexX = Mathf.Clamp( m_indexX, 0, ( m_arrayLengthX - 1 ) ); - } - } - - if( m_isJagged ) - { - InputPort indexYPort = GetInputPortByUniqueId( 2 ); - if( !indexYPort.IsConnected ) - { - EditorGUI.BeginChangeCheck(); - m_indexY = EditorGUILayoutIntField( indexYPort.Name, m_indexY ); - if( EditorGUI.EndChangeCheck() ) - { - m_indexY = Mathf.Clamp( m_indexY, 0, ( m_arrayLengthY - 1 ) ); - } - } - } - } - - public override void DrawProperties() - { - EditorGUI.BeginChangeCheck(); - m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - - if( m_referenceType == TexReferenceType.Object ) - DrawObjectProperties(); - else - DrawInstancedProperties(); - } - - public string GetArrayValue( string indexX, string indexY = null ) - { - if( m_isJagged ) - return string.Format( JaggedArrayFormatStr, m_name, indexX, indexY ); - - return string.Format( ArrayFormatStr, m_name, indexX ); - } - - public string GenerateInstancedShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = string.Empty; - if( m_referenceNode != null ) - { - InputPort indexXPort = GetInputPortByUniqueId( 0 ); - if( m_referenceNode.IsJagged ) - { - InputPort indexYPort = GetInputPortByUniqueId( 2 ); - string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString(); - string arrayIndexY = indexYPort.IsConnected ? indexYPort.GeneratePortInstructions( ref dataCollector ) : m_indexY.ToString(); - result = m_referenceNode.GetArrayValue( arrayIndexX, arrayIndexY ); - } - else - { - string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString(); - result = m_referenceNode.GetArrayValue( arrayIndexX ); - } - } - m_outputPorts[ 0 ].SetLocalValue( result, dataCollector.PortCategory ); - return result; - } - - 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 ); - - if( m_referenceType == TexReferenceType.Instance ) - return GenerateInstancedShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - string dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, AvailableTypesValues[ m_type ] ); - - InputPort indexXPort = GetInputPortByUniqueId( 0 ); - InputPort arrayLengthXPort = GetInputPortByUniqueId( 1 ); - string result = string.Empty; - - if( m_isJagged ) - { - InputPort indexYPort = GetInputPortByUniqueId( 2 ); - InputPort arrayLengthYPort = GetInputPortByUniqueId( 3 ); - - string arrayIndexX = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString(); - string arrayLengthX = arrayLengthXPort.IsConnected ? arrayLengthXPort.GeneratePortInstructions( ref dataCollector ) : m_arrayLengthX.ToString(); - - string arrayIndexY = indexYPort.IsConnected ? indexYPort.GeneratePortInstructions( ref dataCollector ) : m_indexY.ToString(); - string arrayLengthY = arrayLengthYPort.IsConnected ? arrayLengthYPort.GeneratePortInstructions( ref dataCollector ) : m_arrayLengthY.ToString(); - - dataCollector.AddToUniforms( UniqueId, dataType, string.Format( JaggedArrayFormatStr, m_name, arrayLengthX, arrayLengthY ) ); - if( m_autoRangeCheck ) - { - arrayIndexX = string.Format( "clamp({0},0,({1} - 1))", arrayIndexX, arrayLengthX ); - arrayIndexY = string.Format( "clamp({0},0,({1} - 1))", arrayIndexY, arrayLengthY ); - } - result = string.Format( JaggedArrayFormatStr, m_name, arrayIndexX, arrayIndexY ); - } - else - { - - string arrayIndex = indexXPort.IsConnected ? indexXPort.GeneratePortInstructions( ref dataCollector ) : m_indexX.ToString(); - string arrayLength = arrayLengthXPort.IsConnected ? arrayLengthXPort.GeneratePortInstructions( ref dataCollector ) : m_arrayLengthX.ToString(); - - - dataCollector.AddToUniforms( UniqueId, dataType, string.Format( ArrayFormatStr, m_name, arrayLength ) ); - - if( m_autoRangeCheck ) - arrayIndex = string.Format( "clamp({0},0,({1} - 1))", arrayIndex, arrayLength ); - - result = string.Format( ArrayFormatStr, m_name, arrayIndex ); - } - - m_outputPorts[ 0 ].SetLocalValue( result, dataCollector.PortCategory ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public void CheckIfAutoRegister( ref MasterNodeDataCollector dataCollector ) - { - if( m_referenceType == TexReferenceType.Object && m_autoRegister && m_connStatus != NodeConnectionStatus.Connected ) - { - string dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, AvailableTypesValues[ m_type ] ); - if( m_isJagged ) - { - dataCollector.AddToUniforms( UniqueId, dataType, string.Format( JaggedArrayFormatStr, m_name, m_arrayLengthX, m_arrayLengthY ) ); - } - else - { - dataCollector.AddToUniforms( UniqueId, dataType, string.Format( ArrayFormatStr, m_name, m_arrayLengthX ) ); - } - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_name ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_indexX ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_arrayLengthX ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_type ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoRangeCheck ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_isJagged ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_indexY ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_arrayLengthY ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoRegister ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceNodeId ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_name = GetCurrentParam( ref nodeParams ); - m_indexX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_arrayLengthX = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_type = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_autoRangeCheck = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15801 ) - { - m_isJagged = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_indexY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_arrayLengthY = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_autoRegister = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) ); - m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, m_name ) ); - UpdatePorts(); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( m_referenceType == TexReferenceType.Instance && m_referenceNodeId > -1 ) - { - m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as GlobalArrayNode; - if( m_referenceNode != null ) - { - m_referenceArrayId = UIUtils.GetGlobalArrayNodeRegisterId( m_referenceNodeId ); - UpdatePorts(); - } - else - { - m_referenceNodeId = -1; - } - } - } - - public bool AutoRegister { get { return m_autoRegister; } } - public bool IsJagged { get { return m_isJagged; } } - public bool Updated { get { return m_updated; } } - public override string DataToArray { get { return m_name; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs.meta deleted file mode 100644 index c0171212..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GlobalArrayNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 833b18e1479dbd24c80c5b990e16e2bb -timeCreated: 1499769855 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs deleted file mode 100644 index b8f9437a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs +++ /dev/null @@ -1,191 +0,0 @@ -// 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( "Gradient", "Constants And Properties", "Gradient property" )] - public sealed class GradientNode : ParentNode - { - [SerializeField] - private Gradient m_gradient = new Gradient(); - - private string m_functionHeader = "NewGradient( {0}, {1}, {2}," + - " {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}," + - " {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18} )"; - private string m_functionBody = string.Empty; - - private string m_functionHeaderStruct = "Gradient( {0} )"; - private string m_functionBodyStruct = string.Empty; - - public Gradient Gradient { get { return m_gradient; } } - - public GradientNode() : base() { } - public GradientNode( 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 ); - m_insideSize.Set( 128, m_insideSize.y ); - AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue ); - m_autoWrapProperties = true; - m_textLabelWidth = 100; - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_gradient = EditorGUILayoutEx.GradientField( "Gradient", m_gradient ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( !m_isVisible ) - return; - - m_gradient = EditorGUIEx.GradientField( m_remainingBox, m_gradient ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - m_functionBodyStruct = string.Empty; - m_functionBody = string.Empty; - if( !dataCollector.IsSRP ) - { - GenerateGradientStruct( ref m_functionBodyStruct ); - dataCollector.AddFunctions( m_functionHeaderStruct, m_functionBodyStruct, "0" ); - GenerateGradient( ref m_functionBody ); - } - else - { - dataCollector.AddToIncludes( UniqueId, "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" ); - } - - string[] colors = new string[ 8 ]; - for( int i = 0; i < 8; i++ ) - { - if( i < m_gradient.colorKeys.Length ) - { - colors[ i ] = "float4( "+ m_gradient.colorKeys[ i ].color.r + ", "+ m_gradient.colorKeys[ i ].color.g + ", "+ m_gradient.colorKeys[ i ].color.b + ", "+ m_gradient.colorKeys[ i ].time + " )"; - } - else - { - colors[ i ] = "0"; - } - } - - string[] alphas = new string[ 8 ]; - for( int i = 0; i < 8; i++ ) - { - if( i < m_gradient.alphaKeys.Length ) - { - alphas[ i ] = "float2( " + m_gradient.alphaKeys[ i ].alpha + ", " + m_gradient.alphaKeys[ i ].time + " )"; - } - else - { - alphas[ i ] = "0"; - } - } - - string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, (int)m_gradient.mode, m_gradient.colorKeys.Length, m_gradient.alphaKeys.Length - , colors[ 0 ], colors[ 1 ], colors[ 2 ], colors[ 3 ], colors[ 4 ], colors[ 5 ], colors[ 6 ], colors[ 7 ] - , alphas[ 0 ], alphas[ 1 ], alphas[ 2 ], alphas[ 3 ], alphas[ 4 ], alphas[ 5 ], alphas[ 6 ], alphas[ 7 ] ); - - dataCollector.AddLocalVariable( UniqueId, "Gradient gradient" + UniqueId + " = " + functionResult + ";" ); - - return "gradient" + UniqueId; - } - - public static void GenerateGradientStruct( ref string body ) - { - body = string.Empty; - IOUtils.AddFunctionHeader( ref body, "struct Gradient" ); - IOUtils.AddFunctionLine( ref body, "int type;" ); - IOUtils.AddFunctionLine( ref body, "int colorsLength;" ); - IOUtils.AddFunctionLine( ref body, "int alphasLength;" ); - IOUtils.AddFunctionLine( ref body, "float4 colors[8];" ); - IOUtils.AddFunctionLine( ref body, "float2 alphas[8];" ); - IOUtils.AddSingleLineFunction( ref body, "};\n" ); - } - - public static void GenerateGradient( ref string body ) - { - body = string.Empty; - IOUtils.AddFunctionHeader( ref body, "Gradient NewGradient(int type, int colorsLength, int alphasLength, \n\t\tfloat4 colors0, float4 colors1, float4 colors2, float4 colors3, float4 colors4, float4 colors5, float4 colors6, float4 colors7,\n\t\tfloat2 alphas0, float2 alphas1, float2 alphas2, float2 alphas3, float2 alphas4, float2 alphas5, float2 alphas6, float2 alphas7)" ); - IOUtils.AddFunctionLine( ref body, "Gradient g;" ); - IOUtils.AddFunctionLine( ref body, "g.type = type;" ); - IOUtils.AddFunctionLine( ref body, "g.colorsLength = colorsLength;" ); - IOUtils.AddFunctionLine( ref body, "g.alphasLength = alphasLength;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 0 ] = colors0;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 1 ] = colors1;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 2 ] = colors2;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 3 ] = colors3;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 4 ] = colors4;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 5 ] = colors5;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 6 ] = colors6;" ); - IOUtils.AddFunctionLine( ref body, "g.colors[ 7 ] = colors7;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 0 ] = alphas0;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 1 ] = alphas1;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 2 ] = alphas2;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 3 ] = alphas3;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 4 ] = alphas4;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 5 ] = alphas5;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 6 ] = alphas6;" ); - IOUtils.AddFunctionLine( ref body, "g.alphas[ 7 ] = alphas7;" ); - IOUtils.AddFunctionLine( ref body, "return g;" ); - IOUtils.CloseFunctionBody( ref body ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_gradient.mode = (GradientMode)Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - int colorCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - int alphaCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - var colorKeys = new GradientColorKey[ colorCount ]; - for( int i = 0; i < colorCount; i++ ) - { - Vector4 colorKey = IOUtils.StringToVector4( GetCurrentParam( ref nodeParams ) ); - colorKeys[ i ].color = colorKey; - colorKeys[ i ].time = colorKey.w; - } - m_gradient.colorKeys = colorKeys; - - var alphaKeys = new GradientAlphaKey[ alphaCount ]; - for( int i = 0; i < alphaCount; i++ ) - { - Vector2 alphaKey = IOUtils.StringToVector2( GetCurrentParam( ref nodeParams ) ); - alphaKeys[ i ].alpha = alphaKey.x; - alphaKeys[ i ].time = alphaKey.y; - } - m_gradient.alphaKeys = alphaKeys; - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_gradient.mode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_gradient.colorKeys.Length ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_gradient.alphaKeys.Length ); - - for( int i = 0; i < m_gradient.colorKeys.Length; i++ ) - { - Vector4 colorKey = new Vector4( m_gradient.colorKeys[ i ].color.r, m_gradient.colorKeys[ i ].color.g, m_gradient.colorKeys[ i ].color.b, m_gradient.colorKeys[ i ].time) ; - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector4ToString( colorKey ) ); - } - - for( int i = 0; i < m_gradient.alphaKeys.Length; i++ ) - { - Vector2 alphaKey = new Vector4( m_gradient.alphaKeys[ i ].alpha, m_gradient.alphaKeys[ i ].time ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector2ToString( alphaKey ) ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs.meta deleted file mode 100644 index cb9b560a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/GradientNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 98100a8a545b8ce42bc5657fd40a24a5 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs deleted file mode 100644 index 3368c05d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs +++ /dev/null @@ -1,281 +0,0 @@ -// 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( "Int", "Constants And Properties", "Int property", null, KeyCode.Alpha0 )] - public sealed class IntNode : PropertyNode - { - [SerializeField] - private int m_defaultValue; - - [SerializeField] - private int m_materialValue; - - private const float LabelWidth = 8; - - private int m_cachedPropertyId = -1; - - private bool m_isEditingFields; - private int m_previousValue; - private string m_fieldText = "0"; - - public IntNode() : base() { } - public IntNode( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Int" ); - AddOutputPort( WirePortDataType.INT, Constants.EmptyPortValue ); - m_insideSize.Set( 50, 10 ); - m_selectedLocation = PreviewLocation.BottomCenter; - m_drawPrecisionUI = false; - m_showHybridInstancedUI = true; - m_availableAttribs.Add( new PropertyAttributes( "Enum", "[Enum]" ) ); - m_previewShaderGUID = "0f64d695b6ffacc469f2dd31432a232a"; - m_srpBatcherCompatible = true; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterFloatIntNode( this ); - } - - public override void Destroy() - { - base.Destroy(); - UIUtils.UnregisterFloatIntNode( this ); - } - - public override void OnDirtyProperty() - { - UIUtils.UpdateFloatIntDataNode( UniqueId, PropertyInspectorName ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - OnPropertyNameChanged(); - OnDirtyProperty(); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputInt" ); - - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetInt( m_cachedPropertyId, m_materialValue ); - else - PreviewMaterial.SetInt( m_cachedPropertyId, m_defaultValue ); - } - - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - m_defaultValue = EditorGUILayoutIntField( Constants.DefaultValueLabel, m_defaultValue ); - } - - public override void DrawMaterialProperties() - { - if( m_materialMode ) - EditorGUI.BeginChangeCheck(); - - m_materialValue = EditorGUILayoutIntField( Constants.MaterialValueLabel, m_materialValue ); - - if( m_materialMode && EditorGUI.EndChangeCheck() ) - { - m_requireMaterialUpdate = true; - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( !m_isVisible ) - return; - - if( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - float labelWidth = EditorGUIUtility.labelWidth; - EditorGUIUtility.labelWidth = LabelWidth * drawInfo.InvertedZoom; - - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - EditorGUI.BeginChangeCheck(); - m_materialValue = EditorGUIIntField( m_propertyDrawPos, " ", m_materialValue, UIUtils.MainSkin.textField ); - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = true; - if( m_currentParameterType != PropertyType.Constant ) - BeginDelayedDirtyProperty(); - } - } - else - { - EditorGUI.BeginChangeCheck(); - - m_defaultValue = EditorGUIIntField( m_propertyDrawPos, " ", m_defaultValue, UIUtils.MainSkin.textField ); - - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - BeginDelayedDirtyProperty(); - } - } - EditorGUIUtility.labelWidth = labelWidth; - } - else if( drawInfo.CurrentEventType == EventType.Repaint ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - if( GUI.enabled ) - { - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - } - bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant; - int value = currMode ? m_materialValue : m_defaultValue; - - if( m_previousValue != value ) - { - m_previousValue = value; - m_fieldText = value.ToString(); - } - - GUI.Label( fakeField, m_fieldText, UIUtils.MainSkin.textField ); - GUI.enabled = guiEnabled; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - if( m_currentParameterType != PropertyType.Constant ) - return PropertyData( dataCollector.PortCategory ); - - return m_defaultValue.ToString(); - } - - public override string GetPropertyValue() - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Int) = " + m_defaultValue; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetInt( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetInt( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetInt( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - m_materialValue = 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_defaultValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_materialValue ); - } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? - m_materialValue.ToString( Mathf.Abs( m_materialValue ) > 1000 ? Constants.PropertyBigIntFormatLabel : Constants.PropertyIntFormatLabel ) : - m_defaultValue.ToString( Mathf.Abs( m_defaultValue ) > 1000 ? Constants.PropertyBigIntFormatLabel : Constants.PropertyIntFormatLabel ); - } - - public override void SetGlobalValue() { Shader.SetGlobalInt( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalInt( m_propertyName ); } - public int Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - - public void SetMaterialValueFromInline( int val ) - { - m_materialValue = val; - m_requireMaterialUpdate = true; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs.meta deleted file mode 100644 index 0bbac6ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/IntNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 86df2da3da3b1eb4493b968b47030b17 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs deleted file mode 100644 index 02266c8b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs +++ /dev/null @@ -1,261 +0,0 @@ -// 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( "Matrix3X3", "Constants And Properties", "Matrix3X3 property" )] - public sealed class Matrix3X3Node : MatrixParentNode - { - private string[,] m_fieldText = new string[ 3, 3 ] { { "0", "0", "0" }, { "0", "0", "0" }, { "0", "0", "0" } }; - public Matrix3X3Node() : base() { } - public Matrix3X3Node( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Matrix" ); - AddOutputPort( WirePortDataType.FLOAT3x3, Constants.EmptyPortValue ); - m_insideSize.Set( Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE * 3 + Constants.FLOAT_WIDTH_SPACING * 2, Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE * 3 + Constants.FLOAT_WIDTH_SPACING * 2 + Constants.OUTSIDE_WIRE_MARGIN ); - //m_defaultValue = new Matrix4x4(); - //m_materialValue = new Matrix4x4(); - m_drawPreview = false; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - EditorGUILayout.LabelField( Constants.DefaultValueLabel ); - for( int row = 0; row < 3; row++ ) - { - EditorGUILayout.BeginHorizontal(); - for( int column = 0; column < 3; column++ ) - { - m_defaultValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_defaultValue[ row, column ], GUILayout.MaxWidth( 76 ) ); - } - EditorGUILayout.EndHorizontal(); - } - } - - public override void DrawMaterialProperties() - { - if( m_materialMode ) - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.LabelField( Constants.MaterialValueLabel ); - for( int row = 0; row < 3; row++ ) - { - EditorGUILayout.BeginHorizontal(); - for( int column = 0; column < 3; column++ ) - { - m_materialValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_materialValue[ row, column ], GUILayout.MaxWidth( 76 ) ); - } - EditorGUILayout.EndHorizontal(); - } - - if( m_materialMode && EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos.position = m_remainingBox.position; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.height = m_insideSize.y * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( !m_isVisible ) - return; - - if( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant; - Matrix4x4 value = currMode ? m_materialValue : m_defaultValue; - - EditorGUI.BeginChangeCheck(); - for( int row = 0; row < 3; row++ ) - { - for( int column = 0; column < 3; column++ ) - { - m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ); - value[ row, column ] = EditorGUIFloatField( m_propertyDrawPos, string.Empty, value[ row, column ], UIUtils.MainSkin.textField ); - } - } - - if( currMode ) - { - m_materialValue = value; - } - else - { - m_defaultValue = value; - } - - if( EditorGUI.EndChangeCheck() ) - { - m_requireMaterialUpdate = m_materialMode; - BeginDelayedDirtyProperty(); - } - } - else if( drawInfo.CurrentEventType == EventType.Repaint ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - - bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant; - Matrix4x4 value = currMode ? m_materialValue : m_defaultValue; - for( int row = 0; row < 3; row++ ) - { - for( int column = 0; column < 3; column++ ) - { - Rect fakeField = m_propertyDrawPos; - fakeField.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ); - if( GUI.enabled ) - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - - if( m_previousValue[ row, column ] != value[ row, column ] ) - { - m_previousValue[ row, column ] = value[ row, column ]; - m_fieldText[ row, column ] = value[ row, column ].ToString(); - } - - GUI.Label( fakeField, m_fieldText[ row, column ], UIUtils.MainSkin.textField ); - } - } - GUI.enabled = guiEnabled; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - if( m_currentParameterType != PropertyType.Constant ) - { - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - string localVarName = PropertyData( dataCollector.PortCategory ) + "Local3x3"; - string localVarValue = string.Format( "float3x3({0}._m00,{0}._m01,{0}._m02,{0}._m10,{0}._m11,{0}._m12,{0}._m20,{0}._m21,{0}._m22 )", PropertyData( dataCollector.PortCategory ) ); - RegisterLocalVariable( 0, localVarValue, ref dataCollector, localVarName ); - return localVarName; - } - - Matrix4x4 value = m_defaultValue; - - return m_precisionString + "(" + value[ 0, 0 ] + "," + value[ 0, 1 ] + "," + value[ 0, 2 ] + "," + - +value[ 1, 0 ] + "," + value[ 1, 1 ] + "," + value[ 1, 2 ] + "," + - +value[ 2, 0 ] + "," + value[ 2, 1 ] + "," + value[ 2, 2 ] + ")"; - - } - - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - Shader.SetGlobalMatrix( m_propertyName, m_materialValue ); - //mat.SetMatrix( m_propertyName, m_materialValue ); - } - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT4x4 ); - dataName = m_propertyName; - return true; - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetMatrix( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetMatrix( m_propertyName ); - PreviewIsDirty = true; - } - } - - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToMatrix3x3( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix3x3ToString( m_defaultValue ) ); - } - - public override void ReadAdditionalClipboardData( ref string[] nodeParams ) - { - base.ReadAdditionalClipboardData( ref nodeParams ); - m_materialValue = IOUtils.StringToMatrix3x3( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteAdditionalClipboardData( ref string nodeInfo ) - { - base.WriteAdditionalClipboardData( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix3x3ToString( m_materialValue ) ); - } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue[ 0, 0 ].ToString( Mathf.Abs( m_materialValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 1 ].ToString( Mathf.Abs( m_materialValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 2 ].ToString( Mathf.Abs( m_materialValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_materialValue[ 1, 0 ].ToString( Mathf.Abs( m_materialValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 1 ].ToString( Mathf.Abs( m_materialValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 2 ].ToString( Mathf.Abs( m_materialValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_materialValue[ 2, 0 ].ToString( Mathf.Abs( m_materialValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 1 ].ToString( Mathf.Abs( m_materialValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 2 ].ToString( Mathf.Abs( m_materialValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) : - - m_defaultValue[ 0, 0 ].ToString( Mathf.Abs( m_defaultValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 1 ].ToString( Mathf.Abs( m_defaultValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 2 ].ToString( Mathf.Abs( m_defaultValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_defaultValue[ 1, 0 ].ToString( Mathf.Abs( m_defaultValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 1 ].ToString( Mathf.Abs( m_defaultValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 2 ].ToString( Mathf.Abs( m_defaultValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_defaultValue[ 2, 0 ].ToString( Mathf.Abs( m_defaultValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 1 ].ToString( Mathf.Abs( m_defaultValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 2 ].ToString( Mathf.Abs( m_defaultValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs.meta deleted file mode 100644 index 4c852d9d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix3X3Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 01e5a5829caac674fa819ed229de31b6 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs deleted file mode 100644 index 44b99702..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs +++ /dev/null @@ -1,248 +0,0 @@ -// 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( "Matrix4X4", "Constants And Properties", "Matrix4X4 property" )] - public sealed class Matrix4X4Node : MatrixParentNode - { - private string[,] m_fieldText = new string[ 4, 4 ] { { "0", "0", "0", "0" }, { "0", "0", "0", "0" }, { "0", "0", "0", "0" }, { "0", "0", "0", "0" } }; - public Matrix4X4Node() : base() { } - public Matrix4X4Node( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Matrix" ); - AddOutputPort( WirePortDataType.FLOAT4x4, Constants.EmptyPortValue ); - m_insideSize.Set( Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE * 4 + Constants.FLOAT_WIDTH_SPACING * 3, Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE * 4 + Constants.FLOAT_WIDTH_SPACING * 3 + Constants.OUTSIDE_WIRE_MARGIN ); - //m_defaultValue = new Matrix4x4(); - //m_materialValue = new Matrix4x4(); - m_drawPreview = false; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - EditorGUILayout.LabelField( Constants.DefaultValueLabel ); - for ( int row = 0; row < 4; row++ ) - { - EditorGUILayout.BeginHorizontal(); - for ( int column = 0; column < 4; column++ ) - { - m_defaultValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_defaultValue[ row, column ], GUILayout.MaxWidth( 55 ) ); - } - EditorGUILayout.EndHorizontal(); - } - } - - public override void DrawMaterialProperties() - { - if ( m_materialMode ) - EditorGUI.BeginChangeCheck(); - - EditorGUILayout.LabelField( Constants.MaterialValueLabel ); - for ( int row = 0; row < 4; row++ ) - { - EditorGUILayout.BeginHorizontal(); - for ( int column = 0; column < 4; column++ ) - { - m_materialValue[ row, column ] = EditorGUILayoutFloatField( string.Empty, m_materialValue[ row, column ], GUILayout.MaxWidth( 55 ) ); - } - EditorGUILayout.EndHorizontal(); - } - - if ( m_materialMode && EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos.position = m_remainingBox.position; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.height = m_insideSize.y * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if ( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if ( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant; - Matrix4x4 value = currMode ? m_materialValue : m_defaultValue; - - EditorGUI.BeginChangeCheck(); - for ( int row = 0; row < 4; row++ ) - { - for ( int column = 0; column < 4; column++ ) - { - m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ); - value[ row, column ] = EditorGUIFloatField( m_propertyDrawPos, string.Empty, value[ row, column ], UIUtils.MainSkin.textField ); - } - } - - if ( currMode ) - { - m_materialValue = value; - } - else - { - m_defaultValue = value; - } - - if ( EditorGUI.EndChangeCheck() ) - { - m_requireMaterialUpdate = m_materialMode; - BeginDelayedDirtyProperty(); - } - } - else if ( drawInfo.CurrentEventType == EventType.Repaint ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - - bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant; - Matrix4x4 value = currMode ? m_materialValue : m_defaultValue; - for ( int row = 0; row < 4; row++ ) - { - for ( int column = 0; column < 4; column++ ) - { - Rect fakeField = m_propertyDrawPos; - fakeField.position = m_remainingBox.position + Vector2.Scale( m_propertyDrawPos.size, new Vector2( column, row ) ) + new Vector2( Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row ); - if( GUI.enabled ) - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - - if ( m_previousValue[ row, column ] != value[ row, column ] ) - { - m_previousValue[ row, column ] = value[ row, column ]; - m_fieldText[ row, column ] = value[ row, column ].ToString(); - } - - GUI.Label( fakeField, m_fieldText[ row, column ], UIUtils.MainSkin.textField ); - } - } - GUI.enabled = guiEnabled; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - if ( m_currentParameterType != PropertyType.Constant ) - return PropertyData( dataCollector.PortCategory ); - - Matrix4x4 value = m_defaultValue; - - return m_precisionString+"(" + value[ 0, 0 ] + "," + value[ 0, 1 ] + "," + value[ 0, 2 ] + "," + value[ 0, 3 ] + "," + - +value[ 1, 0 ] + "," + value[ 1, 1 ] + "," + value[ 1, 2 ] + "," + value[ 1, 3 ] + "," + - +value[ 2, 0 ] + "," + value[ 2, 1 ] + "," + value[ 2, 2 ] + "," + value[ 2, 3 ] + "," + - +value[ 3, 0 ] + "," + value[ 3, 1 ] + "," + value[ 3, 2 ] + "," + value[ 3, 3 ] + ")"; - - } - - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetMatrix( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat , bool fetchMaterialValues ) - { - base.SetMaterialMode( mat , fetchMaterialValues ); - if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetMatrix( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetMatrix( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToMatrix4x4( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix4x4ToString( m_defaultValue ) ); - } - - public override void ReadAdditionalClipboardData( ref string[] nodeParams ) - { - base.ReadAdditionalClipboardData( ref nodeParams ); - m_materialValue = IOUtils.StringToMatrix4x4( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteAdditionalClipboardData( ref string nodeInfo ) - { - base.WriteAdditionalClipboardData( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Matrix4x4ToString( m_materialValue ) ); - } - - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue[ 0, 0 ].ToString( Mathf.Abs( m_materialValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 1 ].ToString( Mathf.Abs( m_materialValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 2 ].ToString( Mathf.Abs( m_materialValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 0, 3 ].ToString( Mathf.Abs( m_materialValue[ 0, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_materialValue[ 1, 0 ].ToString( Mathf.Abs( m_materialValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 1 ].ToString( Mathf.Abs( m_materialValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 2 ].ToString( Mathf.Abs( m_materialValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 1, 3 ].ToString( Mathf.Abs( m_materialValue[ 1, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_materialValue[ 2, 0 ].ToString( Mathf.Abs( m_materialValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 1 ].ToString( Mathf.Abs( m_materialValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 2 ].ToString( Mathf.Abs( m_materialValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 2, 3 ].ToString( Mathf.Abs( m_materialValue[ 2, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_materialValue[ 3, 0 ].ToString( Mathf.Abs( m_materialValue[ 3, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 1 ].ToString( Mathf.Abs( m_materialValue[ 3, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 2 ].ToString( Mathf.Abs( m_materialValue[ 3, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_materialValue[ 3, 3 ].ToString( Mathf.Abs( m_materialValue[ 3, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) : - - m_defaultValue[ 0, 0 ].ToString( Mathf.Abs( m_defaultValue[ 0, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 1 ].ToString( Mathf.Abs( m_defaultValue[ 0, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 2 ].ToString( Mathf.Abs( m_defaultValue[ 0, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 0, 3 ].ToString( Mathf.Abs( m_defaultValue[ 0, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_defaultValue[ 1, 0 ].ToString( Mathf.Abs( m_defaultValue[ 1, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 1 ].ToString( Mathf.Abs( m_defaultValue[ 1, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 2 ].ToString( Mathf.Abs( m_defaultValue[ 1, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 1, 3 ].ToString( Mathf.Abs( m_defaultValue[ 1, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_defaultValue[ 2, 0 ].ToString( Mathf.Abs( m_defaultValue[ 2, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 1 ].ToString( Mathf.Abs( m_defaultValue[ 2, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 2 ].ToString( Mathf.Abs( m_defaultValue[ 2, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 2, 3 ].ToString( Mathf.Abs( m_defaultValue[ 2, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.MATRIX_DATA_SEPARATOR + - m_defaultValue[ 3, 0 ].ToString( Mathf.Abs( m_defaultValue[ 3, 0 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 1 ].ToString( Mathf.Abs( m_defaultValue[ 3, 1 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 2 ].ToString( Mathf.Abs( m_defaultValue[ 3, 2 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ) + IOUtils.VECTOR_SEPARATOR + m_defaultValue[ 3, 3 ].ToString( Mathf.Abs( m_defaultValue[ 3, 3 ] ) > 1000 ? Constants.PropertyBigMatrixFormatLabel : Constants.PropertyMatrixFormatLabel ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs.meta deleted file mode 100644 index 10ec1a2f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Matrix4X4Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4fa5db614b9379b4da27edafa0a8f4e9 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs deleted file mode 100644 index 85e0504d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class MatrixParentNode : PropertyNode - { - private readonly string[] AvailablePropertyTypeLabels = { PropertyType.Constant.ToString(), PropertyType.Global.ToString(), "Instanced" }; - private readonly int[] AvailablePropertyTypeValues = { (int)PropertyType.Constant, (int)PropertyType.Global , (int)PropertyType.InstancedProperty }; - - protected bool m_isEditingFields; - - [SerializeField] - protected Matrix4x4 m_defaultValue = Matrix4x4.identity; - - [SerializeField] - protected Matrix4x4 m_materialValue = Matrix4x4.identity; - - [NonSerialized] - protected Matrix4x4 m_previousValue; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - public MatrixParentNode() : base() { } - public MatrixParentNode( 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 ); - m_freeType = false; - m_showVariableMode = true; - } - - public override void AfterCommonInit() - { - base.AfterCommonInit(); - m_hasLeftDropdown = true; - m_drawAttributes = false; - m_availableAttribs.Clear(); - - if( PaddingTitleLeft == 0 ) - { - PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin; - if( PaddingTitleRight == 0 ) - PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin; - } - } - - protected void DrawParameterType() - { - PropertyType parameterType = (PropertyType)EditorGUILayoutIntPopup( ParameterTypeStr, (int)m_currentParameterType, AvailablePropertyTypeLabels, AvailablePropertyTypeValues ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - PropertyType parameterType = (PropertyType)m_upperLeftWidget.DrawWidget( this, (int)m_currentParameterType, AvailablePropertyTypeLabels, AvailablePropertyTypeValues ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - } - } - - public override void DrawMainPropertyBlock() - { - DrawParameterType(); - base.DrawMainPropertyBlock(); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void SetGlobalValue() { Shader.SetGlobalMatrix( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalMatrix( m_propertyName ); } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs.meta deleted file mode 100644 index ed87f49f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/MatrixParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d31dc25864c509a4f967e32079a27d6f -timeCreated: 1507902748 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs deleted file mode 100644 index 659a128c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs +++ /dev/null @@ -1,63 +0,0 @@ -// 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( "PI", "Constants And Properties", "PI constant : 3.14159265359" )] - public sealed class PiNode : ParentNode - { - public PiNode() : base() { } - public PiNode( 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.FLOAT, true, "Multiplier" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 70; - InputPorts[ 0 ].FloatInternalData = 1; - m_useInternalPortData = true; - m_previewShaderGUID = "bf4a65726dab3d445a69fb1d0945c33e"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - string finalValue = string.Empty; - string piString = dataCollector.IsSRP ? "PI" : "UNITY_PI"; - if( !InputPorts[ 0 ].IsConnected && InputPorts[ 0 ].FloatInternalData == 1 ) - { - finalValue = piString; - } else - { - string multiplier = InputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - finalValue = "( " + multiplier + " * " + piString + " )"; - } - - - if ( finalValue.Equals( string.Empty ) ) - { - UIUtils.ShowMessage( UniqueId, "PINode generating empty code", MessageSeverity.Warning ); - } - return finalValue; - } - - //public override void ReadFromString( ref string[] nodeParams ) - //{ - // base.ReadFromString( ref nodeParams ); - - // Removed on version 5004 - //m_value = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - //} - - //public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - //{ - // base.WriteToString( ref nodeInfo, ref connectionsInfo ); - //} - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs.meta deleted file mode 100644 index 64327b84..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7a8a03953b97a594b81b2fb71d4a57ec -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs deleted file mode 100644 index 68709954..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs +++ /dev/null @@ -1,1767 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public enum PropertyType - { - Constant = 0, - Property, - InstancedProperty, - Global - } - - public enum VariableMode - { - Create = 0, - Fetch - } - - [Serializable] - public class PropertyAttributes - { - public string Name; - public string Attribute; - public PropertyAttributes( string name, string attribute ) - { - Name = name; - Attribute = attribute; - } - } - - [Serializable] - public class PropertyNode : ParentNode - { - private const string LongNameEnder = "... )"; - protected int m_longNameSize = 200; - //private const string InstancedPropertyWarning = "Instanced Property option shouldn't be used on official SRP templates as all property variables are already declared as instanced inside a CBuffer.\nPlease consider changing to Property option."; - private string TooltipFormatter = "{0}\n\nName: {1}\nValue: {2}"; - protected string GlobalTypeWarningText = "Global variables must be set via a C# script using the Shader.SetGlobal{0}(...) method.\nPlease note that setting a global variable will affect all shaders which are using it."; - private const string HybridInstancedStr = "Hybrid Instanced"; - private const string AutoRegisterStr = "Auto-Register"; - private const string IgnoreVarDeclarationStr = "Variable Mode"; - private const string IsPropertyStr = "Is Property"; - private const string PropertyNameStr = "Property Name"; - private const string PropertyInspectorStr = "Name"; - protected const string EnumsStr = "Enums"; - protected const string CustomAttrStr = "Custom Attributes"; - protected const string ParameterTypeStr = "Type"; - private const string PropertyTextfieldControlName = "PropertyName"; - private const string PropertyInspTextfieldControlName = "PropertyInspectorName"; - private const string OrderIndexStr = "Order Index"; - protected const double MaxTimestamp = 2; - private const double MaxPropertyTimestamp = 2; - private const double MaxGlobalFetchTimestamp = 2; - protected readonly string[] LabelToolbarTitle = { "Material", "Default" }; - protected readonly string[] EnumModesStr = { "Create Enums", "Use Engine Enum Class" }; - protected readonly int[] EnumModeIntValues = { 0, 1 }; - private const string FetchToCreateDuplicatesMsg = "Reverting property name from '{0}' to '{1}' as it is registered to another property node."; - private const string FetchToCreateOnDuplicateNodeMsg = "Setting new property name '{0}' as '{1}' is registered to another property node."; - [SerializeField] - protected PropertyType m_currentParameterType; - - [SerializeField] - private PropertyType m_lastParameterType; - - [SerializeField] - protected string m_propertyName = string.Empty; - - [SerializeField] - protected string m_propertyInspectorName = string.Empty; - - [SerializeField] - protected string m_precisionString; - protected bool m_drawPrecisionUI = true; - - [SerializeField] - private int m_orderIndex = -1; - - [SerializeField] - protected VariableMode m_variableMode = VariableMode.Create; - - [SerializeField] - protected bool m_autoGlobalName = true; - - [SerializeField] - protected bool m_hybridInstanced = false; - - [SerializeField] - protected bool m_autoRegister = false; - - [SerializeField] - protected bool m_registerPropertyOnInstancing = true; - - [SerializeField] - private List<string> m_enumNames = new List<string>(); - - [SerializeField] - private List<int> m_enumValues = new List<int>(); - - [SerializeField] - private int m_enumCount = 0; - - [SerializeField] - private int m_enumModeInt = 0; - - [SerializeField] - private int m_customAttrCount = 0; - - [SerializeField] - private List<string> m_customAttr = new List<string>(); - - [SerializeField] - private string m_enumClassName = string.Empty; - - private bool m_hasEnum = false; - - protected bool m_showTitleWhenNotEditing = true; - - private int m_orderIndexOffset = 0; - - protected bool m_drawAttributes = true; - - protected bool m_underscoredGlobal = false; - protected bool m_globalDefaultBehavior = true; - - protected bool m_freeName; - protected bool m_freeType; - protected bool m_showVariableMode = false; - protected bool m_propertyNameIsDirty; - - protected bool m_showAutoRegisterUI = true; - - protected bool m_showHybridInstancedUI = false; - - protected bool m_useVarSubtitle = false; - - protected bool m_propertyFromInspector; - protected double m_propertyFromInspectorTimestamp; - - protected bool m_checkDuplicateProperty; - protected double m_checkDuplicatePropertyTimestamp; - - protected double m_globalFetchTimestamp; - - protected bool m_delayedDirtyProperty; - protected double m_delayedDirtyPropertyTimestamp; - - protected string m_defaultPropertyName; - protected string m_oldName = string.Empty; - - private bool m_reRegisterName = false; - protected bool m_allowPropertyDuplicates = false; - //protected bool m_useCustomPrefix = false; - protected string m_customPrefix = null; - - protected int m_propertyTab = 0; - - [SerializeField] - private string m_uniqueName; - - // Property Attributes - private const float ButtonLayoutWidth = 15; - - protected bool m_visibleAttribsFoldout; - protected bool m_visibleEnumsFoldout; - protected bool m_visibleCustomAttrFoldout; - protected List<PropertyAttributes> m_availableAttribs = new List<PropertyAttributes>(); - private string[] m_availableAttribsArr; - - [SerializeField] - private bool[] m_selectedAttribsArr; - - [SerializeField] - protected List<int> m_selectedAttribs = new List<int>(); - - //Title editing - protected bool m_isEditing; - protected bool m_stopEditing; - protected bool m_startEditing; - protected double m_clickTime; - protected double m_doubleClickTime = 0.3; - private Rect m_titleClickArea; - - protected bool m_srpBatcherCompatible = false; - protected bool m_excludeUniform = false; - - [SerializeField] - private bool m_addGlobalToSRPBatcher = false; - - public PropertyNode() : base() { } - public PropertyNode( 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 ); - m_textLabelWidth = 105; - if( UIUtils.CurrentWindow != null && UIUtils.CurrentWindow.CurrentGraph != null ) - m_orderIndex = UIUtils.GetPropertyNodeAmount(); - m_currentParameterType = PropertyType.Constant; - m_freeType = true; - m_freeName = true; - m_propertyNameIsDirty = true; - m_customPrecision = true; - m_availableAttribs.Add( new PropertyAttributes( "Hide in Inspector", "[HideInInspector]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "HDR", "[HDR]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Gamma", "[Gamma]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Per Renderer Data", "[PerRendererData]" ) ); - } - - public override void AfterCommonInit() - { - base.AfterCommonInit(); - - if( PaddingTitleLeft == 0 && m_freeType ) - { - PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin; - if( PaddingTitleRight == 0 ) - PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin; - } - - m_hasLeftDropdown = m_freeType; - } - - protected void BeginDelayedDirtyProperty() - { - m_delayedDirtyProperty = true; - m_delayedDirtyPropertyTimestamp = EditorApplication.timeSinceStartup; - } - - public void CheckDelayedDirtyProperty() - { - if( m_delayedDirtyProperty ) - { - if( ( EditorApplication.timeSinceStartup - m_delayedDirtyPropertyTimestamp ) > MaxPropertyTimestamp ) - { - m_delayedDirtyProperty = false; - m_propertyNameIsDirty = true; - m_sizeIsDirty = true; - } - } - } - - public void BeginPropertyFromInspectorCheck() - { - m_propertyFromInspector = true; - m_propertyFromInspectorTimestamp = EditorApplication.timeSinceStartup; - } - - public virtual void CheckPropertyFromInspector( bool forceUpdate = false ) - { - if( m_propertyFromInspector ) - { - if( forceUpdate || ( EditorApplication.timeSinceStartup - m_propertyFromInspectorTimestamp ) > MaxTimestamp ) - { - m_propertyFromInspector = false; - bool autoGlobal = m_autoGlobalName || m_currentParameterType == PropertyType.Global; - RegisterPropertyName( true, m_propertyInspectorName, autoGlobal, m_underscoredGlobal ); - m_propertyNameIsDirty = true; - } - } - } - - public void CheckDuplicateProperty() - { - if( m_checkDuplicateProperty && - ( EditorApplication.timeSinceStartup - m_checkDuplicatePropertyTimestamp ) > MaxTimestamp ) - { - m_checkDuplicateProperty = false; - m_propertyName = UIUtils.GeneratePropertyName( m_propertyName, PropertyType.Global, false ); - - if( UIUtils.IsNumericName( m_propertyName ) ) - { - UIUtils.ShowMessage( UniqueId, string.Format("Invalid property name '{0}' as it cannot start with numbers. Reverting to previous name.", m_propertyName ), MessageSeverity.Warning ); - m_propertyName = m_oldName; - GUI.FocusControl( string.Empty ); - return; - } - - if( !m_propertyName.Equals( m_oldName ) ) - { - if( UIUtils.IsUniformNameAvailable( m_propertyName ) || m_allowPropertyDuplicates ) - { - UIUtils.ReleaseUniformName( UniqueId, m_oldName ); - - m_oldName = m_propertyName; - m_propertyNameIsDirty = true; - m_reRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, m_propertyName ); - OnPropertyNameChanged(); - } - else - { - GUI.FocusControl( string.Empty ); - RegisterFirstAvailablePropertyName( true, true ); - UIUtils.ShowMessage( UniqueId, string.Format( "Duplicate property name found on edited node.\nAssigning first valid one {0}", m_propertyName ) ); - } - } - } - } - - protected override void OnUniqueIDAssigned() - { - if( m_variableMode == VariableMode.Create ) - RegisterFirstAvailablePropertyName( false ); - - if( m_nodeAttribs != null ) - m_uniqueName = m_nodeAttribs.Name + UniqueId; - - UIUtils.RegisterRawPropertyNode( this ); - } - - public bool CheckLocalVariable( ref MasterNodeDataCollector dataCollector ) - { - bool addToLocalValue = false; - int count = 0; - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - if( m_outputPorts[ i ].ConnectionCount > 1 ) - { - addToLocalValue = true; - break; - } - count += 1; - if( count > 1 ) - { - addToLocalValue = true; - break; - } - } - } - - if( addToLocalValue ) - { - ConfigureLocalVariable( ref dataCollector ); - } - - return addToLocalValue; - } - - public virtual void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector ) { } - public virtual void CopyDefaultsToMaterial() { } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - RegisterPropertyName( true, obj.name, true, m_underscoredGlobal ); - } - - public void ChangeParameterType( PropertyType parameterType ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoChangePropertyTypeNodesId ); - Undo.RegisterCompleteObjectUndo( m_containerGraph, Constants.UndoChangePropertyTypeNodesId ); - Undo.RecordObject( this, Constants.UndoChangePropertyTypeNodesId ); - - if( m_currentParameterType == PropertyType.Constant || m_currentParameterType == PropertyType.Global ) - { - CopyDefaultsToMaterial(); - } - - if( parameterType == PropertyType.InstancedProperty ) - { - //if( m_containerGraph.IsSRP ) - //{ - // UIUtils.ShowMessage( InstancedPropertyWarning,MessageSeverity.Warning ); - //} - - UIUtils.CurrentWindow.OutsideGraph.AddInstancePropertyCount(); - } - else if( m_currentParameterType == PropertyType.InstancedProperty ) - { - UIUtils.CurrentWindow.OutsideGraph.RemoveInstancePropertyCount(); - } - - if( ( parameterType == PropertyType.Property || parameterType == PropertyType.InstancedProperty ) - && m_currentParameterType != PropertyType.Property && m_currentParameterType != PropertyType.InstancedProperty ) - { - UIUtils.RegisterPropertyNode( this ); - } - - if( ( parameterType != PropertyType.Property && parameterType != PropertyType.InstancedProperty ) - && ( m_currentParameterType == PropertyType.Property || m_currentParameterType == PropertyType.InstancedProperty ) ) - { - UIUtils.UnregisterPropertyNode( this ); - } - - m_currentParameterType = parameterType; - if( parameterType == PropertyType.Constant ) - { - CurrentVariableMode = VariableMode.Create; - } - - } - - void InitializeAttribsArray() - { - m_availableAttribsArr = new string[ m_availableAttribs.Count ]; - m_selectedAttribsArr = new bool[ m_availableAttribs.Count ]; - for( int i = 0; i < m_availableAttribsArr.Length; i++ ) - { - m_availableAttribsArr[ i ] = m_availableAttribs[ i ].Name; - m_selectedAttribsArr[ i ] = false; - - if( m_selectedAttribs.FindIndex( x => x == i ) > -1 ) - { - m_selectedAttribsArr[ i ] = true; - m_visibleAttribsFoldout = true; - } - } - } - - protected virtual void OnAtrributesChanged() { CheckEnumAttribute(); } - void DrawAttributesAddRemoveButtons() - { - if( m_availableAttribsArr == null ) - { - InitializeAttribsArray(); - } - - int attribCount = m_selectedAttribs.Count; - // Add new port - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - m_visibleAttribsFoldout = true; - m_selectedAttribs.Add( 0 ); - OnAtrributesChanged(); - } - - //Remove port - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - if( attribCount > 0 ) - { - m_selectedAttribs.RemoveAt( attribCount - 1 ); - OnAtrributesChanged(); - } - } - } - - void CheckEnumAttribute() - { - m_hasEnum = false; - foreach( var item in m_selectedAttribs ) - { - if( m_availableAttribsArr[ item ].Equals( "Enum" ) ) - m_hasEnum = true; - } - } - void DrawEnumAddRemoveButtons() - { - // Add new port - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) && m_enumModeInt == 0 ) - { - m_enumNames.Add( "Option" + ( m_enumValues.Count + 1 ) ); - m_enumValues.Add( m_enumValues.Count ); - m_enumCount++; - m_visibleEnumsFoldout = true; - } - - //Remove port - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) && m_enumModeInt == 0 ) - { - if( m_enumNames.Count - 1 > -1 ) - { - m_enumNames.RemoveAt( m_enumNames.Count - 1 ); - m_enumValues.RemoveAt( m_enumValues.Count - 1 ); - m_enumCount--; - } - } - } - - protected void DrawEnums() - { - m_enumModeInt = EditorGUILayout.IntPopup( "Mode", m_enumModeInt, EnumModesStr, EnumModeIntValues ); - - if( m_enumModeInt == 0 ) - { - if( m_enumNames.Count == 0 ) - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add more.", MessageType.Info ); - - float cacheLabelSize = EditorGUIUtility.labelWidth; - EditorGUIUtility.labelWidth = 50; - - for( int i = 0; i < m_enumNames.Count; i++ ) - { - EditorGUI.BeginChangeCheck(); - EditorGUILayout.BeginHorizontal(); - m_enumNames[ i ] = EditorGUILayoutTextField( "Name", m_enumNames[ i ] ); - m_enumValues[ i ] = EditorGUILayoutIntField( "Value", m_enumValues[ i ], GUILayout.Width( 100 ) ); - EditorGUILayout.EndHorizontal(); - if( EditorGUI.EndChangeCheck() ) - { - m_enumNames[ i ] = UIUtils.RemoveInvalidEnumCharacters( m_enumNames[ i ] ); - if( string.IsNullOrEmpty( m_enumNames[ i ] ) ) - { - m_enumNames[ i ] = "Option" + ( i + 1 ); - } - } - } - - EditorGUIUtility.labelWidth = cacheLabelSize; - if( m_enumNames.Count > 0 ) - { - EditorGUILayout.BeginHorizontal(); - GUILayout.Label( " " ); - DrawEnumAddRemoveButtons(); - EditorGUILayout.EndHorizontal(); - } - } - else - { - EditorGUILayout.BeginHorizontal(); - m_enumClassName = EditorGUILayoutTextField( "Class Name", m_enumClassName ); - - if( GUILayout.Button( string.Empty, UIUtils.InspectorPopdropdownFallback, GUILayout.Width( 17 ), GUILayout.Height( 19 ) ) ) - { - GenericMenu menu = new GenericMenu(); - AddMenuItem( menu, "UnityEngine.Rendering.CullMode" ); - AddMenuItem( menu, "UnityEngine.Rendering.ColorWriteMask" ); - AddMenuItem( menu, "UnityEngine.Rendering.CompareFunction" ); - AddMenuItem( menu, "UnityEngine.Rendering.StencilOp" ); - AddMenuItem( menu, "UnityEngine.Rendering.BlendMode" ); - AddMenuItem( menu, "UnityEngine.Rendering.BlendOp" ); - menu.ShowAsContext(); - } - EditorGUILayout.EndHorizontal(); - } - } - - private void AddMenuItem( GenericMenu menu, string newClass ) - { - menu.AddItem( new GUIContent( newClass ), m_enumClassName.Equals( newClass ), OnSelection, newClass ); - } - - private void OnSelection( object newClass ) - { - m_enumClassName = (string)newClass; - } - - protected void DrawCustomAttrAddRemoveButtons() - { - // Add new port - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - m_customAttr.Add( "" ); - m_customAttrCount++; - //m_enumCount++; - m_visibleCustomAttrFoldout = true; - } - - //Remove port - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - if( m_customAttr.Count - 1 > -1 ) - { - m_customAttr.RemoveAt( m_customAttr.Count - 1 ); - m_customAttrCount--; - } - } - } - - protected void DrawCustomAttributes() - { - for( int i = 0; i < m_customAttrCount; i++ ) - { - EditorGUI.BeginChangeCheck(); - m_customAttr[ i ] = EditorGUILayoutTextField( "Attribute " + i, m_customAttr[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_customAttr[ i ] = UIUtils.RemoveInvalidAttrCharacters( m_customAttr[ i ] ); - } - } - - if( m_customAttrCount <= 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add more.", MessageType.Info ); - return; - } - - EditorGUILayout.BeginHorizontal(); - GUILayout.Label( " " ); - DrawCustomAttrAddRemoveButtons(); - EditorGUILayout.EndHorizontal(); - } - - public virtual void DrawAttributes() - { - int attribCount = m_selectedAttribs.Count; - EditorGUI.BeginChangeCheck(); - if( m_availableAttribsArr == null ) - { - InitializeAttribsArray(); - } - for( int i = 0; i < m_availableAttribsArr.Length; i++ ) - { - m_selectedAttribsArr[ i ] = EditorGUILayoutToggleLeft( m_availableAttribsArr[ i ], m_selectedAttribsArr[ i ] ); - } - if( EditorGUI.EndChangeCheck() ) - { - m_selectedAttribs.Clear(); - for( int i = 0; i < m_selectedAttribsArr.Length; i++ ) - { - if( m_selectedAttribsArr[ i ] ) - m_selectedAttribs.Add( i ); - } - - OnAtrributesChanged(); - } - - bool customAttr = EditorGUILayoutToggleLeft( "Custom", m_customAttrCount == 0 ? false : true ); - if( !customAttr ) - { - m_customAttrCount = 0; - } - else if( customAttr && m_customAttrCount < 1 ) - { - if( m_customAttr.Count == 0 ) - m_customAttr.Add( "" ); - - m_customAttrCount = m_customAttr.Count; - } - //m_customAttrCount = EditorGUILayoutToggleLeft( "Custom Attribute", m_customAttrCount == 0 ? false : true ) == 0 ? false : true; - - //if( attribCount == 0 ) - //{ - // EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add more.", MessageType.Info ); - //} - - //bool actionAllowed = true; - //int deleteItem = -1; - - //for ( int i = 0; i < attribCount; i++ ) - //{ - // EditorGUI.BeginChangeCheck(); - // { - // m_selectedAttribs[ i ] = EditorGUILayoutPopup( m_selectedAttribs[ i ], m_availableAttribsArr ); - // } - // if ( EditorGUI.EndChangeCheck() ) - // { - // OnAtrributesChanged(); - // } - - // EditorGUILayout.BeginHorizontal(); - // GUILayout.Label( " " ); - // // Add After - // if ( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - // { - // if ( actionAllowed ) - // { - // m_selectedAttribs.Insert( i, m_selectedAttribs[ i ] ); - // actionAllowed = false; - // OnAtrributesChanged(); - // } - // } - - // // Remove Current - // if ( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - // { - // if ( actionAllowed ) - // { - // actionAllowed = false; - // deleteItem = i; - // } - // } - // EditorGUILayout.EndHorizontal(); - //} - //if ( deleteItem > -1 ) - //{ - // m_selectedAttribs.RemoveAt( deleteItem ); - // OnAtrributesChanged(); - //} - } - public virtual void DrawMainPropertyBlock() - { - EditorGUILayout.BeginVertical(); - { - if( m_freeType ) - { - PropertyType parameterType = (PropertyType)EditorGUILayoutEnumPopup( ParameterTypeStr, m_currentParameterType ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - BeginPropertyFromInspectorCheck(); - } - } - - if( m_freeName ) - { - switch( m_currentParameterType ) - { - case PropertyType.Property: - case PropertyType.InstancedProperty: - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( true ); - ShowVariableMode(); - ShowHybridInstanced(); - ShowAutoRegister(); - ShowPrecision(); - ShowToolbar(); - } - break; - case PropertyType.Global: - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( false ); - ShowVariableMode(); - ShowAutoRegister(); - ShowPrecision(); - ShowDefaults(); - } - break; - case PropertyType.Constant: - { - ShowPropertyInspectorNameGUI(); - ShowPrecision(); - ShowDefaults(); - } - break; - } - } - } - EditorGUILayout.EndVertical(); - } - - public void DrawMainPropertyBlockNoPrecision() - { - EditorGUILayout.BeginVertical(); - { - if( m_freeType ) - { - PropertyType parameterType = (PropertyType)EditorGUILayoutEnumPopup( ParameterTypeStr, m_currentParameterType ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - BeginPropertyFromInspectorCheck(); - } - } - - if( m_freeName ) - { - switch( m_currentParameterType ) - { - case PropertyType.Property: - case PropertyType.InstancedProperty: - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( true ); - ShowToolbar(); - } - break; - case PropertyType.Global: - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( false ); - ShowDefaults(); - } - break; - case PropertyType.Constant: - { - ShowPropertyInspectorNameGUI(); - ShowDefaults(); - } - break; - } - } - } - EditorGUILayout.EndVertical(); - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( m_freeType || m_freeName ) - { - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawMainPropertyBlock ); - if( m_drawAttributes ) - NodeUtils.DrawPropertyGroup( ref m_visibleAttribsFoldout, Constants.AttributesLaberStr, DrawAttributes ); - - if( m_hasEnum ) - { - if( m_enumModeInt == 0 ) - NodeUtils.DrawPropertyGroup( ref m_visibleEnumsFoldout, EnumsStr, DrawEnums, DrawEnumAddRemoveButtons ); - else - NodeUtils.DrawPropertyGroup( ref m_visibleEnumsFoldout, EnumsStr, DrawEnums ); - } - - if( m_drawAttributes && m_customAttrCount > 0 ) - NodeUtils.DrawPropertyGroup( ref m_visibleCustomAttrFoldout, CustomAttrStr, DrawCustomAttributes, DrawCustomAttrAddRemoveButtons ); - - CheckPropertyFromInspector(); - } - } - - public void ShowPrecision() - { - if( m_drawPrecisionUI ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType == PropertyType.Constant || m_variableMode == VariableMode.Create; - EditorGUI.BeginChangeCheck(); - DrawPrecisionProperty(); - if( EditorGUI.EndChangeCheck() ) - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - GUI.enabled = guiEnabled; - - } - } - - public void ShowToolbar() - { - //if ( !CanDrawMaterial ) - //{ - // ShowDefaults(); - // return; - //} - - EditorGUILayout.BeginHorizontal(); - GUILayout.Space( 20 ); - m_propertyTab = GUILayout.Toolbar( m_propertyTab, LabelToolbarTitle ); - EditorGUILayout.EndHorizontal(); - switch( m_propertyTab ) - { - default: - case 0: - { - EditorGUI.BeginChangeCheck(); - DrawMaterialProperties(); - if( EditorGUI.EndChangeCheck() ) - { - BeginDelayedDirtyProperty(); - } - } - break; - case 1: - { - ShowDefaults(); - } - break; - } - } - - public void ShowDefaults() - { - EditorGUI.BeginChangeCheck(); - DrawSubProperties(); - if( EditorGUI.EndChangeCheck() ) - { - BeginDelayedDirtyProperty(); - } - if( m_currentParameterType == PropertyType.Global && m_globalDefaultBehavior ) - { - if( DebugConsoleWindow.DeveloperMode ) - { - ShowGlobalValueButton(); - } - EditorGUILayout.HelpBox( GlobalTypeWarningText, MessageType.Warning ); - } - } - - public void ShowPropertyInspectorNameGUI() - { - EditorGUI.BeginChangeCheck(); - m_propertyInspectorName = EditorGUILayoutTextField( PropertyInspectorStr, m_propertyInspectorName ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_propertyInspectorName.Length > 0 ) - { - BeginPropertyFromInspectorCheck(); - } - } - } - - public void ShowPropertyNameGUI( bool isProperty ) - { - bool guiEnabledBuffer = GUI.enabled; - if( isProperty ) - { - EditorGUILayout.BeginHorizontal(); - GUI.enabled = !m_autoGlobalName; - EditorGUI.BeginChangeCheck(); - m_propertyName = EditorGUILayoutTextField( PropertyNameStr, m_propertyName ); - if( EditorGUI.EndChangeCheck() ) - { - //BeginPropertyFromInspectorCheck(); - m_checkDuplicateProperty = true; - m_checkDuplicatePropertyTimestamp = EditorApplication.timeSinceStartup; - } - GUI.enabled = guiEnabledBuffer; - EditorGUI.BeginChangeCheck(); - m_autoGlobalName = GUILayout.Toggle( m_autoGlobalName, ( m_autoGlobalName ? UIUtils.LockIconOpen : UIUtils.LockIconClosed ), "minibutton", GUILayout.Width( 22 ) ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_autoGlobalName ) - BeginPropertyFromInspectorCheck(); - } - EditorGUILayout.EndHorizontal(); - } - else - { - GUI.enabled = false; - m_propertyName = EditorGUILayoutTextField( PropertyNameStr, m_propertyName ); - GUI.enabled = guiEnabledBuffer; - } - } - - public void ShowVariableMode() - { - if( m_showVariableMode || m_freeType ) - CurrentVariableMode = (VariableMode)EditorGUILayoutEnumPopup( IgnoreVarDeclarationStr, m_variableMode ); - } - - public void ShowHybridInstanced() - { - if( m_showHybridInstancedUI && CurrentParameterType == PropertyType.Property && (m_containerGraph.IsSRP || m_containerGraph.CurrentShaderFunction != null) ) - { - m_hybridInstanced = EditorGUILayoutToggle( HybridInstancedStr, m_hybridInstanced ); - } - } - - public void ShowAutoRegister() - { - if( m_showAutoRegisterUI && CurrentParameterType != PropertyType.Constant ) - { - m_autoRegister = EditorGUILayoutToggle( AutoRegisterStr, m_autoRegister ); - } - } - - public virtual string GetPropertyValStr() { return string.Empty; } - - public override bool OnClick( Vector2 currentMousePos2D ) - { - bool singleClick = base.OnClick( currentMousePos2D ); - m_propertyTab = m_materialMode ? 0 : 1; - return singleClick; - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( currentMousePos2D.y - m_globalPosition.y > ( Constants.NODE_HEADER_HEIGHT + Constants.NODE_HEADER_EXTRA_HEIGHT ) * ContainerGraph.ParentWindow.CameraDrawInfo.InvertedZoom ) - { - ContainerGraph.ParentWindow.ParametersWindow.IsMaximized = !ContainerGraph.ParentWindow.ParametersWindow.IsMaximized; - } - } - - public override void DrawTitle( Rect titlePos ) - { - //base.DrawTitle( titlePos ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - // Custom Editable Title - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( !m_isEditing && ( ( !ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains( drawInfo.MousePosition ) ) ) ) - { - if( ( EditorApplication.timeSinceStartup - m_clickTime ) < m_doubleClickTime ) - m_startEditing = true; - else - GUI.FocusControl( null ); - m_clickTime = EditorApplication.timeSinceStartup; - } - else if( m_isEditing && ( ( drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains( drawInfo.MousePosition ) ) || !EditorGUIUtility.editingTextField ) ) - { - m_stopEditing = true; - } - - if( m_isEditing || m_startEditing ) - { - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_uniqueName ); - m_propertyInspectorName = EditorGUITextField( m_titleClickArea, string.Empty, m_propertyInspectorName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - if( EditorGUI.EndChangeCheck() ) - { - SetClippedTitle( m_propertyInspectorName, m_longNameSize ); - m_sizeIsDirty = true; - m_isDirty = true; - if( m_propertyInspectorName.Length > 0 ) - { - BeginPropertyFromInspectorCheck(); - } - } - - if( m_startEditing ) - EditorGUI.FocusTextInControl( m_uniqueName ); - //if( m_stopEditing ) - // GUI.FocusControl( null ); - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( m_startEditing ) - { - m_startEditing = false; - m_isEditing = true; - } - - if( m_stopEditing ) - { - m_stopEditing = false; - m_isEditing = false; - GUI.FocusControl( null ); - } - } - - - if( m_freeType ) - { - if( m_dropdownEditing ) - { - PropertyType parameterType = (PropertyType)EditorGUIEnumPopup( m_dropdownRect, m_currentParameterType, UIUtils.PropertyPopUp ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - BeginPropertyFromInspectorCheck(); - DropdownEditing = false; - } - } - } - } - - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - //base.OnNodeLayout( drawInfo ); - if( m_reRegisterName ) - { - m_reRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, m_propertyName ); - } - - CheckDelayedDirtyProperty(); - - if( m_currentParameterType != m_lastParameterType || m_propertyNameIsDirty ) - { - m_lastParameterType = m_currentParameterType; - m_propertyNameIsDirty = false; - OnDirtyProperty(); - if( m_currentParameterType != PropertyType.Constant ) - { - SetClippedTitle( m_propertyInspectorName, m_longNameSize ); - //bool globalHandler = false; - //if( globalHandler ) - //{ - string currValue = ( m_currentParameterType == PropertyType.Global && m_globalDefaultBehavior ) ? "<GLOBAL>" : GetPropertyValStr(); - SetClippedAdditionalTitle( string.Format( m_useVarSubtitle ? Constants.SubTitleVarNameFormatStr : Constants.SubTitleValueFormatStr, currValue ), m_longNameSize, LongNameEnder ); - //} - //else - //{ - // if( m_currentParameterType == PropertyType.Global ) - // { - // SetAdditonalTitleText( "Global" ); - // } - // else - // { - // SetAdditonalTitleText( string.Format( m_useVarSubtitle ? Constants.SubTitleVarNameFormatStr : Constants.SubTitleValueFormatStr, GetPropertyValStr() ) ); - // } - //} - } - else - { - SetClippedTitle( m_propertyInspectorName, m_longNameSize ); - SetClippedAdditionalTitle( string.Format( Constants.SubTitleConstFormatStr, GetPropertyValStr() ), m_longNameSize, LongNameEnder ); - } - } - - CheckPropertyFromInspector(); - CheckDuplicateProperty(); - // RUN LAYOUT CHANGES AFTER TITLES CHANGE - base.OnNodeLayout( drawInfo ); - - m_titleClickArea = m_titlePos; - m_titleClickArea.height = Constants.NODE_HEADER_HEIGHT; - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - // Fixed Title ( only renders when not editing ) - if( m_showTitleWhenNotEditing && !m_isEditing && !m_startEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( m_titleClickArea, m_content, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public void RegisterFirstAvailablePropertyName( bool releaseOldOne, bool appendIndexToCurrOne = false ) - { - if( releaseOldOne ) - UIUtils.ReleaseUniformName( UniqueId, m_oldName ); - - if( m_isNodeBeingCopied || appendIndexToCurrOne ) - { - if( string.IsNullOrEmpty( m_propertyName ) ) - return; - - string newPropertyName = UIUtils.GetUniqueUniformName( m_propertyName ); - if( newPropertyName != m_propertyName ) - { - UIUtils.RegisterUniformName( UniqueId, newPropertyName ); - m_propertyName = newPropertyName; - } - else - { - if( UIUtils.IsUniformNameAvailable( m_propertyName ) ) - UIUtils.RegisterUniformName( UniqueId, m_propertyName ); - else - UIUtils.GetFirstAvailableName( UniqueId, m_outputPorts[ 0 ].DataType, out m_propertyName, out m_propertyInspectorName, !string.IsNullOrEmpty( m_customPrefix ), m_customPrefix ); - } - - } - else - { - UIUtils.GetFirstAvailableName( UniqueId, m_outputPorts[ 0 ].DataType, out m_propertyName, out m_propertyInspectorName, !string.IsNullOrEmpty( m_customPrefix ), m_customPrefix ); - } - m_oldName = m_propertyName; - m_propertyNameIsDirty = true; - m_reRegisterName = false; - OnPropertyNameChanged(); - } - - public void SetRawPropertyName( string name ) - { - m_propertyName = name; - } - - public void RegisterPropertyName( bool releaseOldOne, string newName, bool autoGlobal = true, bool forceUnderscore = false ) - { - if( m_currentParameterType != PropertyType.Constant && m_variableMode == VariableMode.Fetch ) - { - string localPropertyName = string.Empty; - if( autoGlobal ) - localPropertyName = UIUtils.GeneratePropertyName( newName, m_currentParameterType, forceUnderscore ); - else - { - localPropertyName = UIUtils.GeneratePropertyName( m_propertyName, PropertyType.Global, forceUnderscore ); - if( UIUtils.IsNumericName( localPropertyName ) ) - { - m_propertyName = m_oldName; - } - - } - - m_propertyName = localPropertyName; - m_propertyInspectorName = newName; - m_propertyNameIsDirty = true; - m_reRegisterName = false; - OnPropertyNameChanged(); - return; - } - - string propertyName = string.Empty; - if( autoGlobal ) - propertyName = UIUtils.GeneratePropertyName( newName, m_currentParameterType, forceUnderscore ); - else - { - propertyName = UIUtils.GeneratePropertyName( m_propertyName, PropertyType.Global, forceUnderscore ); - if( UIUtils.IsNumericName( propertyName ) ) - { - m_propertyName = m_oldName; - } - } - - if( m_propertyName.Equals( propertyName ) ) - return; - - if( UIUtils.IsUniformNameAvailable( propertyName ) || m_allowPropertyDuplicates ) - { - if( releaseOldOne ) - UIUtils.ReleaseUniformName( UniqueId, m_oldName ); - - m_oldName = propertyName; - m_propertyName = propertyName; - if( autoGlobal ) - m_propertyInspectorName = newName; - m_propertyNameIsDirty = true; - m_reRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, propertyName ); - OnPropertyNameChanged(); - } - else - { - GUI.FocusControl( string.Empty ); - RegisterFirstAvailablePropertyName( releaseOldOne ); - UIUtils.ShowMessage( UniqueId, string.Format( "Duplicate name found on edited node.\nAssigning first valid one {0}", m_propertyInspectorName ) ); - } - } - - protected string CreateLocalVarDec( string value ) - { - return string.Format( Constants.PropertyLocalVarDec, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), m_propertyName, value ); - } - - public virtual void CheckIfAutoRegister( ref MasterNodeDataCollector dataCollector ) - { - if( CurrentParameterType != PropertyType.Constant && m_autoRegister && m_connStatus != NodeConnectionStatus.Connected ) - { - RegisterProperty( ref dataCollector ); - } - } - - virtual protected void RegisterProperty( ref MasterNodeDataCollector dataCollector ) - { - CheckPropertyFromInspector( true ); - if( m_propertyName.Length == 0 ) - { - RegisterFirstAvailablePropertyName( false ); - } - - switch( CurrentParameterType ) - { - case PropertyType.Property: - { - //Debug.Log( this.GetInstanceID()+" "+ OrderIndex+" "+GetPropertyValue() ); - dataCollector.AddToProperties( UniqueId, GetPropertyValue(), OrderIndex ); - string dataType = string.Empty; - string dataName = string.Empty; - bool fullValue = false; - if( m_variableMode == VariableMode.Create && GetUniformData( out dataType, out dataName, ref fullValue ) ) - { - if( fullValue ) - { - dataCollector.AddToUniforms( UniqueId, dataName, m_srpBatcherCompatible ); - } - else - { - dataCollector.AddToUniforms( UniqueId, dataType, dataName, m_srpBatcherCompatible, m_excludeUniform ); - } - } - - if( m_hybridInstanced && dataCollector.IsTemplate && dataCollector.IsSRP ) - { - dataCollector.AddToDotsProperties( m_outputPorts[ 0 ].DataType, UniqueId, m_propertyName, OrderIndex, CurrentPrecisionType ); - } - //dataCollector.AddToUniforms( m_uniqueId, GetUniformValue() ); - } - break; - case PropertyType.InstancedProperty: - { - dataCollector.AddToPragmas( UniqueId, IOUtils.InstancedPropertiesHeader ); - - if( m_registerPropertyOnInstancing ) - dataCollector.AddToProperties( UniqueId, GetPropertyValue(), OrderIndex ); - - dataCollector.AddToInstancedProperties( m_outputPorts[ 0 ].DataType, UniqueId, GetInstancedUniformValue( dataCollector.IsTemplate, dataCollector.IsSRP ), OrderIndex ); - } - break; - case PropertyType.Global: - { - string dataType = string.Empty; - string dataName = string.Empty; - bool fullValue = false; - if( m_variableMode == VariableMode.Create && GetUniformData( out dataType, out dataName, ref fullValue ) ) - { - if( fullValue ) - { - dataCollector.AddToUniforms( UniqueId, dataName, m_addGlobalToSRPBatcher ); - } - else - { - dataCollector.AddToUniforms( UniqueId, dataType, dataName, m_addGlobalToSRPBatcher, m_excludeUniform ); - } - } - //dataCollector.AddToUniforms( m_uniqueId, GetUniformValue() ); - } - break; - case PropertyType.Constant: break; - } - dataCollector.AddPropertyNode( this ); - if( m_currentParameterType == PropertyType.InstancedProperty && !m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - { - string instancedVar = dataCollector.IsSRP ? - //m_propertyName : - string.Format( IOUtils.LWSRPInstancedPropertiesData, dataCollector.InstanceBlockName, m_propertyName ) : - string.Format( IOUtils.InstancedPropertiesData, m_propertyName ); - - bool insideSF = InsideShaderFunction; - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - if( insideSF ) - ContainerGraph.ParentWindow.CustomGraph = this.ContainerGraph; - - RegisterLocalVariable( 0, instancedVar, ref dataCollector, m_propertyName + "_Instance" ); - - if( insideSF ) - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - RegisterProperty( ref dataCollector ); - return string.Empty; - } - - public override void Destroy() - { - base.Destroy(); - UIUtils.UnregisterRawPropertyNode( this ); - if( !string.IsNullOrEmpty( m_propertyName ) && UniqueId >= 0 ) - UIUtils.ReleaseUniformName( UniqueId, m_propertyName ); - - if( m_currentParameterType == PropertyType.InstancedProperty ) - { - UIUtils.CurrentWindow.OutsideGraph.RemoveInstancePropertyCount(); - UIUtils.UnregisterPropertyNode( this ); - } - - if( m_currentParameterType == PropertyType.Property ) - { - UIUtils.UnregisterPropertyNode( this ); - } - - if( m_availableAttribs != null ) - m_availableAttribs.Clear(); - - m_availableAttribs = null; - } - - string BuildEnum() - { - string result = "[Enum("; - if( m_enumModeInt == 0 ) - { - for( int i = 0; i < m_enumNames.Count; i++ ) - { - result += m_enumNames[ i ] + "," + m_enumValues[ i ]; - if( i + 1 < m_enumNames.Count ) - result += ","; - } - } - else - { - result += m_enumClassName; - } - result += ")]"; - return result; - } - - public string PropertyAttributes - { - get - { - int attribCount = m_selectedAttribs.Count; - - if( m_selectedAttribs.Count == 0 && m_customAttrCount == 0 ) - return string.Empty; - - string attribs = string.Empty; - for( int i = 0; i < attribCount; i++ ) - { - if( m_availableAttribs[ m_selectedAttribs[ i ] ].Name.Equals( "Enum" ) ) - attribs += BuildEnum(); - else - attribs += m_availableAttribs[ m_selectedAttribs[ i ] ].Attribute; - } - - for( int i = 0; i < m_customAttrCount; i++ ) - { - if( !string.IsNullOrEmpty( m_customAttr[ i ] ) ) - attribs += "[" + m_customAttr[ i ] + "]"; - } - return attribs; - } - } - public virtual void OnDirtyProperty() { } - public virtual void OnPropertyNameChanged() { UIUtils.UpdatePropertyDataNode( UniqueId, PropertyInspectorName ); } - public virtual void DrawSubProperties() { } - public virtual void DrawMaterialProperties() { } - - public virtual string GetPropertyValue() { return string.Empty; } - - public string GetInstancedUniformValue( bool isTemplate, bool isSRP ) - { - if( isTemplate ) - { - if( isSRP ) - { - return string.Format( IOUtils.LWSRPInstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), m_propertyName ); - //return GetUniformValue(); - } - else - { - return string.Format( IOUtils.InstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), m_propertyName ); - } - } - else - return string.Format( IOUtils.InstancedPropertiesElementTabs, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), m_propertyName ); - } - - public string GetInstancedUniformValue( bool isTemplate, bool isSRP, WirePortDataType dataType, string value ) - { - if( isTemplate ) - { - if( isSRP ) - { - //return GetUniformValue( dataType, value ); - return string.Format( IOUtils.LWSRPInstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, dataType ), value ); - } - else - { - return string.Format( IOUtils.InstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, dataType ), value ); - } - } - else - return string.Format( IOUtils.InstancedPropertiesElementTabs, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, dataType ), value ); - } - - public virtual string GetUniformValue() - { - bool excludeUniformKeyword = ( m_currentParameterType == PropertyType.InstancedProperty ) || - m_containerGraph.IsSRP; - int index = excludeUniformKeyword ? 1 : 0; - return string.Format( Constants.UniformDec[ index ], UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), m_propertyName ); - } - - public string GetUniformValue( WirePortDataType dataType, string value ) - { - bool excludeUniformKeyword = ( m_currentParameterType == PropertyType.InstancedProperty ) || - m_containerGraph.IsSRP; - int index = excludeUniformKeyword ? 1 : 0; - return string.Format( Constants.UniformDec[ index ], UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, dataType ), value ); - } - - public virtual bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - dataName = m_propertyName; - fullValue = false; - return true; - } - - public PropertyType CurrentParameterType - { - get { return m_currentParameterType; } - set { m_currentParameterType = value; } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentParameterType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_propertyName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_propertyInspectorName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_orderIndex ); - int attribCount = m_selectedAttribs.Count; - IOUtils.AddFieldValueToString( ref nodeInfo, attribCount ); - if( attribCount > 0 ) - { - for( int i = 0; i < attribCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_availableAttribs[ m_selectedAttribs[ i ] ].Attribute ); - } - } - IOUtils.AddFieldValueToString( ref nodeInfo, m_variableMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoGlobalName ); - - - IOUtils.AddFieldValueToString( ref nodeInfo, m_enumCount ); - for( int i = 0; i < m_enumCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_enumNames[ i ] ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_enumValues[ i ] ); - } - IOUtils.AddFieldValueToString( ref nodeInfo, m_enumModeInt ); - if( m_enumModeInt == 1 ) - IOUtils.AddFieldValueToString( ref nodeInfo, m_enumClassName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoRegister ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_customAttrCount ); - if( m_customAttrCount > 0 ) - { - for( int i = 0; i < m_customAttrCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_customAttr[ i ] ); - } - } - - IOUtils.AddFieldValueToString( ref nodeInfo, m_hybridInstanced ); - } - - int IdForAttrib( string name ) - { - int attribCount = m_availableAttribs.Count; - for( int i = 0; i < attribCount; i++ ) - { - if( m_availableAttribs[ i ].Attribute.Equals( name ) ) - return i; - } - return 0; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 2505 ) - { - string property = GetCurrentParam( ref nodeParams ); - m_currentParameterType = property.Equals( "Uniform" ) ? PropertyType.Global : (PropertyType)Enum.Parse( typeof( PropertyType ), property ); - } - else - { - m_currentParameterType = (PropertyType)Enum.Parse( typeof( PropertyType ), GetCurrentParam( ref nodeParams ) ); - } - - if( m_currentParameterType == PropertyType.InstancedProperty ) - { - UIUtils.CurrentWindow.OutsideGraph.AddInstancePropertyCount(); - UIUtils.RegisterPropertyNode( this ); - } - - if( m_currentParameterType == PropertyType.Property ) - { - UIUtils.RegisterPropertyNode( this ); - } - - m_propertyName = GetCurrentParam( ref nodeParams ); - m_propertyInspectorName = GetCurrentParam( ref nodeParams ); - - if( UIUtils.CurrentShaderVersion() > 13 ) - { - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 4102 ) - { - int attribAmount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( attribAmount > 0 ) - { - for( int i = 0; i < attribAmount; i++ ) - { - m_selectedAttribs.Add( IdForAttrib( GetCurrentParam( ref nodeParams ) ) ); - } - - m_visibleAttribsFoldout = true; - } - InitializeAttribsArray(); - } - - - if( UIUtils.CurrentShaderVersion() > 14003 ) - { - m_variableMode = (VariableMode)Enum.Parse( typeof( VariableMode ), GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 14201 ) - { - m_autoGlobalName = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 14403 ) - { - m_enumCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - for( int i = 0; i < m_enumCount; i++ ) - { - m_enumNames.Add( GetCurrentParam( ref nodeParams ) ); - m_enumValues.Add( Convert.ToInt32( GetCurrentParam( ref nodeParams ) ) ); - } - } - - if( UIUtils.CurrentShaderVersion() > 14501 ) - { - m_enumModeInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( m_enumModeInt == 1 ) - m_enumClassName = GetCurrentParam( ref nodeParams ); - m_autoRegister = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - m_customAttrCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - for( int i = 0; i < m_customAttrCount; i++ ) - { - m_customAttr.Add( GetCurrentParam( ref nodeParams ) ); - } - if( m_customAttrCount > 0 ) - { - m_visibleCustomAttrFoldout = true; - m_visibleAttribsFoldout = true; - } - } - - if( UIUtils.CurrentShaderVersion() > 18003 ) - { - m_hybridInstanced = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - CheckEnumAttribute(); - if( m_enumCount > 0 ) - m_visibleEnumsFoldout = true; - - m_propertyNameIsDirty = true; - m_reRegisterName = false; - - if( !m_isNodeBeingCopied ) - { - if( m_variableMode != VariableMode.Fetch || m_currentParameterType == PropertyType.Constant ) - { - UIUtils.ReleaseUniformName( UniqueId, m_oldName ); - UIUtils.RegisterUniformName( UniqueId, m_propertyName ); - m_oldName = m_propertyName; - } - } - else - { - m_oldName = m_propertyName; - } - - } - - void UpdateTooltip() - { - string currValue = string.Empty; - if( m_currentParameterType != PropertyType.Constant ) - { - currValue = ( m_currentParameterType == PropertyType.Global && m_globalDefaultBehavior ) ? "<GLOBAL>" : GetPropertyValStr(); - } - else - { - currValue = GetPropertyValStr(); - } - - m_tooltipText = string.Format( TooltipFormatter, m_nodeAttribs.Description, m_propertyInspectorName, currValue ); - } - - public override void SetClippedTitle( string newText, int maxSize = 170, string endString = "..." ) - { - base.SetClippedTitle( newText, maxSize, endString ); - UpdateTooltip(); - } - - public override void SetClippedAdditionalTitle( string newText, int maxSize = 170, string endString = "..." ) - { - base.SetClippedAdditionalTitle( newText, maxSize, endString ); - UpdateTooltip(); - } - - public override void OnEnable() - { - base.OnEnable(); - m_reRegisterName = true; - } - - public bool CanDrawMaterial { get { return m_materialMode && m_currentParameterType != PropertyType.Constant; } } - public int RawOrderIndex - { - get { return m_orderIndex; } - } - - public int OrderIndex - { - get { return m_orderIndex + m_orderIndexOffset; } - set { m_orderIndex = value; } - } - - public int OrderIndexOffset - { - get { return m_orderIndexOffset; } - set { m_orderIndexOffset = value; } - } - - public VariableMode CurrentVariableMode - { - get { return m_variableMode; } - set - { - if( value != m_variableMode ) - { - m_variableMode = value; - if( value == VariableMode.Fetch ) - { - m_oldName = m_propertyName; - } - else - { - if( !m_propertyName.Equals( m_oldName ) ) - { - if( UIUtils.IsUniformNameAvailable( m_propertyName ) ) - { - UIUtils.ReleaseUniformName( UniqueId, m_oldName ); - UIUtils.RegisterUniformName( UniqueId, m_propertyName ); - } - else - { - UIUtils.ShowMessage( UniqueId, string.Format( FetchToCreateDuplicatesMsg, m_propertyName, m_oldName ), MessageSeverity.Warning ); - m_propertyName = m_oldName; - } - m_propertyNameIsDirty = true; - OnPropertyNameChanged(); - } - else if( UIUtils.CheckUniformNameOwner( m_propertyName ) != UniqueId ) - { - string oldProperty = m_propertyName; - RegisterFirstAvailablePropertyName( false ); - UIUtils.ShowMessage( UniqueId, string.Format( FetchToCreateOnDuplicateNodeMsg, m_propertyName, oldProperty ), MessageSeverity.Warning ); - } - } - } - } - } - - public string PropertyData( MasterNodePortCategory portCategory ) - { - return ( m_currentParameterType == PropertyType.InstancedProperty ) ? m_outputPorts[ 0 ].LocalValue( portCategory ) : m_propertyName; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - if( m_currentParameterType == PropertyType.Global && m_globalDefaultBehavior && ( EditorApplication.timeSinceStartup - m_globalFetchTimestamp ) > MaxGlobalFetchTimestamp ) - { - FetchGlobalValue(); - m_globalFetchTimestamp = EditorApplication.timeSinceStartup; - } - } - - public void ShowGlobalValueButton() - { - if( GUILayout.Button( "Set Global Value" ) ) - { - SetGlobalValue(); - } - } - - public override bool CheckFindText( string text ) - { - return base.CheckFindText( text ) || - m_propertyName.IndexOf( text, StringComparison.CurrentCultureIgnoreCase ) >= 0 || - m_propertyInspectorName.IndexOf( text, StringComparison.CurrentCultureIgnoreCase ) >= 0; - } - - //This should only be used on template internal properties - public void PropertyNameFromTemplate( TemplateShaderPropertyData data ) - { - m_propertyName = data.PropertyName; - m_propertyInspectorName = data.PropertyInspectorName; - } - public virtual void GeneratePPSInfo( ref string propertyDeclaration, ref string propertySet ) { } - public virtual void SetGlobalValue() { } - public virtual void FetchGlobalValue() { } - - public virtual string PropertyName { get { return m_propertyName; } } - public virtual string PropertyInspectorName { get { return m_propertyInspectorName; } } - public bool FreeType { get { return m_freeType; } set { m_freeType = value; } } - public bool ReRegisterName { get { return m_reRegisterName; } set { m_reRegisterName = value; } } - public string CustomPrefix { get { return m_customPrefix; } set { m_customPrefix = value; } } - public override void RefreshOnUndo() - { - base.RefreshOnUndo(); - BeginPropertyFromInspectorCheck(); - } - public override string DataToArray { get { return PropertyInspectorName; } } - public bool RegisterPropertyOnInstancing { get { return m_registerPropertyOnInstancing; } set { m_registerPropertyOnInstancing = value; } } - public bool SrpBatcherCompatible { get { return m_srpBatcherCompatible; } } - public bool AddGlobalToSRPBatcher { get { return m_addGlobalToSRPBatcher; } set { m_addGlobalToSRPBatcher = value; } } - public bool AutoRegister { get { return m_autoRegister; } set { m_autoRegister = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs.meta deleted file mode 100644 index 704a2440..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PropertyNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5bbfd66571b12f84983b398231271694 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs deleted file mode 100644 index 5c070e2b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs +++ /dev/null @@ -1,530 +0,0 @@ -// 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( "Float", "Constants And Properties", "Float property", null, KeyCode.Alpha1 )] - public sealed class RangedFloatNode : PropertyNode - { - private const int OriginalFontSize = 11; - - private const string MinValueStr = "Min"; - private const string MaxValueStr = "Max"; - - private const float LabelWidth = 8; - - [SerializeField] - private float m_defaultValue = 0; - - [SerializeField] - private float m_materialValue = 0; - - [SerializeField] - private float m_min = 0; - - [SerializeField] - private float m_max = 0; - - [SerializeField] - private bool m_floatMode = true; - - private int m_cachedPropertyId = -1; - - private bool m_isEditingFields; - private Vector3 m_previousValue = Vector3.zero; - private string[] m_fieldText = new string[] { "0", "0", "0" }; - - public RangedFloatNode() : base() { } - public RangedFloatNode( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Float" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_insideSize.Set( 50, 0 ); - m_showPreview = false; - m_showHybridInstancedUI = true; - m_selectedLocation = PreviewLocation.BottomCenter; - m_availableAttribs.Add( new PropertyAttributes( "Toggle", "[Toggle]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Int Range", "[IntRange]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Enum", "[Enum]" ) ); - m_previewShaderGUID = "d9ca47581ac157145bff6f72ac5dd73e"; - m_srpBatcherCompatible = true; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterFloatIntNode( this ); - } - - public override void Destroy() - { - base.Destroy(); - UIUtils.UnregisterFloatIntNode( this ); - } - - public override void OnDirtyProperty() - { - UIUtils.UpdateFloatIntDataNode( UniqueId, PropertyInspectorName ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - OnPropertyNameChanged(); - OnDirtyProperty(); - } - - public void SetFloatMode( bool value ) - { - if ( m_floatMode == value ) - return; - - m_floatMode = value; - if ( value ) - { - m_insideSize.x = 50;// + ( m_showPreview ? 50 : 0 ); - //m_firstPreviewDraw = true; - } - else - { - m_insideSize.x = 200;// + ( m_showPreview ? 0 : 0 ); - //m_firstPreviewDraw = true; - } - m_sizeIsDirty = true; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - void DrawMinMaxUI() - { - EditorGUI.BeginChangeCheck(); - m_min = EditorGUILayoutFloatField( MinValueStr, m_min ); - m_max = EditorGUILayoutFloatField( MaxValueStr, m_max ); - if ( m_min > m_max ) - m_min = m_max; - - if ( m_max < m_min ) - m_max = m_min; - - if ( EditorGUI.EndChangeCheck() ) - { - SetFloatMode( m_min == m_max ); - } - } - public override void DrawSubProperties() - { - DrawMinMaxUI(); - - if ( m_floatMode ) - { - m_defaultValue = EditorGUILayoutFloatField( Constants.DefaultValueLabel, m_defaultValue ); - } - else - { - m_defaultValue = EditorGUILayoutSlider( Constants.DefaultValueLabel, m_defaultValue, m_min, m_max ); - } - } - - public override void DrawMaterialProperties() - { - DrawMinMaxUI(); - - EditorGUI.BeginChangeCheck(); - - if ( m_floatMode ) - { - m_materialValue = EditorGUILayoutFloatField( Constants.MaterialValueLabel, m_materialValue ); - } - else - { - m_materialValue = EditorGUILayoutSlider( Constants.MaterialValueLabel, m_materialValue, m_min, m_max ); - } - if ( EditorGUI.EndChangeCheck() ) - { - //MarkForPreviewUpdate(); - if ( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputFloat" ); - - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetFloat( m_cachedPropertyId, m_materialValue ); - else - PreviewMaterial.SetFloat( m_cachedPropertyId, m_defaultValue ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - if ( m_floatMode ) - { - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - else - { - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.width = m_outputPorts[ 0 ].Position.x - m_propertyDrawPos.x - (m_outputPorts[ 0 ].LabelSize.x + (Constants.PORT_TO_LABEL_SPACE_X + 3) * drawInfo.InvertedZoom + 2); - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if ( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if ( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - void DrawFakeFloatMaterial( DrawInfo drawInfo ) - { - if( m_floatMode ) - { - //UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom ); - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - if( GUI.enabled ) - { - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - } - if( m_previousValue[ 0 ] != m_materialValue ) - { - m_previousValue[ 0 ] = m_materialValue; - m_fieldText[ 0 ] = m_materialValue.ToString(); - } - - GUI.Label( fakeField, m_fieldText[ 0 ], UIUtils.MainSkin.textField ); - } - else - { - DrawFakeSlider( ref m_materialValue, drawInfo ); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - EditorGUI.BeginChangeCheck(); - if ( m_floatMode ) - { - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom ); - } - else - { - DrawSlider( ref m_materialValue, drawInfo ); - } - if ( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = true; - if ( m_currentParameterType != PropertyType.Constant ) - { - BeginDelayedDirtyProperty(); - } - } - } - else - { - EditorGUI.BeginChangeCheck(); - - if ( m_floatMode ) - { - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom ); - } - else - { - DrawSlider( ref m_defaultValue, drawInfo ); - } - if ( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - BeginDelayedDirtyProperty(); - } - - } - } - else if ( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - if( m_currentParameterType == PropertyType.Global ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = false; - DrawFakeFloatMaterial( drawInfo ); - GUI.enabled = guiEnabled; - } - else if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - DrawFakeFloatMaterial( drawInfo ); - } - else - { - if ( m_floatMode ) - { - //UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom ); - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - - if ( m_previousValue[ 0 ] != m_defaultValue ) - { - m_previousValue[ 0 ] = m_defaultValue; - m_fieldText[ 0 ] = m_defaultValue.ToString(); - } - - GUI.Label( fakeField, m_fieldText[ 0 ], UIUtils.MainSkin.textField ); - } - else - { - DrawFakeSlider( ref m_defaultValue, drawInfo ); - } - } - } - } - - void DrawFakeSlider( ref float value, DrawInfo drawInfo ) - { - float rangeWidth = 30 * drawInfo.InvertedZoom; - float rangeSpacing = 5 * drawInfo.InvertedZoom; - - //Min - Rect minRect = m_propertyDrawPos; - minRect.width = rangeWidth; - EditorGUIUtility.AddCursorRect( minRect, MouseCursor.Text ); - if ( m_previousValue[ 1 ] != m_min ) - { - m_previousValue[ 1 ] = m_min; - m_fieldText[ 1 ] = m_min.ToString(); - } - GUI.Label( minRect, m_fieldText[ 1 ], UIUtils.MainSkin.textField ); - - //Value Area - Rect valRect = m_propertyDrawPos; - valRect.width = rangeWidth; - valRect.x = m_propertyDrawPos.xMax - rangeWidth - rangeWidth - rangeSpacing; - EditorGUIUtility.AddCursorRect( valRect, MouseCursor.Text ); - if ( m_previousValue[ 0 ] != value ) - { - m_previousValue[ 0 ] = value; - m_fieldText[ 0 ] = value.ToString(); - } - GUI.Label( valRect, m_fieldText[ 0 ], UIUtils.MainSkin.textField ); - - //Max - Rect maxRect = m_propertyDrawPos; - maxRect.width = rangeWidth; - maxRect.x = m_propertyDrawPos.xMax - rangeWidth; - EditorGUIUtility.AddCursorRect( maxRect, MouseCursor.Text ); - if ( m_previousValue[ 2 ] != m_max ) - { - m_previousValue[ 2 ] = m_max; - m_fieldText[ 2 ] = m_max.ToString(); - } - GUI.Label( maxRect, m_fieldText[ 2 ], UIUtils.MainSkin.textField ); - - Rect sliderValRect = m_propertyDrawPos; - sliderValRect.x = minRect.xMax + rangeSpacing; - sliderValRect.xMax = valRect.xMin - rangeSpacing; - Rect sliderBackRect = sliderValRect; - sliderBackRect.height = 5 * drawInfo.InvertedZoom; - sliderBackRect.center = new Vector2( sliderValRect.center.x, Mathf.Round( sliderValRect.center.y ) ); - - - GUI.Label( sliderBackRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SliderStyle ) ); - - sliderValRect.width = 10; - float percent = ( value - m_min) / ( m_max-m_min ); - percent = Mathf.Clamp01( percent ); - sliderValRect.x += percent * (sliderBackRect.width - 10 * drawInfo.InvertedZoom ); - GUI.Label( sliderValRect, string.Empty, UIUtils.RangedFloatSliderThumbStyle ); - } - - void DrawSlider( ref float value, DrawInfo drawInfo ) - { - float rangeWidth = 30 * drawInfo.InvertedZoom; - float rangeSpacing = 5 * drawInfo.InvertedZoom; - - //Min - Rect minRect = m_propertyDrawPos; - minRect.width = rangeWidth; - m_min = EditorGUIFloatField( minRect, m_min, UIUtils.MainSkin.textField ); - - //Value Area - Rect valRect = m_propertyDrawPos; - valRect.width = rangeWidth; - valRect.x = m_propertyDrawPos.xMax - rangeWidth - rangeWidth - rangeSpacing; - value = EditorGUIFloatField( valRect, value, UIUtils.MainSkin.textField ); - - //Max - Rect maxRect = m_propertyDrawPos; - maxRect.width = rangeWidth; - maxRect.x = m_propertyDrawPos.xMax - rangeWidth; - m_max = EditorGUIFloatField( maxRect, m_max, UIUtils.MainSkin.textField ); - - //Value Slider - Rect sliderValRect = m_propertyDrawPos; - sliderValRect.x = minRect.xMax + rangeSpacing; - sliderValRect.xMax = valRect.xMin - rangeSpacing; - Rect sliderBackRect = sliderValRect; - sliderBackRect.height = 5 * drawInfo.InvertedZoom; - sliderBackRect.center = new Vector2( sliderValRect.center.x, Mathf.Round( sliderValRect.center.y )); - GUI.Label( sliderBackRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SliderStyle ) ); - value = GUIHorizontalSlider( sliderValRect, value, m_min, m_max, GUIStyle.none, UIUtils.RangedFloatSliderThumbStyle ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if ( m_currentParameterType != PropertyType.Constant ) - return PropertyData( dataCollector.PortCategory ); - - return IOUtils.Floatify( m_defaultValue ); - } - - public override string GetPropertyValue() - { - if ( m_floatMode ) - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + m_defaultValue; - } - else - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Range( " + m_min + " , " + m_max + ")) = " + m_defaultValue; - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetFloat( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat , bool fetchMaterialValues ) - { - base.SetMaterialMode( mat , fetchMaterialValues ); - if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetFloat( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetFloat( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_materialValue = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - } - - m_min = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_max = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - SetFloatMode( m_min == m_max ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_materialValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_min ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_max ); - } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? - m_materialValue.ToString( Mathf.Abs( m_materialValue ) > 1000 ? Constants.PropertyBigFloatFormatLabel : Constants.PropertyFloatFormatLabel ) : - m_defaultValue.ToString( Mathf.Abs( m_defaultValue ) > 1000 ? Constants.PropertyBigFloatFormatLabel : Constants.PropertyFloatFormatLabel ); - } - - public override void SetGlobalValue() { Shader.SetGlobalFloat( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalFloat( m_propertyName ); } - public float Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - - public void SetMaterialValueFromInline( float val ) - { - m_materialValue = val; - m_requireMaterialUpdate = true; - } - public override void GeneratePPSInfo( ref string propertyDeclaration, ref string propertySet ) - { - string additionalHeaders = string.Empty; - if( !m_floatMode ) - { - additionalHeaders = string.Format( "Range( {0}, {1} ),", m_min, m_max ); - } - propertyDeclaration += string.Format( ASEPPSHelperTool.PPSPropertyDecFormat, additionalHeaders, PropertyInspectorName, - ASEPPSHelperTool.WireToPPSType[ WirePortDataType.FLOAT ], PropertyName, m_defaultValue ); - - propertySet += string.Format( ASEPPSHelperTool.PPSPropertySetFormat, "Float", PropertyName ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs.meta deleted file mode 100644 index dbf3243f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/RangedFloatNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e81453c5ad3b8224db874b56bf00cad2 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables.meta deleted file mode 100644 index 22447d40..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 92f993d3ba8b1394eaf8c4fe308cab11 -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta deleted file mode 100644 index e1fbf68d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 8c4b0845954941d4d9809abaa67bdc2b -folderAsset: yes -timeCreated: 1481126947 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs deleted file mode 100644 index 0591ba12..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum BuiltInShaderCameraTypes - { - unity_CameraProjection = 0, - unity_CameraInvProjection - } - - [Serializable] - [NodeAttributes( "Projection Matrices", "Camera And Screen", "Camera's Projection/Inverse Projection matrix" )] - public sealed class CameraProjectionNode : ShaderVariablesNode - { - private const string _projMatrixLabelStr = "Projection Matrix"; - private readonly string[] _projMatrixValuesStr = { "Camera Projection", - "Inverse Camera Projection"}; - - - [SerializeField] - private BuiltInShaderCameraTypes m_selectedType = BuiltInShaderCameraTypes.unity_CameraProjection; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, _projMatrixValuesStr[ (int)m_selectedType ], WirePortDataType.FLOAT4x4 ); - m_textLabelWidth = 115; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - } - - 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_selectedType = (BuiltInShaderCameraTypes)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, _projMatrixValuesStr ); - if( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] ); - SetSaveIsDirty(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_selectedType = (BuiltInShaderCameraTypes)EditorGUILayoutPopup( _projMatrixLabelStr, (int)m_selectedType, _projMatrixValuesStr ); - if( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] ); - SetSaveIsDirty(); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector ); - return m_selectedType.ToString(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedType = (BuiltInShaderCameraTypes)Enum.Parse( typeof( BuiltInShaderCameraTypes ), GetCurrentParam( ref nodeParams ) ); - ChangeOutputName( 0, _projMatrixValuesStr[ (int)m_selectedType ] ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta deleted file mode 100644 index 11a1c16b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraProjectionNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f776bdd36b750304c8e0de8ee1f31fc0 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs deleted file mode 100644 index fd23099e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs +++ /dev/null @@ -1,115 +0,0 @@ -// 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 BuiltInShaderClipPlanesTypes - { - Left = 0, - Right, - Bottom, - Top, - Near, - Far - } - - [Serializable] - [NodeAttributes( "Clip Planes", "Camera And Screen", "Camera World Clip Planes" )] - public sealed class CameraWorldClipPlanes : ShaderVariablesNode - { - [SerializeField] - private BuiltInShaderClipPlanesTypes m_selectedType = BuiltInShaderClipPlanesTypes.Left; - - private const string LabelStr = "Plane"; - private const string ValueStr = "unity_CameraWorldClipPlanes"; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - private int m_planeId; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "ABCD", WirePortDataType.FLOAT4 ); - m_textLabelWidth = 55; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) ); - m_previewShaderGUID = "6afe5a4ad7bbd0e4ab352c758f543a09"; - } - - public override void OnEnable() - { - base.OnEnable(); - m_planeId = Shader.PropertyToID( "_PlaneId" ); - } - - 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 ); - m_upperLeftWidget.DrawWidget<BuiltInShaderClipPlanesTypes>(ref m_selectedType, this, OnWidgetUpdate ); - } - - private readonly Action<ParentNode> OnWidgetUpdate = ( x ) => { - x.SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, ( x as CameraWorldClipPlanes ).Type ) ); - }; - - public BuiltInShaderClipPlanesTypes Type { get { return m_selectedType; } } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_selectedType = ( BuiltInShaderClipPlanesTypes ) EditorGUILayoutEnumPopup( LabelStr, m_selectedType ); - if ( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) ); - SetSaveIsDirty(); - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - PreviewMaterial.SetInt( m_planeId, (int)m_selectedType ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - return ValueStr + "[" + ( int ) m_selectedType + "]"; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedType = ( BuiltInShaderClipPlanesTypes ) Enum.Parse( typeof( BuiltInShaderClipPlanesTypes ), GetCurrentParam( ref nodeParams ) ); - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_selectedType ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta deleted file mode 100644 index 3b17b846..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/CameraWorldClipPlanes.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e5a9a010f1c8dda449c8ca7ee9e25869 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs deleted file mode 100644 index c2e93c26..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Ortho Params", "Camera And Screen", "Orthographic Parameters" )] - public sealed class OrthoParams : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "Ortho Cam Width" ); - ChangeOutputName( 2, "Ortho Cam Height" ); - ChangeOutputName( 3, "Unused" ); - ChangeOutputName( 4, "Projection Mode" ); - m_value = "unity_OrthoParams"; - m_previewShaderGUID = "88a910ece3dce224793e669bb1bc158d"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - - if( !m_outputPorts[ 3 ].IsConnected ) - { - m_outputPorts[ 3 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta deleted file mode 100644 index d406a63e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/OrthoParams.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f9431cdf8e81c1d4f902b3fa7d04f7ac -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs deleted file mode 100644 index 9e4357b7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Projection Params", "Camera And Screen", "Projection Near/Far parameters" )] - public sealed class ProjectionParams : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "Flipped" ); - ChangeOutputName( 2, "Near Plane" ); - ChangeOutputName( 3, "Far Plane" ); - ChangeOutputName( 4, "1/Far Plane" ); - m_value = "_ProjectionParams"; - m_previewShaderGUID = "97ae846cb0a6b044388fad3bc03bb4c2"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta deleted file mode 100644 index 8e87d5a2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ProjectionParams.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ba1ca8bace2c2dd4dafac6f73f4dfb1b -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs deleted file mode 100644 index 5446ac2f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Screen Params", "Camera And Screen", "Camera's Render Target size parameters" )] - public sealed class ScreenParams : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "RT Width" ); - ChangeOutputName( 2, "RT Height" ); - ChangeOutputName( 3, "1+1/Width" ); - ChangeOutputName( 4, "1+1/Height" ); - m_value = "_ScreenParams"; - m_previewShaderGUID = "78173633b803de4419206191fed3d61e"; - } - - //public override void RefreshExternalReferences() - //{ - // base.RefreshExternalReferences(); - // if( !m_outputPorts[ 0 ].IsConnected ) - // { - // m_outputPorts[ 0 ].Visible = false; - // m_sizeIsDirty = true; - // } - //} - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta deleted file mode 100644 index f43db824..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ScreenParams.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2e593f23857d59643b5b5f6dd6264e1b -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs deleted file mode 100644 index 2342f158..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Space Camera Pos", "Camera And Screen", "World Space Camera position" )] - public sealed class WorldSpaceCameraPos : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 ); - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - - m_value = "_WorldSpaceCameraPos"; - m_previewShaderGUID = "6b0c78411043dd24dac1152c84bb63ba"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - return GetOutputVectorItem( 0, outputId, base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta deleted file mode 100644 index 8a47447f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/WorldSpaceCameraPos.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 972d92a6008896f4292a61726e18f667 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs deleted file mode 100644 index 4fcb5e19..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Z-Buffer Params", "Camera And Screen", "Linearized Z buffer values" )] - public sealed class ZBufferParams : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "1-far/near" ); - ChangeOutputName( 2, "far/near" ); - ChangeOutputName( 3, "[0]/far" ); - ChangeOutputName( 4, "[1]/far" ); - m_value = "_ZBufferParams"; - m_previewShaderGUID = "56c42c106bcb497439187f5bb6b6f94d"; - } - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta deleted file mode 100644 index e8b668c8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/CameraAndScreen/ZBufferParams.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2765a41106f478f4982e859b978bdec4 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs deleted file mode 100644 index d74d8a5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - public class ConstVecShaderVariable : ShaderVariablesNode - { - [SerializeField] - protected string m_value; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, " ", WirePortDataType.FLOAT4 ); - AddOutputPort( WirePortDataType.FLOAT, "0" ); - AddOutputPort( WirePortDataType.FLOAT, "1" ); - AddOutputPort( WirePortDataType.FLOAT, "2" ); - AddOutputPort( WirePortDataType.FLOAT, "3" ); - } - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - switch ( outputId ) - { - case 0: return m_value; - case 1: return ( m_value + ".x" ); - case 2: return ( m_value + ".y" ); - case 3: return ( m_value + ".z" ); - case 4: return ( m_value + ".w" ); - } - - UIUtils.ShowMessage( UniqueId, "ConstVecShaderVariable generating empty code", MessageSeverity.Warning ); - return string.Empty; - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta deleted file mode 100644 index 97976c8a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstVecShaderVariable.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9102c0b554fd5ad4785acf870dcc17eb -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs deleted file mode 100644 index ff6279e7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class ConstantShaderVariable : ShaderVariablesNode - { - [SerializeField] - protected string m_value; - - [SerializeField] - protected string m_HDValue = string.Empty; - - [SerializeField] - protected string m_LWValue = string.Empty; - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - if( dataCollector.IsTemplate ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_HDValue ) ) - return m_HDValue; - - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_LWValue )) - return m_LWValue; - } - return m_value; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta deleted file mode 100644 index 55110165..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ConstantShaderVariable.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 266391c3c4308014e9ce246e5484b917 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta deleted file mode 100644 index e0c69e86..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 78eb7b1e34d423c40a949c9e75b5f24a -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs deleted file mode 100644 index 2af78f78..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum BuiltInFogAndAmbientColors - { - UNITY_LIGHTMODEL_AMBIENT = 0, - unity_AmbientSky, - unity_AmbientEquator, - unity_AmbientGround, - unity_FogColor - } - - [Serializable] - [NodeAttributes( "Fog And Ambient Colors", "Light", "Fog and Ambient colors" )] - public sealed class FogAndAmbientColorsNode : ShaderVariablesNode - { - private const string ColorLabelStr = "Color"; - private readonly string[] ColorValuesStr = { - "Ambient light ( Legacy )", - "Sky ambient light", - "Equator ambient light", - "Ground ambient light", - "Fog" - }; - - [SerializeField] - private BuiltInFogAndAmbientColors m_selectedType = BuiltInFogAndAmbientColors.UNITY_LIGHTMODEL_AMBIENT; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, ColorValuesStr[ ( int ) m_selectedType ], WirePortDataType.COLOR ); - m_textLabelWidth = 50; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "937c7bde062f0f942b600d9950d2ebb2"; - } - - 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 SetPreviewInputs() - { - base.SetPreviewInputs(); - m_previewMaterialPassId = (int)m_selectedType; - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_selectedType = (BuiltInFogAndAmbientColors)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, ColorValuesStr ); - if( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, ColorValuesStr[ (int)m_selectedType ] ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_selectedType = ( BuiltInFogAndAmbientColors ) EditorGUILayoutPopup( ColorLabelStr, ( int ) m_selectedType, ColorValuesStr ); - - if ( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.HD ) - { - switch( m_selectedType ) - { - case BuiltInFogAndAmbientColors.unity_AmbientSky: - return "_Ambient_ColorSky"; - case BuiltInFogAndAmbientColors.unity_AmbientEquator: - return "_Ambient_Equator"; - case BuiltInFogAndAmbientColors.unity_AmbientGround: - return "_Ambient_Ground"; - case BuiltInFogAndAmbientColors.unity_FogColor: - return "_FogColor"; - } - } - return m_selectedType.ToString(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedType = ( BuiltInFogAndAmbientColors ) Enum.Parse( typeof( BuiltInFogAndAmbientColors ), GetCurrentParam( ref nodeParams ) ); - ChangeOutputName( 0, ColorValuesStr[ ( int ) m_selectedType ] ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta deleted file mode 100644 index f2ab7d02..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogAndAmbientColorsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e2bdfc2fa6fcd0640b01a8b7448a1a11 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs deleted file mode 100644 index 63a635d1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Fog Params", "Light", "Parameters for fog calculation" )] - public sealed class FogParamsNode : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "Density/Sqrt(Ln(2))" ); - ChangeOutputName( 2, "Density/Ln(2)" ); - ChangeOutputName( 3, "-1/(End-Start)" ); - ChangeOutputName( 4, "End/(End-Start))" ); - m_value = "unity_FogParams"; - m_previewShaderGUID = "42abde3281b1848438c3b53443c91a1e"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta deleted file mode 100644 index ccc0df5e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/FogAndAmbient/FogParamsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a3d8c31159e07bc419a7484ab5e894ed -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta deleted file mode 100644 index 86287e65..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 47f503bcb5935b649beee3296dd40260 -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs deleted file mode 100644 index d985714c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - - public enum ASEStandardSurfaceWorkflow - { - Metallic = 0, - Specular - } - - [Serializable] - [NodeAttributes( "Standard Surface Light", "Light", "Provides a way to create a standard surface light model in custom lighting mode", NodeAvailabilityFlags = (int)NodeAvailability.CustomLighting )] - public sealed class CustomStandardSurface : ParentNode - { - private const string WorkflowStr = "Workflow"; - - [SerializeField] - private ASEStandardSurfaceWorkflow m_workflow = ASEStandardSurfaceWorkflow.Metallic; - - [SerializeField] - private ViewSpace m_normalSpace = ViewSpace.Tangent; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Albedo" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal" ); - m_inputPorts[ 1 ].Vector3InternalData = Vector3.forward; - AddInputPort( WirePortDataType.FLOAT3, false, "Emission" ); - AddInputPort( WirePortDataType.FLOAT, false, "Metallic" ); - AddInputPort( WirePortDataType.FLOAT, false, "Smoothness" ); - AddInputPort( WirePortDataType.FLOAT, false, "Occlusion" ); - m_inputPorts[ 5 ].FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT3, "RGB" ); - m_autoWrapProperties = true; - m_textLabelWidth = 100; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = "This node only returns correct information using a custom light model, otherwise returns 0"; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( m_inputPorts[ 1 ].IsConnected && m_normalSpace == ViewSpace.Tangent ) - dataCollector.DirtyNormal = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_workflow = (ASEStandardSurfaceWorkflow)EditorGUILayoutEnumPopup( WorkflowStr, m_workflow ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateSpecularMetallicPorts(); - } - - EditorGUI.BeginChangeCheck(); - m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePort(); - } - } - - private void UpdatePort() - { - if( m_normalSpace == ViewSpace.World ) - m_inputPorts[ 1 ].Name = "World Normal"; - else - m_inputPorts[ 1 ].Name = "Normal"; - - m_sizeIsDirty = true; - } - - void UpdateSpecularMetallicPorts() - { - if( m_workflow == ASEStandardSurfaceWorkflow.Specular ) - m_inputPorts[ 3 ].ChangeProperties( "Specular", WirePortDataType.FLOAT3, false ); - else - m_inputPorts[ 3 ].ChangeProperties( "Metallic", WirePortDataType.FLOAT, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting ) - return "float3(0,0,0)"; - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - string specularMode = string.Empty; - if( m_workflow == ASEStandardSurfaceWorkflow.Specular ) - specularMode = "Specular"; - - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - - if( dataCollector.DirtyNormal ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - } - - dataCollector.AddLocalVariable( UniqueId, "SurfaceOutputStandard" + specularMode + " s" + OutputId + " = (SurfaceOutputStandard" + specularMode + " ) 0;" ); - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Albedo = " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ";" ); - - string normal = string.Empty; - - if( m_inputPorts[ 1 ].IsConnected ) - { - normal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - if( m_normalSpace == ViewSpace.Tangent ) - { - normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )"; - } - } - else - { - normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ); - } - - - - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Normal = "+ normal + ";" ); - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Emission = " + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ) + ";" ); - if( m_workflow == ASEStandardSurfaceWorkflow.Specular ) - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Specular = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ";" ); - else - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Metallic = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ";" ); - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Smoothness = " + m_inputPorts[ 4 ].GeneratePortInstructions( ref dataCollector ) + ";" ); - dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Occlusion = " + m_inputPorts[ 5 ].GeneratePortInstructions( ref dataCollector ) + ";\n" ); - - dataCollector.AddLocalVariable( UniqueId, "data.light = gi.light;\n", true ); - - dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi;" ); - dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDBASE", true ); - - dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( s" + OutputId + ".Smoothness, data.worldViewDir, s" + OutputId + ".Normal, float3(0,0,0));" ); - dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGlobalIllumination( data, s" + OutputId + ".Occlusion, s" + OutputId + ".Normal, g" + OutputId + " );" ); - dataCollector.AddLocalVariable( UniqueId, "#endif\n", true ); - dataCollector.AddLocalVariable( UniqueId, "float3 surfResult" + OutputId + " = LightingStandard" + specularMode + " ( s" + OutputId + ", viewDir, gi" + OutputId + " ).rgb;" ); - //Emission must be always added to trick Unity, so it knows what needs to be created p.e. world pos - dataCollector.AddLocalVariable( UniqueId, "surfResult" + OutputId + " += s" + OutputId + ".Emission;\n" ); - - m_outputPorts[ 0 ].SetLocalValue( "surfResult" + OutputId, dataCollector.PortCategory ); - - //Remove emission contribution from Forward Add - dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDADD//" + OutputId ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "surfResult{0} -= s{0}.Emission;", OutputId )); - dataCollector.AddLocalVariable( UniqueId, "#endif//" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader || ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) ) - m_showErrorMessage = true; - else - m_showErrorMessage = false; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 13204 ) - { - m_workflow = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? ASEStandardSurfaceWorkflow.Specular : ASEStandardSurfaceWorkflow.Metallic; - } - else - { - m_workflow = (ASEStandardSurfaceWorkflow)Enum.Parse( typeof( ASEStandardSurfaceWorkflow ), GetCurrentParam( ref nodeParams ) ); - } - UpdateSpecularMetallicPorts(); - - if( UIUtils.CurrentShaderVersion() >= 14402 ) - { - m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) ); - } - UpdatePort(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_workflow ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta deleted file mode 100644 index 172f37cd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/CustomStandardSurface.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 78916999fd7bc3c4e9767bc9cf0698c0 -timeCreated: 1500054866 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs deleted file mode 100644 index c58da735..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Indirect Diffuse Light", "Light", "Indirect Lighting", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )] - public sealed class IndirectDiffuseLighting : ParentNode - { - [SerializeField] - private ViewSpace m_normalSpace = ViewSpace.Tangent; - - private int m_cachedIntensityId = -1; - - - private readonly string LWIndirectDiffuseHeader = "ASEIndirectDiffuse( {0}, {1})"; - private readonly string[] LWIndirectDiffuseBody = - { - "float3 ASEIndirectDiffuse( float2 uvStaticLightmap, float3 normalWS )\n", - "{\n", - "#ifdef LIGHTMAP_ON\n", - "\treturn SampleLightmap( uvStaticLightmap, normalWS );\n", - "#else\n", - "\treturn SampleSH(normalWS);\n", - "#endif\n", - "}\n" - }; - - - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal" ); - AddOutputPort( WirePortDataType.FLOAT3, "RGB" ); - m_inputPorts[ 0 ].Vector3InternalData = Vector3.forward; - m_autoWrapProperties = true; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = "This node only returns correct information using a custom light model, otherwise returns 0"; - m_previewShaderGUID = "b45d57fa606c1ea438fe9a2c08426bc7"; - m_drawPreviewAsSphere = true; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - m_previewMaterialPassId = 1; - else - m_previewMaterialPassId = 2; - } - else - { - m_previewMaterialPassId = 0; - } - - if( m_cachedIntensityId == -1 ) - m_cachedIntensityId = Shader.PropertyToID( "_Intensity" ); - - PreviewMaterial.SetFloat( m_cachedIntensityId, RenderSettings.ambientIntensity ); - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - // This needs to be rechecked - //if( m_inputPorts[ 0 ].IsConnected ) - dataCollector.DirtyNormal = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePort(); - } - } - - private void UpdatePort() - { - if( m_normalSpace == ViewSpace.World ) - m_inputPorts[ 0 ].ChangeProperties( "World Normal", m_inputPorts[ 0 ].DataType, false ); - else - m_inputPorts[ 0 ].ChangeProperties( "Normal", m_inputPorts[ 0 ].DataType, false ); - - m_sizeIsDirty = true; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) ) - m_showErrorMessage = true; - else - m_showErrorMessage = 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 finalValue = string.Empty; - - if( dataCollector.IsTemplate && dataCollector.IsFragmentCategory ) - { - if( !dataCollector.IsSRP ) - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib ); - - string texcoord1 = string.Empty; - string texcoord2 = string.Empty; - - if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) ) - texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName; - else - texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ); - - if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) ) - texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName; - else - texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false ); - - string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName; - string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName; - TemplateVertexData data = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lmap" ); - - string varName = "ase_lmap"; - if( data != null ) - varName = data.VarName; - - dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef DYNAMICLIGHTMAP_ON //dynlm" ); - dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //dynlm" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef LIGHTMAP_ON //stalm" ); - dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw;" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //stalm" ); - - TemplateVertexData shdata = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT3, false, "ase_sh" ); - string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Vertex ); - string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - //Debug.Log( shdata ); - string shVarName = "ase_sh"; - if( shdata != null ) - shVarName = shdata.VarName; - string outSH = vOutName + "." + shVarName + ".xyz"; - dataCollector.AddToVertexLocalVariables( UniqueId, "#ifndef LIGHTMAP_ON //nstalm" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //sh" ); - dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = 0;" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef VERTEXLIGHT_ON //vl" ); - dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " += Shade4PointLights (" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0," ); - dataCollector.AddToVertexLocalVariables( UniqueId, "unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb," ); - dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightAtten0, " + worldPos + ", " + worldNormal + ");" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //vl" ); - dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = ShadeSHPerVertex (" + worldNormal + ", " + outSH + ");" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //sh" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //nstalm" ); - - //dataCollector.AddToPragmas( UniqueId, "multi_compile_fwdbase" ); - - string fragWorldNormal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ); - else - fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ); - } - - dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data" + OutputId + ";" ); - dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data" + OutputId + " );" ); - - dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) //dylm" + OutputId ); - dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".lightmapUV = " + fInName + "." + varName + ";" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //dylm" + OutputId ); - - dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //fsh" + OutputId ); - dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".ambient = " + fInName + "." + shVarName + ";" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //fsh" + OutputId ); - - dataCollector.AddToLocalVariables( UniqueId, "UnityGI gi" + OutputId + " = UnityGI_Base(data" + OutputId + ", 1, " + fragWorldNormal + ");" ); - - finalValue = "gi" + OutputId + ".indirect.diffuse"; - m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ); - return finalValue; - } - else - { - if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight ) - { - string texcoord1 = string.Empty; - - if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) ) - texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName; - else - texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ); - - string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName; - string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName; - - - if( !dataCollector.TemplateDataCollectorInstance.HasRawInterpolatorOfName( "lightmapUVOrVertexSH" ) ) - { - string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "lightmapUVOrVertexSH" ); - - dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_LIGHTMAP_UV( " + texcoord1 + ", unity_LightmapST, " + vOutName + ".lightmapUVOrVertexSH.xy );" ); - dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH( " + worldNormal + ", " + vOutName + ".lightmapUVOrVertexSH.xyz );" ); - - dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" ); - dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" ); - } - - string fragWorldNormal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ); - else - fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ); - } - - //SAMPLE_GI - - //This function may not do full pixel and does not behave correctly with given normal thus is commented out - //dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SAMPLE_GI( " + fInName + ".lightmapUVOrVertexSH.xy, " + fInName + ".lightmapUVOrVertexSH.xyz, " + fragWorldNormal + " );" ); - dataCollector.AddFunction( LWIndirectDiffuseBody[ 0 ], LWIndirectDiffuseBody, false ); - finalValue = "bakedGI" + OutputId; - string result = string.Format( LWIndirectDiffuseHeader, fInName + ".lightmapUVOrVertexSH.xy", fragWorldNormal ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, finalValue, result ); - - m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ); - return finalValue; - } - else if( dataCollector.CurrentSRPType == TemplateSRPType.HD ) - { - string texcoord1 = string.Empty; - string texcoord2 = string.Empty; - - if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) ) - texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName; - else - texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ); - - if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) ) - texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName; - else - texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false ); - - dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lightmapUVs" ); - - string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName; - string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName; - - dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw;" ); - dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;" ); - - string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Fragment ); - - dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" ); - dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" ); - dataCollector.AddToPragmas( UniqueId, "multi_compile _ DYNAMICLIGHTMAP_ON" ); - - string fragWorldNormal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ); - else - fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ); - } - - //SAMPLE_GI - dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SampleBakedGI( " + worldPos + ", " + fragWorldNormal + ", " + fInName + ".ase_lightmapUVs.xy, " + fInName + ".ase_lightmapUVs.zw );" ); - finalValue = "bakedGI" + OutputId; - m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ); - return finalValue; - } - } - } - if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting ) - return "float3(0,0,0)"; - - string normal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - - normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_normalSpace == ViewSpace.Tangent ) - normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )"; - } - else - { - if( dataCollector.IsFragmentCategory ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - if( dataCollector.DirtyNormal ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - } - } - - normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ); - } - - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "ShadeSH9( float4( " + normal + ", 1 ) )" ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi;" ); - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT3, "diffNorm" + OutputId, normal ); - dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGI_Base( data, 1, diffNorm" + OutputId + " );" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "gi" + OutputId + ".indirect.diffuse + diffNorm" + OutputId + " * 0.0001" ); - } - - finalValue = "indirectDiffuse" + OutputId; - m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ); - return finalValue; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 13002 ) - m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) ); - - UpdatePort(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta deleted file mode 100644 index 2e9b5ba5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectDiffuseLighting.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 11bf17b0757d57c47add2eb50c62c75e -timeCreated: 1495726164 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs deleted file mode 100644 index 197e193e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs +++ /dev/null @@ -1,268 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Indirect Specular Light", "Light", "Indirect Specular Light", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )] - public sealed class IndirectSpecularLight : ParentNode - { - [SerializeField] - private ViewSpace m_normalSpace = ViewSpace.Tangent; - - private const string DefaultErrorMessage = "This node only returns correct information using a custom light model, otherwise returns 0"; - private bool m_upgradeMessage = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal" ); - AddInputPort( WirePortDataType.FLOAT, false, "Smoothness" ); - AddInputPort( WirePortDataType.FLOAT, false, "Occlusion" ); - m_inputPorts[ 0 ].Vector3InternalData = Vector3.forward; - m_inputPorts[ 1 ].FloatInternalData = 0.5f; - m_inputPorts[ 2 ].FloatInternalData = 1; - m_inputPorts[ 1 ].AutoDrawInternalData = true; - m_inputPorts[ 2 ].AutoDrawInternalData = true; - m_autoWrapProperties = true; - AddOutputPort( WirePortDataType.FLOAT3, "RGB" ); - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = DefaultErrorMessage; - m_previewShaderGUID = "d6e441d0a8608954c97fa347d3735e92"; - m_drawPreviewAsSphere = true; - } - - 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 SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - m_previewMaterialPassId = 1; - else - m_previewMaterialPassId = 2; - } - else - { - m_previewMaterialPassId = 0; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_normalSpace = (ViewSpace)EditorGUILayoutEnumPopup( "Normal Space", m_normalSpace ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePort(); - } - if( !m_inputPorts[ 1 ].IsConnected ) - m_inputPorts[ 1 ].FloatInternalData = EditorGUILayout.FloatField( m_inputPorts[ 1 ].Name, m_inputPorts[ 1 ].FloatInternalData ); - if( !m_inputPorts[ 2 ].IsConnected ) - m_inputPorts[ 2 ].FloatInternalData = EditorGUILayout.FloatField( m_inputPorts[ 2 ].Name, m_inputPorts[ 2 ].FloatInternalData ); - } - - private void UpdatePort() - { - if( m_normalSpace == ViewSpace.World ) - m_inputPorts[ 0 ].ChangeProperties( "World Normal", m_inputPorts[ 0 ].DataType, false ); - else - m_inputPorts[ 0 ].ChangeProperties( "Normal", m_inputPorts[ 0 ].DataType, false ); - - m_sizeIsDirty = true; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( m_upgradeMessage || ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) ) - m_showErrorMessage = true; - else - m_showErrorMessage = false; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - { - if( !dataCollector.IsSRP ) - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib ); - string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos(); - string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, MasterNodePortCategory.Fragment ); - - string worldNormal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ); - else - worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ); - } - - string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data;" ); - dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data );" ); - dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ";" ); - dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + worldViewDir + ";" ); - dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR;" ); - dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR;" ); - dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[0] = unity_SpecCube0_BoxMin;" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" ); - dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[0] = unity_SpecCube0_BoxMax;" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[0] = unity_SpecCube0_ProbePosition;" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[1] = unity_SpecCube1_BoxMax;" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[1] = unity_SpecCube1_BoxMin;" ); - dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[1] = unity_SpecCube1_ProbePosition;" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" ); - - dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + tempsmoothness + ", " + worldViewDir + ", " + worldNormal + ", float3(0,0,0));" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + tempocclusion + ", " + worldNormal + ", g" + OutputId + " )" ); - return "indirectSpecular" + OutputId; - } - else - { - if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight ) - { - string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, MasterNodePortCategory.Fragment ); - string worldNormal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - if( m_normalSpace == ViewSpace.Tangent ) - worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ); - else - worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ); - } - - string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - dataCollector.AddLocalVariable( UniqueId, "half3 reflectVector" + OutputId + " = reflect( -" + worldViewDir + ", " + worldNormal + " );" ); - dataCollector.AddLocalVariable( UniqueId, "float3 indirectSpecular" + OutputId + " = GlossyEnvironmentReflection( reflectVector" + OutputId + ", 1.0 - " + tempsmoothness + ", " + tempocclusion + " );" ); - return "indirectSpecular" + OutputId; - } - else if( dataCollector.CurrentSRPType == TemplateSRPType.HD ) - { - UIUtils.ShowMessage( UniqueId, "Indirect Specular Light node currently not supported on HDRP" ); - return m_outputPorts[0].ErrorValue; - } - } - } - - if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting ) - return m_outputPorts[0].ErrorValue; - - string normal = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - - normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_normalSpace == ViewSpace.Tangent ) - normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )"; - - dataCollector.AddLocalVariable( UniqueId, "float3 indirectNormal" + OutputId + " = " + normal + ";" ); - normal = "indirectNormal" + OutputId; - } - else - { - if( dataCollector.IsFragmentCategory ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - if( dataCollector.DirtyNormal ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - } - } - - normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ); - } - - string smoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string occlusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string viewDir = "data.worldViewDir"; - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - string worldPos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, UniqueId ); - viewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId ); - - dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data;" ); - dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data );" ); - dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ";" ); - dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + viewDir + ";" ); - dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR;" ); - dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR;" ); - dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" ); - dataCollector.AddLocalVariable( UniqueId, "data.boxMin[0] = unity_SpecCube0_BoxMin;" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" ); - dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" ); - dataCollector.AddLocalVariable( UniqueId, "data.boxMax[0] = unity_SpecCube0_BoxMax;" ); - dataCollector.AddLocalVariable( UniqueId, "data.probePosition[0] = unity_SpecCube0_ProbePosition;" ); - dataCollector.AddLocalVariable( UniqueId, "data.boxMax[1] = unity_SpecCube1_BoxMax;" ); - dataCollector.AddLocalVariable( UniqueId, "data.boxMin[1] = unity_SpecCube1_BoxMin;" ); - dataCollector.AddLocalVariable( UniqueId, "data.probePosition[1] = unity_SpecCube1_ProbePosition;" ); - dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" ); - } - - dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + smoothness + ", " + viewDir + ", " + normal + ", float3(0,0,0));" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + occlusion + ", " + normal + ", g" + OutputId + " )" ); - - return "indirectSpecular" + OutputId; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 13002 ) - m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) ); - - if( UIUtils.CurrentShaderVersion() < 13804 ) - { - m_errorMessageTooltip = "Smoothness port was previously being used as Roughness, please check if you are correctly using it and save to confirm."; - m_upgradeMessage = true; - UIUtils.ShowMessage( UniqueId, "Indirect Specular Light node: Smoothness port was previously being used as Roughness, please check if you are correctly using it and save to confirm." ); - } - - UpdatePort(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalSpace ); - - m_errorMessageTooltip = DefaultErrorMessage; - m_upgradeMessage = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta deleted file mode 100644 index 0c0bb141..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/IndirectSpecularLight.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0820850e74009954188ff84e2f5cc4f2 -timeCreated: 1495817589 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs deleted file mode 100644 index 57ad0f44..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEditor; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Light Attenuation", "Light", "Contains light attenuation for all types of light", NodeAvailabilityFlags = (int)( NodeAvailability.CustomLighting | NodeAvailability.TemplateShader ) )] - public sealed class LightAttenuation : ParentNode - { - static readonly string SurfaceError = "This node only returns correct information using a custom light model, otherwise returns 1"; - static readonly string TemplateError = "This node will only produce proper attenuation if the template contains a shadow caster pass"; - - private const string ASEAttenVarName = "ase_lightAtten"; - - private readonly string[] LightweightPragmaMultiCompiles = - { - "multi_compile _ _MAIN_LIGHT_SHADOWS", - "multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE", - "multi_compile _ _SHADOWS_SOFT" - }; - - //private readonly string[] LightweightVertexInstructions = - //{ - // /*local vertex position*/"VertexPositionInputs ase_vertexInput = GetVertexPositionInputs ({0});", - // "#ifdef _MAIN_LIGHT_SHADOWS//ase_lightAtten_vert", - // /*available interpolator*/"{0} = GetShadowCoord( ase_vertexInput );", - // "#endif//ase_lightAtten_vert" - //}; - private const string LightweightLightAttenDecl = "float ase_lightAtten = 0;"; - private readonly string[] LightweightFragmentInstructions = - { - /*shadow coords*/"Light ase_lightAtten_mainLight = GetMainLight( {0} );", - "ase_lightAtten = ase_lightAtten_mainLight.distanceAttenuation * ase_lightAtten_mainLight.shadowAttenuation;" - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = SurfaceError; - m_previewShaderGUID = "4b12227498a5c8d46b6c44ea018e5b56"; - m_drawPreviewAsSphere = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - { - if( !dataCollector.IsSRP ) - { - return dataCollector.TemplateDataCollectorInstance.GetLightAtten( UniqueId ); - } - else - { - if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight ) - { - if( dataCollector.HasLocalVariable( LightweightLightAttenDecl )) - return ASEAttenVarName; - - // Pragmas - for( int i = 0; i < LightweightPragmaMultiCompiles.Length; i++ ) - dataCollector.AddToPragmas( UniqueId, LightweightPragmaMultiCompiles[ i ] ); - - string shadowCoords = dataCollector.TemplateDataCollectorInstance.GetShadowCoords( UniqueId/*, false, dataCollector.PortCategory*/ ); - //return shadowCoords; - // Vertex Instructions - //TemplateVertexData shadowCoordsData = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false ); - //string vertexInterpName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName; - //string vertexShadowCoords = vertexInterpName + "." + shadowCoordsData.VarNameWithSwizzle; - //string vertexPos = dataCollector.TemplateDataCollectorInstance.GetVertexPosition( WirePortDataType.FLOAT3, PrecisionType.Float ,false,MasterNodePortCategory.Vertex ); - - //dataCollector.AddToVertexLocalVariables( UniqueId, string.Format( LightweightVertexInstructions[ 0 ], vertexPos )); - //dataCollector.AddToVertexLocalVariables( UniqueId, LightweightVertexInstructions[ 1 ]); - //dataCollector.AddToVertexLocalVariables( UniqueId, string.Format( LightweightVertexInstructions[ 2 ], vertexShadowCoords ) ); - //dataCollector.AddToVertexLocalVariables( UniqueId, LightweightVertexInstructions[ 3 ]); - - // Fragment Instructions - //string fragmentInterpName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName; - //string fragmentShadowCoords = fragmentInterpName + "." + shadowCoordsData.VarNameWithSwizzle; - - dataCollector.AddLocalVariable( UniqueId, LightweightLightAttenDecl ); - dataCollector.AddLocalVariable( UniqueId, string.Format( LightweightFragmentInstructions[ 0 ], shadowCoords ) ); - dataCollector.AddLocalVariable( UniqueId, LightweightFragmentInstructions[ 1 ] ); - return ASEAttenVarName; - } - else - { - UIUtils.ShowMessage( UniqueId, "Light Attenuation node currently not supported on HDRP" ); - return "1"; - } - } - } - - if ( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting ) - { - UIUtils.ShowMessage( UniqueId, "Light Attenuation node currently not supported on non-custom lighting surface shaders" ); - return "1"; - } - - dataCollector.UsingLightAttenuation = true; - return ASEAttenVarName; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader && ContainerGraph.CurrentSRPType != TemplateSRPType.Lightweight ) - { - m_showErrorMessage = true; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = TemplateError; - } else - { - m_errorMessageTypeIsError = NodeMessageType.Error; - m_errorMessageTooltip = SurfaceError; - if ( ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel != StandardShaderLightModel.CustomLighting ) ) - m_showErrorMessage = true; - else - m_showErrorMessage = false; - } - - - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta deleted file mode 100644 index 05a8aa70..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightAttenuation.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4e205b44d56609f459ffc558febe2792 -timeCreated: 1495449979 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs deleted file mode 100644 index 92021081..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Light Color", "Light", "Light Color, RGB value already contains light intensity while A only contains light intensity" )] - public sealed class LightColorNode : ShaderVariablesNode - { - private const string m_lightColorValue = "_LightColor0"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "RGBA", WirePortDataType.COLOR ); - AddOutputPort( WirePortDataType.FLOAT3, "Color" ); - AddOutputPort( WirePortDataType.FLOAT, "Intensity" ); - m_previewShaderGUID = "43f5d3c033eb5044e9aeb40241358349"; - } - - public override void RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - RenderTexture temp = RenderTexture.active; - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, i ); - RenderTexture.active = temp; - } - - PreviewIsDirty = m_continuousPreviewRefresh; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate && !dataCollector.IsSRP ) - dataCollector.AddToIncludes( -1, Constants.UnityLightingLib ); - - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - string finalVar = m_lightColorValue; - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - { - dataCollector.TemplateDataCollectorInstance.AddHDLightInfo(); - finalVar = string.Format( TemplateHelperFunctions.HDLightInfoFormat, "0", "color" ); ; - } - else - { - finalVar = "_MainLightColor"; - } - } - else - { - dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) && ( UNITY_VERSION < 560 || ( defined(LIGHTMAP_SHADOW_MIXING) && !defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN) ) )//aselc" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "ase_lightColor", "0" ); - dataCollector.AddLocalVariable( UniqueId, "#else //aselc" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "ase_lightColor", finalVar ); - dataCollector.AddLocalVariable( UniqueId, "#endif //aselc" ); - finalVar = "ase_lightColor"; - } - //else if( ContainerGraph.CurrentStandardSurface.CurrentLightingModel == StandardShaderLightModel.CustomLighting ) - // finalVar = "gi.light.color"; - - switch( outputId ) - { - default: - case 0: return finalVar; - case 1: return finalVar + ".rgb"; - case 2: return finalVar + ".a"; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta deleted file mode 100644 index 9acf2a10..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/LightColorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 275270020c577924caf04492f73b2ea6 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs deleted file mode 100644 index 80aae5df..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEditor; -using UnityEngine; -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "World Space Light Pos", "Light", "Light Position" )] - public sealed class WorldSpaceLightPos : ShaderVariablesNode - { - private const string HelperText = - "This node will behave differently according to light type." + - "\n\n- For directional lights the Dir/Pos output will specify a world space direction and Type will be set to 0." + - "\n\n- For other light types the Dir/Pos output will specify a world space position and Type will be set to 1."; - private const string m_lightPosValue = "_WorldSpaceLightPos0"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, Constants.EmptyPortValue, WirePortDataType.FLOAT4 ); - AddOutputPort( WirePortDataType.FLOAT3, "Dir/Pos" ); - AddOutputPort( WirePortDataType.FLOAT, "Type" ); - m_previewShaderGUID = "2292a614672283c41a367b22cdde4620"; - m_drawPreviewAsSphere = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.HelpBox( HelperText, MessageType.Info ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - string finalVar = m_lightPosValue; - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP ) - finalVar = "_MainLightPosition"; - if( outputId == 1 ) - { - return finalVar + ".xyz"; - } - else if( outputId == 2 ) - { - return finalVar + ".w"; - } - else - { - return finalVar; - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - - public override void RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - SetPreviewInputs(); - - RenderTexture temp = RenderTexture.active; - - RenderTexture.active = m_outputPorts[ 0 ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ 0 ].OutputPreviewTexture, PreviewMaterial, 0 ); - Graphics.Blit( m_outputPorts[ 0 ].OutputPreviewTexture, m_outputPorts[ 1 ].OutputPreviewTexture ); - - RenderTexture.active = m_outputPorts[ 2 ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ 2 ].OutputPreviewTexture, PreviewMaterial, 1 ); - RenderTexture.active = temp; - - PreviewIsDirty = m_continuousPreviewRefresh; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta deleted file mode 100644 index 79f4fc5b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Lighting/WorldSpaceLightPos.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: db94d973647dae9488d3ef5ee2fd95a4 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs deleted file mode 100644 index 499999f1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class ShaderVariablesNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.OBJECT, "Out" ); - } - public override string GetIncludes() - { - return Constants.UnityShaderVariables; - } - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP ) ) - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - return string.Empty; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta deleted file mode 100644 index dce292dc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/ShaderVariablesNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1eb723e6ceff9a345a9dbfe04aa3dc11 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta deleted file mode 100644 index bfd7fd96..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 7c77e88b33fec7c429412624a7b2c620 -folderAsset: yes -timeCreated: 1481126947 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs deleted file mode 100644 index 096676f2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Cos Time", "Time", "Cosine of time" )] - public sealed class CosTime : ConstVecShaderVariable - { -#if UNITY_2018_3_OR_NEWER - private readonly string[] SRPTime = - { - "cos( _TimeParameters.x * 0.125 )", - "cos( _TimeParameters.x * 0.25 )", - "cos( _TimeParameters.x * 0.5 )", - "_TimeParameters.z", - }; -#endif - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "t/8" ); - ChangeOutputName( 2, "t/4" ); - ChangeOutputName( 3, "t/2" ); - ChangeOutputName( 4, "t" ); - m_value = "_CosTime"; - m_previewShaderGUID = "3093999b42c3c0940a71799511d7781c"; - m_continuousPreviewRefresh = true; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { -#if UNITY_2018_3_OR_NEWER - if( outputId > 0 && dataCollector.IsTemplate ) - { - if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) || - ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ) - return SRPTime[ outputId - 1 ]; - } -#endif - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta deleted file mode 100644 index 80373c18..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/CosTime.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 447e504f2ca5aaf4bbf0fdbce33596bc -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs deleted file mode 100644 index a1f3380f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Delta Time", "Time", "Delta time" )] - public sealed class DeltaTime : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "dt" ); - ChangeOutputName( 2, "1/dt" ); - ChangeOutputName( 3, "smoothDt" ); - ChangeOutputName( 4, "1/smoothDt" ); - m_value = "unity_DeltaTime"; - m_previewShaderGUID = "9d69a693042c443498f96d6da60535eb"; - m_continuousPreviewRefresh = true; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta deleted file mode 100644 index 400f94fe..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/DeltaTime.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3ddde7ed1ab4f8044a9a6aa3891f5ca4 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs deleted file mode 100644 index 8445f90b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Time", "Time", "Time in seconds with a scale multiplier" )] - public sealed class SimpleTimeNode : ShaderVariablesNode - { - private const string TimeStandard = "_Time.y"; -#if UNITY_2018_3_OR_NEWER - private const string TimeSRP = "_TimeParameters.x"; -#endif - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - m_inputPorts[ 0 ].FloatInternalData = 1; - m_useInternalPortData = true; - m_previewShaderGUID = "45b7107d5d11f124fad92bcb1fa53661"; - m_continuousPreviewRefresh = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - string multiplier = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string timeGlobalVar = TimeStandard; -#if UNITY_2018_3_OR_NEWER - if( dataCollector.IsTemplate ) - { - if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) || - ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ) - timeGlobalVar = TimeSRP; - } -#endif - if( multiplier == "1.0" ) - return timeGlobalVar; - - string scaledVarName = "mulTime" + OutputId; - string scaledVarValue = timeGlobalVar + " * " + multiplier; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, scaledVarName, scaledVarValue ); - return scaledVarName; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta deleted file mode 100644 index 313b9315..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SimpleTimeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f36e4491ee33fe74fa51cfb5ad450c6e -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs deleted file mode 100644 index aac2b1eb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs +++ /dev/null @@ -1,58 +0,0 @@ -// 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( "Sin Time", "Time", "Unity sin time" )] - public sealed class SinTimeNode : ConstVecShaderVariable - { - //double m_time; -#if UNITY_2018_3_OR_NEWER - private readonly string[] SRPTime = - { - "sin( _TimeParameters.x * 0.125 )", - "sin( _TimeParameters.x * 0.25 )", - "sin( _TimeParameters.x * 0.5 )", - "_TimeParameters.y", - }; -#endif - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "t/8" ); - ChangeOutputName( 2, "t/4" ); - ChangeOutputName( 3, "t/2" ); - ChangeOutputName( 4, "t" ); - m_value = "_SinTime"; - m_previewShaderGUID = "e4ba809e0badeb94994170b2cbbbba10"; - m_continuousPreviewRefresh = true; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { -#if UNITY_2018_3_OR_NEWER - if( outputId > 0 && dataCollector.IsTemplate ) - { - if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) || - ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 ) ) - return SRPTime[ outputId - 1 ]; - } -#endif - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta deleted file mode 100644 index 876a7748..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/SinTimeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 796acd44fcf330e4e921855630007b9b -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs deleted file mode 100644 index 258d5177..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Time Parameters", "Time", "Time since level load" )] - public sealed class TimeNode : ConstVecShaderVariable - { -#if UNITY_2018_3_OR_NEWER - private readonly string[] SRPTime = - { - "( _TimeParameters.x * 0.05 )", - "( _TimeParameters.x )", - "( _TimeParameters.x * 2 )", - "( _TimeParameters.x * 3 )", - }; -#endif - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "t/20" ); - ChangeOutputName( 2, "t" ); - ChangeOutputName( 3, "t*2" ); - ChangeOutputName( 4, "t*3" ); - m_value = "_Time"; - m_previewShaderGUID = "73abc10c8d1399444827a7eeb9c24c2a"; - m_continuousPreviewRefresh = true; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { -#if UNITY_2018_3_OR_NEWER - if( outputId > 0 && dataCollector.IsTemplate ) - { - if( ( dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_5_16_1 ) || - ( dataCollector.TemplateDataCollectorInstance.IsLWRP && ASEPackageManagerHelper.CurrentLWVersion > ASESRPVersions.ASE_SRP_5_16_1 )) - return SRPTime[ outputId - 1 ]; - } -#endif - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta deleted file mode 100644 index 521dcf41..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Time/TimeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d8c6b7bfb7784e14d8708ab6fb981268 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta deleted file mode 100644 index 008be40e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2ce97203c4871664493f8760d88d0d4d -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs deleted file mode 100644 index 1238566a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Camera To World Matrix", "Matrix Transform", "Current camera to world matrix" )] - public sealed class CameraToWorldMatrix : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_CameraToWorld"; - m_drawPreview = false; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector ); - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta deleted file mode 100644 index 2e13b7e9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/CameraToWorldMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6accfe0f350cf064dae07041fe90446b -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs deleted file mode 100644 index 0b53040c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Inverse Projection Matrix", "Matrix Transform", "Current inverse projection matrix", NodeAvailabilityFlags = (int)( NodeAvailability.TemplateShader ) )] - public sealed class InverseProjectionMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_I_P"; - m_drawPreview = false; - m_matrixId = 1; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else - { - return GeneratorUtils.GenerateIdentity4x4( ref dataCollector, UniqueId ); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ContainerGraph.IsSRP ) - { - m_showErrorMessage = false; - } - else - { - m_showErrorMessage = true; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = "This node only works for Scriptable Render Pipeline (LWRP, HDRP, URP)"; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta deleted file mode 100644 index 302ccf23..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseProjectionMatrixNode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0fdbc380972c44b489c5f948a40b8e69 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs deleted file mode 100644 index e4071ba0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Inverse Transpose Model View Matrix", "Matrix Transform", "All Transformation types" )] - public sealed class InverseTranspMVMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_IT_MV"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta deleted file mode 100644 index 1b3b8fd3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseTranspMVMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3a71f1e560487aa4c8484c4153941884 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs deleted file mode 100644 index c21aa195..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Inverse View Matrix", "Matrix Transform", "Current inverse view matrix" )] - public sealed class InverseViewMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_I_V"; - m_drawPreview = false; - m_matrixId = 0; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta deleted file mode 100644 index 61b23243..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: dd0c1c252c062184e9ad592b91e7fcd2 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs deleted file mode 100644 index d812cc23..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Inverse View Projection Matrix", "Matrix Transform", "Current view inverse projection matrix", NodeAvailabilityFlags = (int)( NodeAvailability.TemplateShader ) )] - public sealed class InverseViewProjectionMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_I_VP"; - m_drawPreview = false; - m_matrixId = 1; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else - { - return GeneratorUtils.GenerateIdentity4x4( ref dataCollector, UniqueId ); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ContainerGraph.IsSRP ) - { - m_showErrorMessage = false; - } - else - { - m_showErrorMessage = true; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = "This node only works for Scriptable Render Pipeline (LWRP, HDRP, URP)"; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta deleted file mode 100644 index 6b221613..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/InverseViewProjectionMatrixNode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f6f151774e252dd4fb2b9ee440ec8eed -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs deleted file mode 100644 index ed903397..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Model Matrix", "Matrix Transform", "Current model matrix" )] - public sealed class MMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_M"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta deleted file mode 100644 index 51c6d1f8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 503a386043991354eaca2410683d836a -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs deleted file mode 100644 index a99d8518..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Model View Matrix", "Matrix Transform", "Current model * view matrix" )] - public sealed class MVMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_MV"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta deleted file mode 100644 index 6c0355ea..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 30c7936db4e6fe5488076d799841f857 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs deleted file mode 100644 index 324a1532..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Model View Projection Matrix", "Matrix Transform", "Current model * view * projection matrix" )] - public sealed class MVPMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_MVP"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta deleted file mode 100644 index 8275deff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/MVPMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 74e00fb3d8e161f498c078795184bae4 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs deleted file mode 100644 index 2f5873be..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Object To World Matrix", "Matrix Transform", "Current model matrix" )] - public sealed class ObjectToWorldMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_ObjectToWorld"; - m_HDValue = "GetObjectToWorldMatrix()"; - m_LWValue = "GetObjectToWorldMatrix()"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta deleted file mode 100644 index 7d008d9d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ObjectToWorldMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a0c0180a327eba54c832fbb695dd282f -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs deleted file mode 100644 index a80058d2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Projection Matrix", "Matrix Transform", "Current projection matrix" )] - public sealed class ProjectionMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_P"; - m_drawPreview = false; - m_matrixId = 1; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta deleted file mode 100644 index 5f2d19b1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ProjectionMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 008fd07cf3f9a7140a9e23be43733f7c -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs deleted file mode 100644 index 4f568726..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Texture 0 Matrix", "Matrix Transform", "Texture 0 Matrix", null, UnityEngine.KeyCode.None, true, true )] - public sealed class Texture0MatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_TEXTURE0"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta deleted file mode 100644 index fbdf6114..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture0MatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f57a1d05f7a9c5847912566ff1605c6d -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs deleted file mode 100644 index a9debbe5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Texture 1 Matrix", "Matrix Transform", "Texture 1 Matrix", null, UnityEngine.KeyCode.None, true, true )] - public sealed class Texture1MatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_TEXTURE1"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta deleted file mode 100644 index 429b1082..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture1MatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9ef360a7c6005ad479d7a3e6db1d32f4 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs deleted file mode 100644 index c0938e7a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Texture 2 Matrix", "Matrix Transform", "Texture 2 Matrix", null, UnityEngine.KeyCode.None, true, true )] - public sealed class Texture2MatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_TEXTURE2"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta deleted file mode 100644 index dc1e0080..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture2MatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6cf4950dda0f6e6438ace404fbef19a7 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs deleted file mode 100644 index 8b5f86ae..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Texture 3 Matrix", "Matrix Transform", "Texture 3 Matrix", null, UnityEngine.KeyCode.None, true, true )] - public sealed class Texture3MatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_TEXTURE3"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta deleted file mode 100644 index 00df6e3e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/Texture3MatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 02a9fb7a3a104974e941f4109567b97f -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs deleted file mode 100644 index bc7ee22a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs +++ /dev/null @@ -1,560 +0,0 @@ -// 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 InverseTangentType - { - Fast, - Precise - } - - [Serializable] - [NodeAttributes( "Transform Direction", "Vector Operators", "Transforms a direction vector from one space to another" )] - public sealed class TransformDirectionNode : ParentNode - { - - [SerializeField] - private TransformSpaceFrom m_from = TransformSpaceFrom.Object; - - [SerializeField] - private TransformSpaceTo m_to = TransformSpaceTo.World; - - [SerializeField] - private bool m_normalize = false; - - [SerializeField] - private InverseTangentType m_inverseTangentType = InverseTangentType.Fast; - - private string InverseTBNStr = "Inverse TBN"; - - private const string NormalizeOptionStr = "Normalize"; - private const string NormalizeFunc = "normalize( {0} )"; - - private const string AseObjectToWorldDirVarName = "objToWorldDir"; - private const string AseObjectToWorldDirFormat = "mul( unity_ObjectToWorld, float4( {0}, 0 ) ).xyz"; - private const string AseSRPObjectToWorldDirFormat = "mul( GetObjectToWorldMatrix(), float4( {0}, 0 ) ).xyz"; - - private const string AseObjectToViewDirVarName = "objToViewDir"; - private const string AseObjectToViewDirFormat = "mul( UNITY_MATRIX_IT_MV, float4( {0}, 0 ) ).xyz"; - private const string AseHDObjectToViewDirFormat = "TransformWorldToViewDir( TransformObjectToWorldDir( {0} ))"; - - private const string AseWorldToObjectDirVarName = "worldToObjDir"; - private const string AseWorldToObjectDirFormat = "mul( unity_WorldToObject, float4( {0}, 0 ) ).xyz"; - private const string AseSRPWorldToObjectDirFormat = "mul( GetWorldToObjectMatrix(), float4( {0}, 0 ) ).xyz"; - - - private const string AseWorldToViewDirVarName = "worldToViewDir"; - private const string AseWorldToViewDirFormat = "mul( UNITY_MATRIX_V, float4( {0}, 0 ) ).xyz"; - - private const string AseViewToObjectDirVarName = "viewToObjDir"; - private const string AseViewToObjectDirFormat = "mul( UNITY_MATRIX_T_MV, float4( {0}, 0 ) ).xyz"; - - private const string AseViewToWorldDirVarName = "viewToWorldDir"; - private const string AseViewToWorldDirFormat = "mul( UNITY_MATRIX_I_V, float4( {0}, 0 ) ).xyz"; - - /////////////////////////////////////////////////////////// - private const string AseObjectToClipDirVarName = "objectToClipDir"; - private const string AseObjectToClipDirFormat = "mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, float4({0}, 0.0)))"; - private const string AseSRPObjectToClipDirFormat = "TransformWorldToHClipDir(TransformObjectToWorldDir({0}))"; - - private const string AseWorldToClipDirVarName = "worldToClipDir"; - private const string AseWorldToClipDirFormat = "mul(UNITY_MATRIX_VP, float4({0}, 0.0))"; - private const string AseSRPWorldToClipDirFormat = "TransformWorldToHClipDir({0})"; - - private const string AseViewToClipDirVarName = "viewToClipDir"; - private const string AseViewToClipDirFormat = "mul(UNITY_MATRIX_P, float4({0}, 0.0))"; - private const string AseSRPViewToClipDirFormat = "mul(GetViewToHClipMatrix(), float4({0}, 1.0))"; - // - private const string AseClipToObjectDirVarName = "clipToObjectDir"; - - private const string AseClipToObjectDirFormat = "mul( UNITY_MATRIX_IT_MV, mul( unity_CameraInvProjection,float4({0},0)) ).xyz"; - private const string AseClipToWorldDirFormat = "mul( UNITY_MATRIX_I_V, mul( unity_CameraInvProjection,float4({0},0)) ).xyz"; - private const string AseClipToViewDirFormat = " mul( unity_CameraInvProjection,float4({0},0)).xyz"; - private const string AseHDClipToObjectDirFormat = "mul( UNITY_MATRIX_I_M, mul( UNITY_MATRIX_I_VP,float4({0},0)) ).xyz"; - - private const string AseClipToWorldDirVarName = "clipToWorldDir"; - private const string AseHDClipToWorldDirFormat = "mul( UNITY_MATRIX_I_VP, float4({0},0) ).xyz"; - - private const string AseClipToViewDirVarName = "clipToViewDir"; - private const string AseHDClipToViewDirFormat = " mul( UNITY_MATRIX_I_P,float4({0},0)).xyz"; - private const string AseClipToNDC = "{0}.xyz/{0}.w"; - - ///////////////////////////////////////////////////// - private const string AseObjectToTangentDirVarName = "objectToTangentDir"; - private const string AseWorldToTangentDirVarName = "worldToTangentDir"; - private const string AseViewToTangentDirVarName = "viewToTangentDir"; - private const string AseClipToTangentDirVarName = "clipToTangentDir"; - private const string ASEWorldToTangentFormat = "mul( ase_worldToTangent, {0})"; - - - private const string AseTangentToObjectDirVarName = "tangentTobjectDir"; - private const string AseTangentToWorldDirVarName = "tangentToWorldDir"; - private const string AseTangentToViewDirVarName = "tangentToViewDir"; - private const string AseTangentToClipDirVarName = "tangentToClipDir"; - private const string ASEMulOpFormat = "mul( {0}, {1} )"; - - - - /////////////////////////////////////////////////////////// - private const string FromStr = "From"; - private const string ToStr = "To"; - private const string SubtitleFormat = "{0} to {1}"; - - private readonly string[] m_spaceOptionsFrom = - { - "Object", - "World", - "View", - "Tangent" - }; - - private readonly string[] m_spaceOptionsTo = - { - "Object", - "World", - "View", - "Tangent", - "Clip" - }; - - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, Constants.EmptyPortValue ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929"; - m_textLabelWidth = 100; - UpdateSubtitle(); - } - - private void UpdateSubtitle() - { - SetAdditonalTitleText( string.Format( SubtitleFormat, m_from, m_to ) ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_from = (TransformSpaceFrom)EditorGUILayoutPopup( FromStr, (int)m_from, m_spaceOptionsFrom ); - m_to = (TransformSpaceTo)EditorGUILayoutPopup( ToStr, (int)m_to, m_spaceOptionsTo ); - if( m_from == TransformSpaceFrom.Tangent ) - { - m_inverseTangentType = (InverseTangentType)EditorGUILayoutEnumPopup( InverseTBNStr, m_inverseTangentType ); - } - - m_normalize = EditorGUILayoutToggle( NormalizeOptionStr, m_normalize ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateSubtitle(); - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( (int)m_from != (int)m_to && ( m_from == TransformSpaceFrom.Tangent || m_to == TransformSpaceTo.Tangent ) ) - dataCollector.DirtyNormal = true; - } - - void CalculateTransform( TransformSpaceFrom from, TransformSpaceTo to, ref MasterNodeDataCollector dataCollector, ref string varName, ref string result ) - { - switch( from ) - { - case TransformSpaceFrom.Object: - { - switch( to ) - { - default: case TransformSpaceTo.Object: break; - case TransformSpaceTo.World: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - result = string.Format( AseSRPObjectToWorldDirFormat, result ); - else - result = string.Format( AseObjectToWorldDirFormat, result ); - varName = AseObjectToWorldDirVarName + OutputId; - } - break; - case TransformSpaceTo.View: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - result = string.Format( AseHDObjectToViewDirFormat, result ); - else - result = string.Format( AseObjectToViewDirFormat, result ); - varName = AseObjectToViewDirVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPObjectToClipDirFormat, result ); - } - else - { - result = string.Format( AseObjectToClipDirFormat, result ); - } - varName = AseObjectToClipDirVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.World: - { - switch( to ) - { - case TransformSpaceTo.Object: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - result = string.Format( AseSRPWorldToObjectDirFormat, result ); - else - result = string.Format( AseWorldToObjectDirFormat, result ); - varName = AseWorldToObjectDirVarName + OutputId; - } - break; - default: - case TransformSpaceTo.World: break; - case TransformSpaceTo.View: - { - result = string.Format( AseWorldToViewDirFormat, result ); - varName = AseWorldToViewDirVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPWorldToClipDirFormat, result ); - } - else - { - result = string.Format( AseWorldToClipDirFormat, result ); - } - varName = AseWorldToClipDirVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.View: - { - switch( to ) - { - case TransformSpaceTo.Object: - { - result = string.Format( AseViewToObjectDirFormat, result ); - varName = AseViewToObjectDirVarName + OutputId; - } - break; - case TransformSpaceTo.World: - { - result = string.Format( AseViewToWorldDirFormat, result ); - varName = AseViewToWorldDirVarName + OutputId; - } - break; - default: case TransformSpaceTo.View: break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPViewToClipDirFormat, result ); - } - else - { - result = string.Format( AseViewToClipDirFormat, result ); - } - varName = AseViewToClipDirVarName + OutputId; - } - break; - } - } - break; - //case TransformSpace.Clip: - //{ - // switch( to ) - // { - // case TransformSpace.Object: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToObjectDirFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToObjectDirFormat, result ); - // } - // varName = AseClipToObjectDirVarName + OutputId; - // } - // break; - // case TransformSpace.World: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToWorldDirFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToWorldDirFormat, result ); - // } - // varName = AseClipToWorldDirVarName + OutputId; - // } - // break; - // case TransformSpace.View: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToViewDirFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToViewDirFormat, result ); - // } - // varName = AseClipToViewDirVarName + OutputId; - // } - // break; - // case TransformSpace.Clip: break; - // default: - // break; - // } - //} - //break; - default: break; - } - } - - 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 ) ); - - GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector ); - - string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string varName = string.Empty; - - if( (int)m_from == (int)m_to ) - { - RegisterLocalVariable( 0, result, ref dataCollector ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - switch( m_from ) - { - case TransformSpaceFrom.Object: - { - switch( m_to ) - { - default: case TransformSpaceTo.Object: break; - case TransformSpaceTo.World: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.View: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseObjectToTangentDirVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.World: - { - switch( m_to ) - { - case TransformSpaceTo.Object: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - default: - case TransformSpaceTo.World: break; - case TransformSpaceTo.View: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseWorldToTangentDirVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.View: - { - switch( m_to ) - { - case TransformSpaceTo.Object: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.World: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - default: case TransformSpaceTo.View: break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseViewToTangentDirVarName + OutputId; - } - break; - } - } - break; - //case TransformSpace.Clip: - //{ - // switch( m_to ) - // { - // case TransformSpace.Object: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.World: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.View: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.Clip: break; - // case TransformSpace.Tangent: - // { - // GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - // CalculateTransform( m_from, TransformSpace.World, ref dataCollector, ref varName, ref result ); - // result = string.Format( ASEWorldToTangentFormat, result ); - // varName = AseClipToTangentDirVarName + OutputId; - // } - // break; - // default: - // break; - // } - //}break; - case TransformSpaceFrom.Tangent: - { - string matrixVal = string.Empty; - if( m_inverseTangentType == InverseTangentType.Fast ) - matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast( ref dataCollector, UniqueId, CurrentPrecisionType ); - else - matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise( ref dataCollector, UniqueId, CurrentPrecisionType ); - - switch( m_to ) - { - case TransformSpaceTo.Object: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToObjectDirVarName + OutputId; - } - break; - case TransformSpaceTo.World: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - varName = AseTangentToWorldDirVarName + OutputId; - } - break; - case TransformSpaceTo.View: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToViewDirVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToClipDirVarName + OutputId; - } - break; - case TransformSpaceTo.Tangent: - default: - break; - } - } - break; - default: break; - } - - if( m_normalize ) - result = string.Format( NormalizeFunc, result ); - - RegisterLocalVariable( 0, result, ref dataCollector, varName ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string from = GetCurrentParam( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 17500 && from.Equals( "Clip" ) ) - { - UIUtils.ShowMessage( UniqueId, "Clip Space no longer supported on From field over Transform Direction node" ); - } - else - { - m_from = (TransformSpaceFrom)Enum.Parse( typeof( TransformSpaceFrom ), from ); - } - m_to = (TransformSpaceTo)Enum.Parse( typeof( TransformSpaceTo ), GetCurrentParam( ref nodeParams ) ); - m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15800 ) - { - m_inverseTangentType = (InverseTangentType)Enum.Parse( typeof( InverseTangentType ), GetCurrentParam( ref nodeParams ) ); - } - UpdateSubtitle(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_from ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_to ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalize ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inverseTangentType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta deleted file mode 100644 index 123dc9ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformDirectionNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5088261e4c0031f4aba961a253707b80 -timeCreated: 1525857790 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs deleted file mode 100644 index 850f1a51..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs +++ /dev/null @@ -1,620 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Transform Position", "Object Transform", "Transforms a position value from one space to another" )] - public sealed class TransformPositionNode : ParentNode - { - [SerializeField] - private TransformSpaceFrom m_from = TransformSpaceFrom.Object; - - [SerializeField] - private TransformSpaceTo m_to = TransformSpaceTo.World; - - [SerializeField] - private bool m_perspectiveDivide = false; - - [SerializeField] - private InverseTangentType m_inverseTangentType = InverseTangentType.Fast; - - [SerializeField] - private bool m_absoluteWorldPos = true; - - private const string AbsoluteWorldPosStr = "Absolute"; - - private string InverseTBNStr = "Inverse TBN"; - - private const string AseObjectToWorldPosVarName = "objToWorld"; - private const string AseObjectToWorldPosFormat = "mul( unity_ObjectToWorld, float4( {0}, 1 ) ).xyz"; - private const string AseHDObjectToWorldPosFormat = "mul( GetObjectToWorldMatrix(), float4( {0}, 1 ) ).xyz"; - private const string ASEHDAbsoluteWordPos = "GetAbsolutePositionWS({0})"; - private const string ASEHDRelaviveCameraPos = "GetCameraRelativePositionWS({0})"; - private const string AseObjectToViewPosVarName = "objToView"; - private const string AseObjectToViewPosFormat = "mul( UNITY_MATRIX_MV, float4( {0}, 1 ) ).xyz"; - private const string AseHDObjectToViewPosFormat = "TransformWorldToView( TransformObjectToWorld({0}) )"; - - private const string AseWorldToObjectPosVarName = "worldToObj"; - private const string AseWorldToObjectPosFormat = "mul( unity_WorldToObject, float4( {0}, 1 ) ).xyz"; - private const string AseSRPWorldToObjectPosFormat = "mul( GetWorldToObjectMatrix(), float4( {0}, 1 ) ).xyz"; - - - private const string AseWorldToViewPosVarName = "worldToView"; - private const string AseWorldToViewPosFormat = "mul( UNITY_MATRIX_V, float4( {0}, 1 ) ).xyz"; - - private const string AseViewToObjectPosVarName = "viewToObj"; - private const string AseViewToObjectPosFormat = "mul( unity_WorldToObject, mul( UNITY_MATRIX_I_V , float4( {0}, 1 ) ) ).xyz"; - private const string AseHDViewToObjectPosFormat = "mul( GetWorldToObjectMatrix(), mul( UNITY_MATRIX_I_V , float4( {0}, 1 ) ) ).xyz"; - - private const string AseViewToWorldPosVarName = "viewToWorld"; - private const string AseViewToWorldPosFormat = "mul( UNITY_MATRIX_I_V, float4( {0}, 1 ) ).xyz"; - - /////////////////////////////////////////////////////////// - private const string AseObjectToClipPosVarName = "objectToClip"; - private const string AseObjectToClipPosFormat = "UnityObjectToClipPos({0})"; - private const string AseSRPObjectToClipPosFormat = "TransformWorldToHClip(TransformObjectToWorld({0}))"; - - private const string AseWorldToClipPosVarName = "worldToClip"; - private const string AseWorldToClipPosFormat = "mul(UNITY_MATRIX_VP, float4({0}, 1.0))"; - private const string AseSRPWorldToClipPosFormat = "TransformWorldToHClip({0})"; - - private const string AseViewToClipPosVarName = "viewToClip"; - private const string AseViewToClipPosFormat = "mul(UNITY_MATRIX_P, float4({0}, 1.0))"; - private const string AseSRPViewToClipPosFormat = "TransformWViewToHClip({0})"; - // - - private const string AseClipToObjectPosVarName = "clipToObject"; - private const string AseClipToObjectPosFormat = "mul( UNITY_MATRIX_IT_MV, mul( unity_CameraInvProjection,float4({0},1)) ).xyz"; - private const string AseHDClipToObjectPosFormat = "mul( UNITY_MATRIX_I_M, mul( UNITY_MATRIX_I_VP,float4({0},1)) ).xyz"; - - private const string AseClipToWorldPosVarName = "clipToWorld"; - private const string AseClipToWorldPosFormat = "mul( UNITY_MATRIX_I_V, mul( unity_CameraInvProjection,float4({0},1)) ).xyz"; - private const string AseHDClipToWorldPosFormat = "mul( UNITY_MATRIX_I_VP, float4({0},1) ).xyz"; - - private const string AseClipToViewPosVarName = "clipToView"; - private const string AseClipToViewPosFormat = " mul( unity_CameraInvProjection,float4({0},1)).xyz"; - private const string AseHDClipToViewPosFormat = " mul( UNITY_MATRIX_I_P,float4({0},1)).xyz"; - private const string AseClipToNDC = "{0}.xyz/{0}.w"; - ///////////////////////////////////////////////////// - private const string AseObjectToTangentPosVarName = "objectToTangentPos"; - private const string AseWorldToTangentPosVarName = "worldToTangentPos"; - private const string AseViewToTangentPosVarName = "viewToTangentPos"; - private const string AseClipToTangentPosVarName = "clipToTangentPos"; - private const string ASEWorldToTangentFormat = "mul( ase_worldToTangent, {0})"; - - - private const string AseTangentToObjectPosVarName = "tangentTobjectPos"; - private const string AseTangentToWorldPosVarName = "tangentToWorldPos"; - private const string AseTangentToViewPosVarName = "tangentToViewPos"; - private const string AseTangentToClipPosVarName = "tangentToClipPos"; - private const string ASEMulOpFormat = "mul( {0}, {1} )"; - - - /////////////////////////////////////////////////////////// - private const string FromStr = "From"; - private const string ToStr = "To"; - private const string PerpectiveDivideStr = "Perpective Divide"; - private const string SubtitleFormat = "{0} to {1}"; - - private readonly string[] m_spaceOptionsFrom = - { - "Object", - "World", - "View", - "Tangent" - }; - - private readonly string[] m_spaceOptionsTo = - { - "Object", - "World", - "View", - "Tangent", - "Clip" - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, Constants.EmptyPortValue ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929"; - m_textLabelWidth = 120; - UpdateSubtitle(); - } - - private void UpdateSubtitle() - { - SetAdditonalTitleText( string.Format( SubtitleFormat, m_from, m_to ) ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_from = (TransformSpaceFrom)EditorGUILayoutPopup( FromStr, (int)m_from, m_spaceOptionsFrom ); - m_to = (TransformSpaceTo)EditorGUILayoutPopup( ToStr, (int)m_to, m_spaceOptionsTo ); - if( m_from == TransformSpaceFrom.Tangent ) - { - m_inverseTangentType = (InverseTangentType)EditorGUILayoutEnumPopup( InverseTBNStr, m_inverseTangentType ); - } - if( EditorGUI.EndChangeCheck() ) - { - UpdateSubtitle(); - } - - if( m_to == TransformSpaceTo.Clip ) - { - m_perspectiveDivide = EditorGUILayoutToggle( PerpectiveDivideStr, m_perspectiveDivide ); - } - - //if( m_containerGraph.IsHDRP && ( m_from == TransformSpace.Object && m_to == TransformSpace.World ) || - // ( m_from == TransformSpace.World && m_to == TransformSpace.Object ) ) - //{ - // m_absoluteWorldPos = EditorGUILayoutToggle( AbsoluteWorldPosStr, m_absoluteWorldPos ); - //} - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( (int)m_from != (int)m_to && ( m_from == TransformSpaceFrom.Tangent || m_to == TransformSpaceTo.Tangent ) ) - dataCollector.DirtyNormal = true; - } - - void CalculateTransform( TransformSpaceFrom from, TransformSpaceTo to, ref MasterNodeDataCollector dataCollector, ref string varName, ref string result ) - { - switch( from ) - { - case TransformSpaceFrom.Object: - { - switch( to ) - { - default: - case TransformSpaceTo.Object: break; - case TransformSpaceTo.World: - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - { - result = string.Format( AseHDObjectToWorldPosFormat, result ); - if( m_absoluteWorldPos ) - { - result = string.Format( ASEHDAbsoluteWordPos, result ); - } - } - else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight ) - { - result = string.Format( AseHDObjectToWorldPosFormat, result ); - } - } - else - result = string.Format( AseObjectToWorldPosFormat, result ); - - - varName = AseObjectToWorldPosVarName + OutputId; - } - break; - case TransformSpaceTo.View: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - result = string.Format( AseHDObjectToViewPosFormat, result ); - else - result = string.Format( AseObjectToViewPosFormat, result ); - varName = AseObjectToViewPosVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPObjectToClipPosFormat, result ); - } - else - { - result = string.Format( AseObjectToClipPosFormat, result ); - } - varName = AseObjectToClipPosVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.World: - { - switch( to ) - { - case TransformSpaceTo.Object: - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - { - if( m_absoluteWorldPos ) - { - result = string.Format( ASEHDRelaviveCameraPos, result ); - } - result = string.Format( AseSRPWorldToObjectPosFormat, result ); - } - else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight ) - { - result = string.Format( AseSRPWorldToObjectPosFormat, result ); - } - - } - else - result = string.Format( AseWorldToObjectPosFormat, result ); - varName = AseWorldToObjectPosVarName + OutputId; - } - break; - default: - case TransformSpaceTo.World: break; - case TransformSpaceTo.View: - { - result = string.Format( AseWorldToViewPosFormat, result ); - varName = AseWorldToViewPosVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPWorldToClipPosFormat, result ); - } - else - { - result = string.Format( AseWorldToClipPosFormat, result ); - } - varName = AseWorldToClipPosVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.View: - { - switch( to ) - { - case TransformSpaceTo.Object: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - result = string.Format( AseHDViewToObjectPosFormat, result ); - else - result = string.Format( AseViewToObjectPosFormat, result ); - varName = AseViewToObjectPosVarName + OutputId; - } - break; - case TransformSpaceTo.World: - { - result = string.Format( AseViewToWorldPosFormat, result ); - varName = AseViewToWorldPosVarName + OutputId; - } - break; - default: - case TransformSpaceTo.View: break; - case TransformSpaceTo.Clip: - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - result = string.Format( AseSRPViewToClipPosFormat, result ); - } - else - { - result = string.Format( AseViewToClipPosFormat, result ); - } - varName = AseViewToClipPosVarName + OutputId; - } - break; - } - } - break; - //case TransformSpace.Clip: - //{ - // switch( to ) - // { - // case TransformSpace.Object: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToObjectPosFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToObjectPosFormat, result ); - // } - // varName = AseClipToObjectPosVarName + OutputId; - // } - // break; - // case TransformSpace.World: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToWorldPosFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToWorldPosFormat, result ); - // } - // varName = AseClipToWorldPosVarName + OutputId; - // } - // break; - // case TransformSpace.View: - // { - // if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - // { - // result = string.Format( AseHDClipToViewPosFormat, result ); - // } - // else - // { - // result = string.Format( AseClipToViewPosFormat, result ); - // } - // varName = AseClipToViewPosVarName + OutputId; - // } - // break; - // case TransformSpace.Clip: break; - // default: - // break; - // } - //} - //break; - default: break; - } - } - - 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 ) ); - - GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector ); - - string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string varName = string.Empty; - - if( (int)m_from == (int)m_to ) - { - RegisterLocalVariable( 0, result, ref dataCollector ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - switch( m_from ) - { - case TransformSpaceFrom.Object: - { - switch( m_to ) - { - default: - case TransformSpaceTo.Object: break; - case TransformSpaceTo.World: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.View: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseObjectToTangentPosVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.World: - { - switch( m_to ) - { - case TransformSpaceTo.Object: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - default: - case TransformSpaceTo.World: break; - case TransformSpaceTo.View: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseWorldToTangentPosVarName + OutputId; - } - break; - } - } - break; - case TransformSpaceFrom.View: - { - switch( m_to ) - { - case TransformSpaceTo.Object: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.World: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); ; - } - break; - default: - case TransformSpaceTo.View: break; - case TransformSpaceTo.Clip: - { - CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - } - break; - case TransformSpaceTo.Tangent: - { - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - CalculateTransform( m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result ); - result = string.Format( ASEWorldToTangentFormat, result ); - varName = AseViewToTangentPosVarName + OutputId; - } - break; - } - } - break; - //case TransformSpace.Clip: - //{ - // switch( m_to ) - // { - // case TransformSpace.Object: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.World: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.View: - // { - // CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result ); - // } - // break; - // case TransformSpace.Clip: break; - // case TransformSpace.Tangent: - // { - // GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - // CalculateTransform( m_from, TransformSpace.World, ref dataCollector, ref varName, ref result ); - // result = string.Format( ASEWorldToTangentFormat, result ); - // varName = AseClipToTangentPosVarName + OutputId; - // } - // break; - // default: - // break; - // } - //} - //break; - case TransformSpaceFrom.Tangent: - { - string matrixVal = string.Empty; - if( m_inverseTangentType == InverseTangentType.Fast ) - matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast( ref dataCollector, UniqueId, CurrentPrecisionType ); - else - matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise( ref dataCollector, UniqueId, CurrentPrecisionType ); - - switch( m_to ) - { - case TransformSpaceTo.Object: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToObjectPosVarName + OutputId; - } - break; - case TransformSpaceTo.World: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - varName = AseTangentToWorldPosVarName + OutputId; - } - break; - case TransformSpaceTo.View: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToViewPosVarName + OutputId; - } - break; - case TransformSpaceTo.Clip: - { - result = string.Format( ASEMulOpFormat, matrixVal, result ); - CalculateTransform( TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result ); - varName = AseTangentToClipPosVarName + OutputId; - } - break; - case TransformSpaceTo.Tangent: - default: - break; - } - } - break; - default: break; - } - - if( m_to == TransformSpaceTo.Clip ) - { - if( m_perspectiveDivide ) - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, varName, result ); - result = string.Format( AseClipToNDC, varName ); - varName += "NDC"; - } - else - { - result += ".xyz"; - } - } - - RegisterLocalVariable( 0, result, ref dataCollector, varName ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string from = GetCurrentParam( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 17500 && from.Equals( "Clip" ) ) - { - UIUtils.ShowMessage( UniqueId, "Clip Space no longer supported on From field over Transform Position node" ); - } - else - { - m_from = (TransformSpaceFrom)Enum.Parse( typeof( TransformSpaceFrom ), from ); - } - m_to = (TransformSpaceTo)Enum.Parse( typeof( TransformSpaceTo ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15701 ) - { - m_perspectiveDivide = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 15800 ) - { - m_inverseTangentType = (InverseTangentType)Enum.Parse( typeof( InverseTangentType ), GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 16103 ) - { - m_absoluteWorldPos = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - UpdateSubtitle(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_from ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_to ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_perspectiveDivide ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inverseTangentType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_absoluteWorldPos ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta deleted file mode 100644 index 84e1fcd2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformPositionNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 274dde08d42e4b041b9be7a22a8c09d6 -timeCreated: 1525857790 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs deleted file mode 100644 index 1802fe55..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum BuiltInShaderTransformTypes - { - UNITY_MATRIX_MVP = 0, - UNITY_MATRIX_MV, - UNITY_MATRIX_V, - UNITY_MATRIX_P, - UNITY_MATRIX_VP, - UNITY_MATRIX_T_MV, - UNITY_MATRIX_IT_MV, - //UNITY_MATRIX_TEXTURE0, - //UNITY_MATRIX_TEXTURE1, - //UNITY_MATRIX_TEXTURE2, - //UNITY_MATRIX_TEXTURE3, - _Object2World, - _World2Object//, - //unity_Scale - } - - [Serializable] - [NodeAttributes( "Common Transform Matrices", "Matrix Transform", "All Transformation types" )] - public sealed class TransformVariables : ShaderVariablesNode - { - [SerializeField] - private BuiltInShaderTransformTypes m_selectedType = BuiltInShaderTransformTypes.UNITY_MATRIX_MVP; - - private const string MatrixLabelStr = "Matrix"; - private readonly string[] ValuesStr = - { - "Model View Projection", - "Model View", - "View", - "Projection", - "View Projection", - "Transpose Model View", - "Inverse Transpose Model View", - "Object to World", - "Word to Object" - }; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, ValuesStr[ ( int ) m_selectedType ], WirePortDataType.FLOAT4x4 ); - m_textLabelWidth = 60; - m_hasLeftDropdown = true; - m_autoWrapProperties = true; - m_drawPreview = false; - } - - 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 Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_selectedType = (BuiltInShaderTransformTypes)m_upperLeftWidget.DrawWidget( this, (int)m_selectedType, ValuesStr ); - if( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, ValuesStr[ (int)m_selectedType ] ); - m_sizeIsDirty = true; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_selectedType = ( BuiltInShaderTransformTypes ) EditorGUILayoutPopup( MatrixLabelStr, ( int ) m_selectedType, ValuesStr ); - if ( EditorGUI.EndChangeCheck() ) - { - ChangeOutputName( 0, ValuesStr[ ( int ) m_selectedType ] ); - m_sizeIsDirty = true; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - switch( m_selectedType ) - { - case BuiltInShaderTransformTypes.UNITY_MATRIX_MVP: - return "mul(GetWorldToHClipMatrix(),GetObjectToWorldMatrix())"; - case BuiltInShaderTransformTypes.UNITY_MATRIX_MV: - return "mul( GetWorldToViewMatrix(),GetObjectToWorldMatrix())"; - case BuiltInShaderTransformTypes.UNITY_MATRIX_V: - return "GetWorldToViewMatrix()"; - case BuiltInShaderTransformTypes.UNITY_MATRIX_P: - return "GetViewToHClipMatrix()"; - case BuiltInShaderTransformTypes.UNITY_MATRIX_VP: - return "GetWorldToHClipMatrix()"; - case BuiltInShaderTransformTypes._Object2World: - return "GetObjectToWorldMatrix()"; - case BuiltInShaderTransformTypes._World2Object: - return "GetWorldToObjectMatrix()"; - case BuiltInShaderTransformTypes.UNITY_MATRIX_T_MV: - case BuiltInShaderTransformTypes.UNITY_MATRIX_IT_MV: - default: - { - UIUtils.ShowMessage( UniqueId, "Matrix not declared natively on SRP. Must create it manually inside ASE" ); - return "float4x4(" + - "1,0,0,0," + - "0,1,0,0," + - "0,0,1,0," + - "0,0,0,1)"; - } - } - } - else - { - return m_selectedType.ToString(); - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string selectedTypeStr = GetCurrentParam( ref nodeParams ); - try - { - BuiltInShaderTransformTypes selectedType = (BuiltInShaderTransformTypes)Enum.Parse( typeof( BuiltInShaderTransformTypes ), selectedTypeStr ); - m_selectedType = selectedType; - } - catch( Exception e ) - { - switch( selectedTypeStr ) - { - default: Debug.LogException( e );break; - case "UNITY_MATRIX_TEXTURE0":UIUtils.ShowMessage( UniqueId, "Texture 0 matrix is no longer supported",MessageSeverity.Warning);break; - case "UNITY_MATRIX_TEXTURE1":UIUtils.ShowMessage( UniqueId, "Texture 1 matrix is no longer supported",MessageSeverity.Warning);break; - case "UNITY_MATRIX_TEXTURE2":UIUtils.ShowMessage( UniqueId, "Texture 2 matrix is no longer supported",MessageSeverity.Warning);break; - case "UNITY_MATRIX_TEXTURE3":UIUtils.ShowMessage( UniqueId, "Texture 3 matrix is no longer supported",MessageSeverity.Warning); break; - case "unity_Scale": UIUtils.ShowMessage( UniqueId, "Scale matrix is no longer supported", MessageSeverity.Warning ); break; - } - } - - ChangeOutputName( 0, ValuesStr[ ( int ) m_selectedType ] ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta deleted file mode 100644 index d0e613af..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransformVariables.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 04aad5172ee1d4d4795e20bfae0ff64d -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs deleted file mode 100644 index c7c46fe8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Transpose Model View Matrix", "Matrix Transform", "Transpose of model * view matrix" )] - public sealed class TransposeMVMatrix : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_T_MV"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta deleted file mode 100644 index 871d6018..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/TransposeMVMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5762b195353d629448631bfb15fb8372 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs deleted file mode 100644 index 09325ec7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Projector Clip Matrix", "Matrix Transform", "Current Projector Clip matrix. To be used when working with Unity projector." )] - public sealed class UnityProjectorClipMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_ProjectorClip"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - dataCollector.AddToUniforms( UniqueId, "float4x4 unity_ProjectorClip;" ); - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta deleted file mode 100644 index 6bc17bde..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorClipMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6095e3e4dc186f146bc109813901ccc8 -timeCreated: 1512062884 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs deleted file mode 100644 index 4cfb63c8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Projector Matrix", "Matrix Transform", "Current Projector Clip matrix. To be used when working with Unity projector." )] - public sealed class UnityProjectorMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_Projector"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - dataCollector.AddToUniforms( UniqueId, "float4x4 unity_Projector;" ); - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta deleted file mode 100644 index 0a62ab9f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityProjectorMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c3efd02b48473d94b92302654b671ddc -timeCreated: 1512062884 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs deleted file mode 100644 index 2d2f00c9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Scale Matrix", "Matrix Transform", "Scale Matrix",null, UnityEngine.KeyCode.None, true, true, "Object Scale" )] - public sealed class UnityScaleMatrix : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_Scale"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta deleted file mode 100644 index 26f2df76..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/UnityScaleMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 28a04286716e19f4aa58954888374428 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs deleted file mode 100644 index 2291bc32..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "View Matrix", "Matrix Transform", "Current view matrix" )] - public sealed class ViewMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_V"; - m_drawPreview = false; - m_matrixId = 0; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta deleted file mode 100644 index bcfb2edc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5aa75cc5e6044a44a9a4439eac1d948b -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs deleted file mode 100644 index 23e53e40..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "View Projection Matrix", "Matrix Transform", "Current view * projection matrix." )] - public sealed class ViewProjectionMatrixNode : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "UNITY_MATRIX_VP"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta deleted file mode 100644 index 1a1cd1c4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/ViewProjectionMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fe26c99932382e047aebc05b7e67a3d0 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs deleted file mode 100644 index 65d9e082..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "World To Camera Matrix", "Matrix Transform", "Inverse of current camera to world matrix" )] - public sealed class WorldToCameraMatrix : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_WorldToCamera"; - m_drawPreview = false; - } - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GeneratorUtils.RegisterUnity2019MatrixDefines( ref dataCollector ); - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta deleted file mode 100644 index a8d0b7a1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToCameraMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 584bea5554dc1b64c8965d8fcfc54e23 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs deleted file mode 100644 index dd82ebb1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "World To Object Matrix", "Matrix Transform", "Inverse of current world matrix" )] - public sealed class WorldToObjectMatrix : ConstantShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputProperties( 0, "Out", WirePortDataType.FLOAT4x4 ); - m_value = "unity_WorldToObject"; - m_HDValue = "GetWorldToObjectMatrix()"; - m_LWValue = "GetWorldToObjectMatrix()"; - m_drawPreview = false; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta deleted file mode 100644 index dd284eb7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToObjectMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d9e2a5077cc29de439d5c845eac35a04 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs deleted file mode 100644 index 194802ef..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World To Tangent Matrix", "Matrix Transform", "World to tangent transform matrix" )] - public sealed class WorldToTangentMatrix : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.FLOAT3x3, "Out" ); - //UIUtils.AddNormalDependentCount(); - m_drawPreview = false; - } - - //public override void Destroy() - //{ - // ContainerGraph.RemoveNormalDependentCount(); - // base.Destroy(); - //} - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if( dataCollector.IsTemplate ) - return dataCollector.TemplateDataCollectorInstance.GetWorldToTangentMatrix( CurrentPrecisionType ); - - if( dataCollector.IsFragmentCategory ) - { - dataCollector.ForceNormal = true; - - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - - return GeneratorUtils.WorldToTangentStr; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta deleted file mode 100644 index ed19db78..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Transform/WorldToTangentMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b598d9ebc2d7be44a97270732f55f9bc -timeCreated: 1484747592 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta deleted file mode 100644 index 89ede46c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 5bbb49ec7f4a3524d9950847c88d4afc -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs deleted file mode 100644 index 231a0111..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Color Space Double", "Miscellaneous", "Color Space Double" )] - public class ColorSpaceDouble : ParentNode - { - private const string ColorSpaceDoubleStr = "unity_ColorSpaceDouble"; - - private readonly string[] ColorSpaceDoubleDef = - { - "#ifdef UNITY_COLORSPACE_GAMMA//ASE Color Space Def", - "#define unity_ColorSpaceDouble half4(2.0, 2.0, 2.0, 2.0)//ASE Color Space Def", - "#else // Linear values//ASE Color Space Def", - "#define unity_ColorSpaceDouble half4(4.59479380, 4.59479380, 4.59479380, 2.0)//ASE Color Space Def", - "#endif//ASE Color Space Def" - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputColorPorts( "RGBA" ); - m_previewShaderGUID = "ac680a8772bb97c46851a7f075fd04e3"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - for( int i = 0; i < ColorSpaceDoubleDef.Length; i++ ) - { - dataCollector.AddToDirectives( ColorSpaceDoubleDef[ i ], -1 ); - } - } - return GetOutputVectorItem( 0, outputId, ColorSpaceDoubleStr ); ; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta deleted file mode 100644 index 32721b88..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/ColorSpaceDouble.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7d1204234983b3c4499da752961185be -timeCreated: 1481888315 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs deleted file mode 100644 index 0570939c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Face", "Vertex Data", "Indicates whether the rendered surface is facing the camera (1), or facing away from the camera(-1)" )] - public class FaceVariableNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - m_previewShaderGUID = "4b0b5b9f16353b840a5f5ad2baab3c3c"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work on Tessellation port" ); - return m_outputPorts[0].ErrorValue; - } - - if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) - { - if ( dataCollector.TesselationActive ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work properly on Vertex/Tessellation ports" ); - return m_outputPorts[ 0 ].ErrorValue; - } - else - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " node does not work propery on Vertex ports" ); - return m_outputPorts[ 0 ].ErrorValue; - } - } - - if ( dataCollector.IsTemplate ) - { - return dataCollector.TemplateDataCollectorInstance.GetVFace( UniqueId ); - } - else - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.VFACE ); - string variable = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) ? Constants.VertexShaderOutputStr : Constants.InputVarStr; - return variable + "." + Constants.VFaceVariable; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta deleted file mode 100644 index b583327e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/FaceVariableNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4b4a6f07436b05a4cbc2559e4e704000 -timeCreated: 1492513159 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs deleted file mode 100644 index c845e063..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Instance ID", "Vertex Data", "Indicates the per-instance identifier" )] - public class InstanceIdNode : ParentNode - { - private readonly string[] InstancingVariableAttrib = - { "uint currInstanceId = 0;", - "#ifdef UNITY_INSTANCING_ENABLED", - "currInstanceId = unity_InstanceID;", - "#endif"}; - private const string InstancingInnerVariable = "currInstanceId"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.INT, "Out" ); - m_previewShaderGUID = "03febce56a8cf354b90e7d5180c1dbd7"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - { - dataCollector.TemplateDataCollectorInstance.SetupInstancing(); - } - - if( !dataCollector.HasLocalVariable( InstancingVariableAttrib[ 0 ] ) ) - { - dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 0 ] ,true ); - dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 1 ] ,true ); - dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 2 ] ,true ); - dataCollector.AddLocalVariable( UniqueId, InstancingVariableAttrib[ 3 ] ,true ); - } - return InstancingInnerVariable; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta deleted file mode 100644 index efae4fb9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/InstanceIdNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c449923583a9fbe4283acebc97756ea1 -timeCreated: 1547811127 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs deleted file mode 100644 index f2a1959f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "LOD Fade", "Miscellaneous", "LODFadeNode" )] - public sealed class LODFadeNode : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "Fade[0...1]" ); - ChangeOutputName( 2, "Fade[16Lvl]" ); - ChangeOutputName( 3, "Unused" ); - ChangeOutputName( 4, "Unused" ); - m_value = "unity_LODFade"; - m_previewShaderGUID = "fcd4d93f57ffc51458d4ade10df2fdb4"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - - if( !m_outputPorts[ 3 ].IsConnected ) - { - m_outputPorts[ 3 ].Visible = false; - m_sizeIsDirty = true; - } - - if( !m_outputPorts[ 4 ].IsConnected ) - { - m_outputPorts[ 4 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta deleted file mode 100644 index a83635a4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/LODFadeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f96cf34c2936c96458403e9cf75e8e10 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs deleted file mode 100644 index b60f8472..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -#if UNITY_EDITOR_WIN -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Primitive ID", "Vertex Data", "Per-primitive identifier automatically generated by the runtime" )] - public class PrimitiveIDVariableNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.INT, "Out" ); - m_previewShaderGUID = "92c1b588d7658594cb219696f593f64b"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !dataCollector.IsTemplate ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " is not supported on surface shaders." ); - return m_outputPorts[0].ErrorValue; - } - - if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " is not supported on Vertex ports" ); - return m_outputPorts[0].ErrorValue; - } - - return dataCollector.TemplateDataCollectorInstance.GetPrimitiveId(); - } - } -} -#endif - diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta deleted file mode 100644 index 6d7d119b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/PrimitiveIdVariableNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: dd0af9fbbba750341a7b09316178f285 -timeCreated: 1492513159 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs deleted file mode 100644 index 6bfd7f36..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Switch by Face", "Miscellaneous", "Switch which automaticaly uses a Face variable to select which input to use" )] - public class SwitchByFaceNode : DynamicTypeNode - { - private const string SwitchOp = "((({0}>0)?({1}):({2})))"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "Front"; - m_inputPorts[ 1 ].Name = "Back"; - m_textLabelWidth = 50; - m_previewShaderGUID = "f4edf6febb54dc743b25bd5b56facea8"; - } - - - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work on Tessellation port" ); - return GenerateErrorValue(); - } - - if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) - { - if ( dataCollector.TesselationActive ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work properly on Vertex/Tessellation ports" ); - return GenerateErrorValue(); - } - else - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work properly on Vertex ports" ); - return GenerateErrorValue(); - } - } - - if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - string front = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string back = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - dataCollector.AddToInput( UniqueId, SurfaceInputs.VFACE ); - string variable = string.Empty; - if ( dataCollector.IsTemplate ) - { - variable = dataCollector.TemplateDataCollectorInstance.GetVFace( UniqueId ); - } - else - { - variable = ( ( dataCollector.PortCategory == MasterNodePortCategory.Vertex ) ? Constants.VertexShaderOutputStr : Constants.InputVarStr ) + "." + Constants.VFaceVariable; - } - - string value = string.Format( SwitchOp, variable, front, back ); - RegisterLocalVariable( 0, value, ref dataCollector, "switchResult" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta deleted file mode 100644 index b12692c4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/SwitchByFaceNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b0464d8b27caa7d4d8fa5d1828934da8 -timeCreated: 1492515561 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs deleted file mode 100644 index d2b75192..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Vertex ID", "Vertex Data", "Indicates current vertex number" )] - public class VertexIdVariableNode : ParentNode - { - private const string VertexIdVarName = "ase_vertexId"; - private const string VertexIdRegistry = "uint "+ VertexIdVarName + " : SV_VertexID;"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.INT, "Out" ); - m_previewShaderGUID = "5934bf2c10b127a459177a3b622cea65"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " does not work on Tessellation port" ); - return m_outputPorts[0].ErrorValue; - } - - if ( dataCollector.IsTemplate ) - { - return dataCollector.TemplateDataCollectorInstance.GetVertexId(); - } - else - { - if( dataCollector.IsFragmentCategory ) - { - GenerateValueInVertex( ref dataCollector, WirePortDataType.UINT, Constants.VertexShaderInputStr + "."+ VertexIdVarName, VertexIdVarName, true ); - return Constants.InputVarStr + "."+ VertexIdVarName; - } - else - { - return Constants.VertexShaderInputStr + "."+ VertexIdVarName; - } - } - } - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - if( !dataCollector.IsTemplate ) - dataCollector.AddCustomAppData( VertexIdRegistry ); - - base.PropagateNodeData( nodeData, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta deleted file mode 100644 index cad8fe04..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/VertexIdVariableNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ce37a30cae7677942ad44f0945ab7b77 -timeCreated: 1492513159 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs deleted file mode 100644 index 49966a09..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Transform Params", "Object Transform", "World Transform Params contains information about the transform, W is usually 1.0, or -1.0 for odd-negative scale transforms" )] - public sealed class WorldTransformParams : ConstVecShaderVariable - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeOutputName( 1, "X" ); - ChangeOutputName( 2, "Y" ); - ChangeOutputName( 3, "Z" ); - ChangeOutputName( 4, "W" ); - m_value = "unity_WorldTransformParams"; - m_previewShaderGUID = "5a2642605f085da458d6e03ade47b87a"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( !m_outputPorts[ 0 ].IsConnected ) - { - m_outputPorts[ 0 ].Visible = false; - m_sizeIsDirty = true; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta deleted file mode 100644 index b28aa84a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/ShaderVariables/Various/WorldTransformParams.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: aec376443deca354789bc36ba18af898 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs deleted file mode 100644 index 6704cbee..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs +++ /dev/null @@ -1,1197 +0,0 @@ -// Amplify Shader Editor - Visual Shader vEditing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Static Switch", "Logical Operators", "Creates a shader keyword toggle", Available = true )] - public sealed class StaticSwitch : PropertyNode - { - private float InstanceIconWidth = 19; - private float InstanceIconHeight = 19; - private readonly Color ReferenceHeaderColor = new Color( 0f, 0.5f, 0.585f, 1.0f ); - - [SerializeField] - private int m_defaultValue = 0; - - [SerializeField] - private int m_materialValue = 0; - - [SerializeField] - private int m_multiCompile = 0; - - [SerializeField] - private int m_currentKeywordId = 0; - - [SerializeField] - private string m_currentKeyword = string.Empty; - - [SerializeField] - private bool m_createToggle = true; - - private const string IsLocalStr = "Is Local"; -#if UNITY_2019_1_OR_NEWER - [SerializeField] - private bool m_isLocal = true; -#else - [SerializeField] - private bool m_isLocal = false; -#endif - private GUIContent m_checkContent; - private GUIContent m_popContent; - - private int m_conditionId = -1; - - private const int MinComboSize = 50; - private const int MaxComboSize = 105; - - private Rect m_varRect; - private Rect m_imgRect; - private bool m_editing; - - public enum KeywordModeType - { - Toggle = 0, - ToggleOff, - KeywordEnum, - } - - public enum StaticSwitchVariableMode - { - Create = 0, - Fetch, - Reference - } - - [SerializeField] - private KeywordModeType m_keywordModeType = KeywordModeType.Toggle; - - [SerializeField] - private StaticSwitch m_reference = null; - - private const string StaticSwitchStr = "Static Switch"; - private const string MaterialToggleStr = "Material Toggle"; - - private const string ToggleMaterialValueStr = "Material Value"; - private const string ToggleDefaultValueStr = "Default Value"; - - private const string AmountStr = "Amount"; - private const string KeywordStr = "Keyword"; - private const string CustomStr = "Custom"; - private const string ToggleTypeStr = "Toggle Type"; - private const string TypeStr = "Type"; - private const string ModeStr = "Mode"; - private const string KeywordTypeStr = "Keyword Type"; - - private const string KeywordNameStr = "Keyword Name"; - public readonly static string[] KeywordTypeList = { "Shader Feature", "Multi Compile"/*, "Define Symbol"*/ }; - public readonly static int[] KeywordTypeInt = { 0, 1/*, 2*/ }; - - [SerializeField] - private string[] m_defaultKeywordNames = { "Key0", "Key1", "Key2", "Key3", "Key4", "Key5", "Key6", "Key7", "Key8" }; - - [SerializeField] - private string[] m_keywordEnumList = { "Key0", "Key1" }; - - [SerializeField] - private StaticSwitchVariableMode m_staticSwitchVarMode = StaticSwitchVariableMode.Create; - - [SerializeField] - private int m_referenceArrayId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - private int m_keywordEnumAmount = 2; - - private bool m_isStaticSwitchDirty = false; - - private Rect m_iconPos; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.FLOAT, false, "False", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "True", -1, MasterNodePortCategory.Fragment, 0 ); - for( int i = 2; i < 9; i++ ) - { - AddInputPort( WirePortDataType.FLOAT, false, m_defaultKeywordNames[ i ] ); - m_inputPorts[ i ].Visible = false; - } - m_headerColor = new Color( 0.0f, 0.55f, 0.45f, 1f ); - m_customPrefix = KeywordStr + " "; - m_autoWrapProperties = false; - m_freeType = false; - m_useVarSubtitle = true; - m_allowPropertyDuplicates = true; - m_showTitleWhenNotEditing = false; - m_currentParameterType = PropertyType.Property; - - m_checkContent = new GUIContent(); - m_checkContent.image = UIUtils.CheckmarkIcon; - - m_popContent = new GUIContent(); - m_popContent.image = UIUtils.PopupIcon; - - m_previewShaderGUID = "0b708c11c68e6a9478ac97fe3643eab1"; - m_showAutoRegisterUI = true; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_conditionId == -1 ) - m_conditionId = Shader.PropertyToID( "_Condition" ); - - StaticSwitch node = ( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference && m_reference != null ) ? m_reference : this; - - if( m_createToggle ) - PreviewMaterial.SetInt( m_conditionId, node.MaterialValue ); - else - PreviewMaterial.SetInt( m_conditionId, node.DefaultValue ); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - - if( m_createToggle ) - UIUtils.RegisterPropertyNode( this ); - else - UIUtils.UnregisterPropertyNode( this ); - - if( CurrentVarMode != StaticSwitchVariableMode.Reference ) - { - ContainerGraph.StaticSwitchNodes.AddNode( this ); - } - - if( UniqueId > -1 ) - ContainerGraph.StaticSwitchNodes.OnReorderEventComplete += OnReorderEventComplete; - } - - public override void Destroy() - { - base.Destroy(); - UIUtils.UnregisterPropertyNode( this ); - if( CurrentVarMode != StaticSwitchVariableMode.Reference ) - { - ContainerGraph.StaticSwitchNodes.RemoveNode( this ); - } - - if( UniqueId > -1 ) - ContainerGraph.StaticSwitchNodes.OnReorderEventComplete -= OnReorderEventComplete; - } - - void OnReorderEventComplete() - { - if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - if( m_reference != null ) - { - m_referenceArrayId = ContainerGraph.StaticSwitchNodes.GetNodeRegisterIdx( m_reference.UniqueId ); - } - } - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnections(); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type ); - UpdateConnections(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateConnections(); - } - - private void UpdateConnections() - { - WirePortDataType mainType = WirePortDataType.FLOAT; - - int highest = UIUtils.GetPriority( mainType ); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - WirePortDataType portType = m_inputPorts[ i ].GetOutputConnection().DataType; - if( UIUtils.GetPriority( portType ) > highest ) - { - mainType = portType; - highest = UIUtils.GetPriority( portType ); - } - } - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].ChangeType( mainType, false ); - } - - m_outputPorts[ 0 ].ChangeType( mainType, false ); - } - - public override string GetPropertyValue() - { - if( m_createToggle ) - if( m_keywordModeType == KeywordModeType.KeywordEnum && m_keywordEnumAmount > 0 ) - return PropertyAttributes + "[" + m_keywordModeType.ToString() + "(" + GetKeywordEnumPropertyList() + ")] " + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + m_defaultValue; - else - return PropertyAttributes + "[" + m_keywordModeType.ToString() + "(" + GetPropertyValStr() + ")] " + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + m_defaultValue; - else - return string.Empty; - } - - public string KeywordEnum( int index ) - { - if( m_createToggle ) - { - return string.IsNullOrEmpty( PropertyName ) ? KeywordEnumList( index ) : ( PropertyName + "_" + KeywordEnumList( index ) ); - } - else - { - return string.IsNullOrEmpty( PropertyName ) ? KeywordEnumList( index ) : ( PropertyName + KeywordEnumList( index ) ); - } - } - - public string KeywordEnumList( int index ) - { - if( CurrentVarMode == StaticSwitchVariableMode.Fetch ) - return m_keywordEnumList[ index ]; - else - { - return m_createToggle ? m_keywordEnumList[ index ].ToUpper() : m_keywordEnumList[ index ]; - } - - } - public override string PropertyName - { - get - { - if( CurrentVarMode == StaticSwitchVariableMode.Fetch ) - return m_currentKeyword; - else - { - return m_createToggle ? base.PropertyName.ToUpper() : base.PropertyName; - } - } - } - - public override string GetPropertyValStr() - { - if( m_keywordModeType == KeywordModeType.KeywordEnum ) - return PropertyName; - else if( CurrentVarMode == StaticSwitchVariableMode.Fetch ) - return m_currentKeyword; - else - return PropertyName + OnOffStr; - } - - private string GetKeywordEnumPropertyList() - { - string result = string.Empty; - for( int i = 0; i < m_keywordEnumList.Length; i++ ) - { - if( i == 0 ) - result = m_keywordEnumList[ i ]; - else - result += "," + m_keywordEnumList[ i ]; - } - return result; - } - - private string GetKeywordEnumPragmaList() - { - string result = string.Empty; - for( int i = 0; i < m_keywordEnumList.Length; i++ ) - { - if( i == 0 ) - result = KeywordEnum( i ); - else - result += " " + KeywordEnum( i ); - } - return result; - } - - public override string GetUniformValue() - { - return string.Empty; - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - dataType = string.Empty; - dataName = string.Empty; - return false; - } - - public override void DrawProperties() - { - //base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, PropertyGroup ); - NodeUtils.DrawPropertyGroup( ref m_visibleCustomAttrFoldout, CustomAttrStr, DrawCustomAttributes, DrawCustomAttrAddRemoveButtons ); - CheckPropertyFromInspector(); - } - - void DrawEnumList() - { - EditorGUI.BeginChangeCheck(); - KeywordEnumAmount = EditorGUILayoutIntSlider( AmountStr, KeywordEnumAmount, 2, 9 ); - if( EditorGUI.EndChangeCheck() ) - { - CurrentSelectedInput = Mathf.Clamp( CurrentSelectedInput, 0, KeywordEnumAmount - 1 ); - UpdateLabels(); - } - EditorGUI.indentLevel++; - for( int i = 0; i < m_keywordEnumList.Length; i++ ) - { - EditorGUI.BeginChangeCheck(); - m_keywordEnumList[ i ] = EditorGUILayoutTextField( "Item " + i, m_keywordEnumList[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_keywordEnumList[ i ] = UIUtils.RemoveInvalidEnumCharacters( m_keywordEnumList[ i ] ); - m_keywordEnumList[ i ] = m_keywordEnumList[ i ].Replace( " ", "" ); // sad face :( does not support spaces - m_inputPorts[ i ].Name = m_keywordEnumList[ i ]; - m_defaultKeywordNames[ i ] = m_inputPorts[ i ].Name; - } - } - EditorGUI.indentLevel--; - } - - public void UpdateLabels() - { - int maxinputs = m_keywordModeType == KeywordModeType.KeywordEnum ? KeywordEnumAmount : 2; - KeywordEnumAmount = Mathf.Clamp( KeywordEnumAmount, 0, maxinputs ); - m_keywordEnumList = new string[ maxinputs ]; - - for( int i = 0; i < maxinputs; i++ ) - { - m_keywordEnumList[ i ] = m_defaultKeywordNames[ i ]; - m_inputPorts[ i ].Name = m_keywordEnumList[ i ]; - } - - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - m_inputPorts[ 0 ].Name = "False"; - m_inputPorts[ 1 ].Name = "True"; - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].Visible = ( i < maxinputs ); - } - m_sizeIsDirty = true; - m_isStaticSwitchDirty = true; - } - - void PropertyGroup() - { - EditorGUI.BeginChangeCheck(); - CurrentVarMode = (StaticSwitchVariableMode)EditorGUILayoutEnumPopup( ModeStr, CurrentVarMode ); - if( EditorGUI.EndChangeCheck() ) - { - if( CurrentVarMode == StaticSwitchVariableMode.Fetch ) - { - m_keywordModeType = KeywordModeType.Toggle; - UpdateLabels(); - } - - if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - UIUtils.UnregisterPropertyNode( this ); - } - else - { - if( m_createToggle ) - UIUtils.RegisterPropertyNode( this ); - else - UIUtils.UnregisterPropertyNode( this ); - } - } - - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - EditorGUI.BeginChangeCheck(); - m_multiCompile = EditorGUILayoutIntPopup( KeywordTypeStr, m_multiCompile, KeywordTypeList, KeywordTypeInt ); - if( EditorGUI.EndChangeCheck() ) - { - BeginPropertyFromInspectorCheck(); - } - } - else if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - string[] arr = ContainerGraph.StaticSwitchNodes.NodesArr; - bool guiEnabledBuffer = GUI.enabled; - if( arr != null && arr.Length > 0 ) - { - GUI.enabled = true; - } - else - { - m_referenceArrayId = -1; - GUI.enabled = false; - } - - EditorGUI.BeginChangeCheck(); - m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId, arr ); - if( EditorGUI.EndChangeCheck() ) - { - m_reference = ContainerGraph.StaticSwitchNodes.GetNode( m_referenceArrayId ); - if( m_reference != null ) - { - m_referenceNodeId = m_reference.UniqueId; - CheckReferenceValues( true ); - } - else - { - m_referenceArrayId = -1; - m_referenceNodeId = -1; - } - } - GUI.enabled = guiEnabledBuffer; - - return; - } - - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - EditorGUI.BeginChangeCheck(); - m_keywordModeType = (KeywordModeType)EditorGUILayoutEnumPopup( TypeStr, m_keywordModeType ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateLabels(); - } - } - - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( true ); - bool guiEnabledBuffer = GUI.enabled; - GUI.enabled = false; - EditorGUILayout.TextField( KeywordNameStr, GetPropertyValStr() ); - GUI.enabled = guiEnabledBuffer; - } - - } - else - { - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - ShowPropertyInspectorNameGUI(); - ShowPropertyNameGUI( true ); - DrawEnumList(); - } - - } - - if( CurrentVarMode == StaticSwitchVariableMode.Fetch ) - { - //ShowPropertyInspectorNameGUI(); - EditorGUI.BeginChangeCheck(); - m_currentKeywordId = EditorGUILayoutPopup( KeywordStr, m_currentKeywordId, UIUtils.AvailableKeywords ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_currentKeywordId != 0 ) - { - m_currentKeyword = UIUtils.AvailableKeywords[ m_currentKeywordId ]; - } - } - - if( m_currentKeywordId == 0 ) - { - EditorGUI.BeginChangeCheck(); - m_currentKeyword = EditorGUILayoutTextField( CustomStr, m_currentKeyword ); - if( EditorGUI.EndChangeCheck() ) - { - m_currentKeyword = UIUtils.RemoveInvalidCharacters( m_currentKeyword ); - } - } - } - -#if UNITY_2019_1_OR_NEWER - m_isLocal = EditorGUILayoutToggle( IsLocalStr, m_isLocal ); -#endif - - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - ShowAutoRegister(); - } - - EditorGUI.BeginChangeCheck(); - m_createToggle = EditorGUILayoutToggle( MaterialToggleStr, m_createToggle ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_createToggle ) - UIUtils.RegisterPropertyNode( this ); - else - UIUtils.UnregisterPropertyNode( this ); - } - - - if( m_createToggle ) - { - EditorGUILayout.BeginHorizontal(); - GUILayout.Space( 20 ); - m_propertyTab = GUILayout.Toolbar( m_propertyTab, LabelToolbarTitle ); - EditorGUILayout.EndHorizontal(); - switch( m_propertyTab ) - { - default: - case 0: - { - EditorGUI.BeginChangeCheck(); - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - m_materialValue = EditorGUILayoutToggle( ToggleMaterialValueStr, m_materialValue == 1 ) ? 1 : 0; - else - m_materialValue = EditorGUILayoutPopup( ToggleMaterialValueStr, m_materialValue, m_keywordEnumList ); - if( EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - } - break; - case 1: - { - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - m_defaultValue = EditorGUILayoutToggle( ToggleDefaultValueStr, m_defaultValue == 1 ) ? 1 : 0; - else - m_defaultValue = EditorGUILayoutPopup( ToggleDefaultValueStr, m_defaultValue, m_keywordEnumList ); - } - break; - } - } - - //EditorGUILayout.HelpBox( "Keyword Type:\n" + - // "The difference is that unused variants of \"Shader Feature\" shaders will not be included into game build while \"Multi Compile\" variants are included regardless of their usage.\n\n" + - // "So \"Shader Feature\" makes most sense for keywords that will be set on the materials, while \"Multi Compile\" for keywords that will be set from code globally.\n\n" + - // "You can set keywords using the material property using the \"Property Name\" or you can set the keyword directly using the \"Keyword Name\".", MessageType.None ); - } - - public override void CheckPropertyFromInspector( bool forceUpdate = false ) - { - if( m_propertyFromInspector ) - { - if( forceUpdate || ( EditorApplication.timeSinceStartup - m_propertyFromInspectorTimestamp ) > MaxTimestamp ) - { - m_propertyFromInspector = false; - RegisterPropertyName( true, m_propertyInspectorName, m_autoGlobalName, m_underscoredGlobal ); - m_propertyNameIsDirty = true; - - if( CurrentVarMode != StaticSwitchVariableMode.Reference ) - { - ContainerGraph.StaticSwitchNodes.UpdateDataOnNode( UniqueId, DataToArray ); - } - } - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - float finalSize = 0; - if( m_keywordModeType == KeywordModeType.KeywordEnum ) - { - GUIContent dropdown = new GUIContent( m_inputPorts[ CurrentSelectedInput ].Name ); - int cacheSize = UIUtils.GraphDropDown.fontSize; - UIUtils.GraphDropDown.fontSize = 10; - Vector2 calcSize = UIUtils.GraphDropDown.CalcSize( dropdown ); - UIUtils.GraphDropDown.fontSize = cacheSize; - finalSize = Mathf.Clamp( calcSize.x, MinComboSize, MaxComboSize ); - if( m_insideSize.x != finalSize ) - { - m_insideSize.Set( finalSize, 25 ); - m_sizeIsDirty = true; - } - } - - base.OnNodeLayout( drawInfo ); - - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - m_varRect = m_remainingBox; - m_varRect.size = Vector2.one * 22 * drawInfo.InvertedZoom; - m_varRect.center = m_remainingBox.center; - if( m_showPreview ) - m_varRect.y = m_remainingBox.y; - } - else - { - m_varRect = m_remainingBox; - m_varRect.width = finalSize * drawInfo.InvertedZoom; - m_varRect.height = 16 * drawInfo.InvertedZoom; - m_varRect.x = m_remainingBox.xMax - m_varRect.width; - m_varRect.y += 1 * drawInfo.InvertedZoom; - - m_imgRect = m_varRect; - m_imgRect.x = m_varRect.xMax - 16 * drawInfo.InvertedZoom; - m_imgRect.width = 16 * drawInfo.InvertedZoom; - m_imgRect.height = m_imgRect.width; - } - - CheckReferenceValues( false ); - - if( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference ) - { - m_iconPos = m_globalPosition; - m_iconPos.width = InstanceIconWidth * drawInfo.InvertedZoom; - m_iconPos.height = InstanceIconHeight * drawInfo.InvertedZoom; - - m_iconPos.y += 10 * drawInfo.InvertedZoom; - m_iconPos.x += /*m_globalPosition.width - m_iconPos.width - */5 * drawInfo.InvertedZoom; - } - - } - - void CheckReferenceValues( bool forceUpdate ) - { - if( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference ) - { - if( m_reference == null && m_referenceNodeId > 0 ) - { - m_reference = ContainerGraph.GetNode( m_referenceNodeId ) as StaticSwitch; - m_referenceArrayId = ContainerGraph.StaticSwitchNodes.GetNodeRegisterIdx( m_referenceNodeId ); - } - - if( m_reference != null ) - { - if( forceUpdate || m_reference.IsStaticSwitchDirty ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - m_inputPorts[ i ].Name = m_reference.InputPorts[ i ].Name; - m_inputPorts[ i ].Visible = m_reference.InputPorts[ i ].Visible; - } - m_sizeIsDirty = true; - } - } - } - else - { - m_isStaticSwitchDirty = false; - } - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown || !m_createToggle ) - return; - - if( m_varRect.Contains( drawInfo.MousePosition ) ) - { - m_editing = true; - } - else if( m_editing ) - { - m_editing = false; - } - } - - private int CurrentSelectedInput - { - get - { - return m_materialMode ? m_materialValue : m_defaultValue; - } - set - { - if( m_materialMode ) - m_materialValue = value; - else - m_defaultValue = value; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference ) - return; - - if( m_editing ) - { - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - if( GUI.Button( m_varRect, GUIContent.none, UIUtils.GraphButton ) ) - { - CurrentSelectedInput = CurrentSelectedInput == 1 ? 0 : 1; - PreviewIsDirty = true; - m_editing = false; - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - - if( CurrentSelectedInput == 1 ) - { - GUI.Label( m_varRect, m_checkContent, UIUtils.GraphButtonIcon ); - } - } - else - { - EditorGUI.BeginChangeCheck(); - CurrentSelectedInput = EditorGUIPopup( m_varRect, CurrentSelectedInput, m_keywordEnumList, UIUtils.GraphDropDown ); - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_editing = false; - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - if( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference ) - { - GUI.Label( m_iconPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ) ); - return; - } - - if( m_createToggle && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - if( !m_editing ) - { - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - GUI.Label( m_varRect, GUIContent.none, UIUtils.GraphButton ); - - if( CurrentSelectedInput == 1 ) - GUI.Label( m_varRect, m_checkContent, UIUtils.GraphButtonIcon ); - } - else - { - GUI.Label( m_varRect, m_keywordEnumList[ CurrentSelectedInput ], UIUtils.GraphDropDown ); - GUI.Label( m_imgRect, m_popContent, UIUtils.GraphButtonIcon ); - } - } - } - } - - private string OnOffStr - { - get - { - StaticSwitch node = null; - switch( CurrentVarMode ) - { - default: - case StaticSwitchVariableMode.Create: - case StaticSwitchVariableMode.Fetch: - node = this; - break; - case StaticSwitchVariableMode.Reference: - { - node = ( m_reference != null ) ? m_reference : this; - } - break; - } - - if( !node.CreateToggle ) - return string.Empty; - - switch( node.KeywordModeTypeValue ) - { - default: - case KeywordModeType.Toggle: - return "_ON"; - case KeywordModeType.ToggleOff: - return "_OFF"; - } - } - } - string GetStaticSwitchType() - { - string staticSwitchType = ( m_multiCompile == 1 ) ? "multi_compile" : "shader_feature"; -#if UNITY_2019_1_OR_NEWER - if( m_isLocal ) - staticSwitchType += "_local"; -#endif - return staticSwitchType; - } - - void RegisterPragmas( ref MasterNodeDataCollector dataCollector ) - { - if( CurrentVarMode == StaticSwitchVariableMode.Create ) - { - string staticSwitchType = GetStaticSwitchType(); - if( m_keywordModeType == KeywordModeType.KeywordEnum ) - { - if( m_multiCompile == 1 ) - dataCollector.AddToPragmas( UniqueId, staticSwitchType + " " + GetKeywordEnumPragmaList() ); - else if( m_multiCompile == 0 ) - dataCollector.AddToPragmas( UniqueId, staticSwitchType + " " + GetKeywordEnumPragmaList() ); - } - else - { - if( m_multiCompile == 1 ) - dataCollector.AddToPragmas( UniqueId, staticSwitchType + " __ " + PropertyName + OnOffStr ); - else if( m_multiCompile == 0 ) - dataCollector.AddToPragmas( UniqueId, staticSwitchType + " " + PropertyName + OnOffStr ); - } - } - } - - protected override void RegisterProperty( ref MasterNodeDataCollector dataCollector ) - { - if( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference && m_reference != null ) - { - m_reference.RegisterProperty( ref dataCollector ); - m_reference.RegisterPragmas( ref dataCollector ); - } - else - { - if( m_createToggle ) - base.RegisterProperty( ref dataCollector ); - - RegisterPragmas( ref dataCollector ); - } - } - - 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 ); - - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - StaticSwitch node = ( m_staticSwitchVarMode == StaticSwitchVariableMode.Reference && m_reference != null ) ? m_reference : this; - - this.OrderIndex = node.RawOrderIndex; - this.OrderIndexOffset = node.OrderIndexOffset; - //if( m_keywordModeType == KeywordModeType.KeywordEnum ) - - //node.RegisterPragmas( ref dataCollector ); - - string outType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if( node.KeywordModeTypeValue == KeywordModeType.KeywordEnum ) - { - string defaultKey = "\t" + outType + " staticSwitch" + OutputId + " = " + m_inputPorts[ node.DefaultValue ].GeneratePortInstructions( ref dataCollector ) + ";"; - - string[] allOutputs = new string[ node.KeywordEnumAmount ]; - for( int i = 0; i < node.KeywordEnumAmount; i++ ) - allOutputs[ i ] = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ); - - for( int i = 0; i < node.KeywordEnumAmount; i++ ) - { - string keyword = node.KeywordEnum( i ); - if( i == 0 ) - dataCollector.AddLocalVariable( UniqueId, "#if defined(" + keyword + ")", true ); - else - dataCollector.AddLocalVariable( UniqueId, "#elif defined(" + keyword + ")", true ); - - if( node.DefaultValue == i ) - dataCollector.AddLocalVariable( UniqueId, defaultKey, true ); - else - dataCollector.AddLocalVariable( UniqueId, "\t" + outType + " staticSwitch" + OutputId + " = " + allOutputs[ i ] + ";", true ); - } - dataCollector.AddLocalVariable( UniqueId, "#else", true ); - dataCollector.AddLocalVariable( UniqueId, defaultKey, true ); - dataCollector.AddLocalVariable( UniqueId, "#endif", true ); - } - else - { - string falseCode = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string trueCode = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - if( node.CurrentVarMode == StaticSwitchVariableMode.Fetch ) - dataCollector.AddLocalVariable( UniqueId, "#ifdef " + node.CurrentKeyword, true ); - else - dataCollector.AddLocalVariable( UniqueId, "#ifdef " + node.PropertyName + OnOffStr, true ); - dataCollector.AddLocalVariable( UniqueId, "\t" + outType + " staticSwitch" + OutputId + " = " + trueCode + ";", true ); - dataCollector.AddLocalVariable( UniqueId, "#else", true ); - dataCollector.AddLocalVariable( UniqueId, "\t" + outType + " staticSwitch" + OutputId + " = " + falseCode + ";", true ); - dataCollector.AddLocalVariable( UniqueId, "#endif", true ); - } - - m_outputPorts[ 0 ].SetLocalValue( "staticSwitch" + OutputId, dataCollector.PortCategory ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void DrawTitle( Rect titlePos ) - { - bool referenceMode = m_staticSwitchVarMode == StaticSwitchVariableMode.Reference && m_reference != null; - string subTitle = string.Empty; - string subTitleFormat = string.Empty; - if( referenceMode ) - { - subTitle = m_reference.GetPropertyValStr(); - subTitleFormat = Constants.SubTitleRefNameFormatStr; - } - else - { - subTitle = GetPropertyValStr(); - subTitleFormat = Constants.SubTitleVarNameFormatStr; - } - - SetAdditonalTitleTextOnCallback( subTitle, ( instance, newSubTitle ) => instance.AdditonalTitleContent.text = string.Format( subTitleFormat, newSubTitle ) ); - - if( !m_isEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( titlePos, StaticSwitchStr, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - if( m_keywordModeType == KeywordModeType.KeywordEnum ) - { - for( int i = 0; i < m_keywordEnumAmount; i++ ) - { - string key = KeywordEnum( i ); - mat.DisableKeyword( key ); - } - mat.EnableKeyword( KeywordEnum( m_materialValue )); - mat.SetFloat( m_propertyName, m_materialValue ); - } - else - { - int final = m_materialValue; - if( m_keywordModeType == KeywordModeType.ToggleOff ) - final = final == 1 ? 0 : 1; - mat.SetFloat( m_propertyName, m_materialValue ); - if( final == 1 ) - mat.EnableKeyword( GetPropertyValStr() ); - else - mat.DisableKeyword( GetPropertyValStr() ); - } - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetInt( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetInt( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_multiCompile = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14403 ) - { - m_defaultValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_materialValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - else - { - m_defaultValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? 1 : 0; - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_materialValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ) ? 1 : 0; - } - } - - if( UIUtils.CurrentShaderVersion() > 13104 ) - { - m_createToggle = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_currentKeyword = GetCurrentParam( ref nodeParams ); - m_currentKeywordId = UIUtils.GetKeywordId( m_currentKeyword ); - } - if( UIUtils.CurrentShaderVersion() > 14001 ) - { - m_keywordModeType = (KeywordModeType)Enum.Parse( typeof( KeywordModeType ), GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 14403 ) - { - KeywordEnumAmount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - for( int i = 0; i < KeywordEnumAmount; i++ ) - { - m_defaultKeywordNames[ i ] = GetCurrentParam( ref nodeParams ); - } - - UpdateLabels(); - } - - if( UIUtils.CurrentShaderVersion() > 16304 ) - { - string currentVarMode = GetCurrentParam( ref nodeParams ); - CurrentVarMode = (StaticSwitchVariableMode)Enum.Parse( typeof( StaticSwitchVariableMode ), currentVarMode ); - if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - else - { - CurrentVarMode = (StaticSwitchVariableMode)m_variableMode; - } - - if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - UIUtils.UnregisterPropertyNode( this ); - } - else - { - if( m_createToggle ) - UIUtils.RegisterPropertyNode( this ); - else - UIUtils.UnregisterPropertyNode( this ); - } - - if( UIUtils.CurrentShaderVersion() > 16700 ) - { - m_isLocal = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - SetMaterialToggleRetrocompatibility(); - - if( !m_isNodeBeingCopied && CurrentVarMode != StaticSwitchVariableMode.Reference ) - { - ContainerGraph.StaticSwitchNodes.UpdateDataOnNode( UniqueId, DataToArray ); - } - } - - void SetMaterialToggleRetrocompatibility() - { - if( UIUtils.CurrentShaderVersion() < 17108 ) - { - if( !m_createToggle && m_staticSwitchVarMode == StaticSwitchVariableMode.Create ) - { - if( m_keywordModeType != KeywordModeType.KeywordEnum ) - { - m_propertyName = m_propertyName.ToUpper() + "_ON"; - } - else - { - m_propertyName = m_propertyName.ToUpper(); - for( int i = 0; i < m_keywordEnumList.Length; i++ ) - { - m_keywordEnumList[ i ] = "_" + m_keywordEnumList[ i ].ToUpper(); - } - } - m_autoGlobalName = false; - } - } - } - - public override void ReadFromDeprecated( ref string[] nodeParams, Type oldType = null ) - { - base.ReadFromDeprecated( ref nodeParams, oldType ); - { - m_currentKeyword = GetCurrentParam( ref nodeParams ); - m_currentKeywordId = UIUtils.GetKeywordId( m_currentKeyword ); - m_createToggle = false; - m_keywordModeType = KeywordModeType.Toggle; - m_variableMode = VariableMode.Fetch; - CurrentVarMode = StaticSwitchVariableMode.Fetch; - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_multiCompile ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_materialValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_createToggle ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentKeyword ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_keywordModeType ); - IOUtils.AddFieldValueToString( ref nodeInfo, KeywordEnumAmount ); - for( int i = 0; i < KeywordEnumAmount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_keywordEnumList[ i ] ); - } - - IOUtils.AddFieldValueToString( ref nodeInfo, CurrentVarMode ); - if( CurrentVarMode == StaticSwitchVariableMode.Reference ) - { - int referenceId = ( m_reference != null ) ? m_reference.UniqueId : -1; - IOUtils.AddFieldValueToString( ref nodeInfo, referenceId ); - } - IOUtils.AddFieldValueToString( ref nodeInfo, m_isLocal ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - CheckReferenceValues( true ); - } - - StaticSwitchVariableMode CurrentVarMode - { - get { return m_staticSwitchVarMode; } - set - { - if( m_staticSwitchVarMode != value ) - { - if( value == StaticSwitchVariableMode.Reference ) - { - ContainerGraph.StaticSwitchNodes.RemoveNode( this ); - m_referenceArrayId = -1; - m_referenceNodeId = -1; - m_reference = null; - m_headerColorModifier = ReferenceHeaderColor; - } - else - { - m_headerColorModifier = Color.white; - ContainerGraph.StaticSwitchNodes.AddNode( this ); - UpdateLabels(); - } - } - m_staticSwitchVarMode = value; - } - } - public bool IsStaticSwitchDirty { get { return m_isStaticSwitchDirty; } } - public KeywordModeType KeywordModeTypeValue { get { return m_keywordModeType; } } - public int DefaultValue { get { return m_defaultValue; } } - public int MaterialValue { get { return m_materialValue; } } - public string CurrentKeyword { get { return m_currentKeyword; } } - public bool CreateToggle { get { return m_createToggle; } } - - public int KeywordEnumAmount - { - get - { - return m_keywordEnumAmount; - } - set - { - m_keywordEnumAmount = value; - m_defaultValue = Mathf.Clamp( m_defaultValue, 0, m_keywordEnumAmount - 1 ); - m_materialValue = Mathf.Clamp( m_defaultValue, 0, m_keywordEnumAmount - 1 ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs.meta deleted file mode 100644 index e1b216a4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/StaticSwitch.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b1d1a233ea65ccd478fb6caf4327da48 -timeCreated: 1497289190 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs deleted file mode 100644 index 4901dbbf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node TAU -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Tau", "Constants And Properties", "Tau constant (2*PI): 6.28318530718", null, KeyCode.None, true, false, null,null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TauNode : ParentNode - { - private readonly string Tau = ( 2.0 * Mathf.PI ).ToString(); - public TauNode() : base() { } - public TauNode( 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 ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_previewShaderGUID = "701bc295c0d75d8429eabcf45e8e008d"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - return dataCollector.IsSRP? "TWO_PI": Tau; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs.meta deleted file mode 100644 index 96b9694f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TauNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1a6ded4f5e42f6d4684a6131a3cf4d33 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs deleted file mode 100644 index 46584ded..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs +++ /dev/null @@ -1,994 +0,0 @@ -// 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( "Texture Array", "Textures", "Texture Array fetches a texture from a texture2DArray asset file given a index value", KeyCode.None, true, 0, int.MaxValue, typeof( Texture2DArray ) )] - public class TextureArrayNode : PropertyNode - { - [SerializeField] - private Texture2DArray m_defaultTextureArray; - - [SerializeField] - private Texture2DArray m_materialTextureArray; - - [SerializeField] - private TexReferenceType m_referenceType = TexReferenceType.Object; - - [SerializeField] - private int m_uvSet = 0; - - [SerializeField] - private MipType m_mipMode = MipType.Auto; - - private readonly string[] m_mipOptions = { "Auto", "Mip Level", "Derivative" }; - - private TextureArrayNode m_referenceSampler = null; - - [SerializeField] - private int m_referenceArrayId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - [SerializeField] - private bool m_autoUnpackNormals = false; - - private InputPort m_texPort; - private InputPort m_uvPort; - private InputPort m_indexPort; - private InputPort m_lodPort; - private InputPort m_normalPort; - private InputPort m_ddxPort; - private InputPort m_ddyPort; - - private OutputPort m_colorPort; - - private const string AutoUnpackNormalsStr = "Normal"; - private const string NormalScaleStr = "Scale"; - - private string m_labelText = "None (Texture2DArray)"; - - private readonly Color ReferenceHeaderColor = new Color( 2.66f, 1.02f, 0.6f, 1.0f ); - - private int m_cachedUvsId = -1; - private int m_cachedSamplerId = -1; - private int m_texConnectedId = -1; - private int m_cachedUnpackId = -1; - private int m_cachedLodId = -1; - - private Rect m_iconPos; - private bool m_isEditingPicker; - - private bool m_linearTexture; - protected bool m_drawPicker; - - private ReferenceState m_state = ReferenceState.Self; - private ParentNode m_previewTextProp = null; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputColorPorts( "RGBA" ); - m_colorPort = m_outputPorts[ 0 ]; - AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex", -1, MasterNodePortCategory.Fragment, 6 ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT, false, "Index", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "Level", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, NormalScaleStr, -1, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT2, false, "DDX", -1, MasterNodePortCategory.Fragment, 4 ); - AddInputPort( WirePortDataType.FLOAT2, false, "DDY", -1, MasterNodePortCategory.Fragment, 5 ); - m_inputPorts[ 2 ].AutoDrawInternalData = true; - - m_texPort = m_inputPorts[ 0 ]; - m_uvPort = m_inputPorts[ 1 ]; - m_indexPort = m_inputPorts[ 2 ]; - m_lodPort = m_inputPorts[ 3 ]; - - m_lodPort.Visible = false; - m_normalPort = m_inputPorts[ 4 ]; - m_normalPort.Visible = m_autoUnpackNormals; - m_normalPort.FloatInternalData = 1.0f; - m_ddxPort = m_inputPorts[ 5 ]; - m_ddxPort.Visible = false; - m_ddyPort = m_inputPorts[ 6 ]; - m_ddyPort.Visible = false; - m_insideSize.Set( 128, 128 + 5 ); - m_drawPrecisionUI = false; - m_currentParameterType = PropertyType.Property; - - m_availableAttribs.Add( new PropertyAttributes( "No Scale Offset", "[NoScaleOffset]" ) ); - - m_freeType = false; - m_showPreview = true; - m_drawPreviewExpander = false; - m_drawPreview = false; - m_drawPicker = true; - m_customPrefix = "Texture Array "; - m_selectedLocation = PreviewLocation.TopCenter; - m_previewShaderGUID = "2e6d093df2d289f47b827b36efb31a81"; - m_showAutoRegisterUI = false; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedUvsId == -1 ) - m_cachedUvsId = Shader.PropertyToID( "_CustomUVs" ); - - if( m_cachedSamplerId == -1 ) - m_cachedSamplerId = Shader.PropertyToID( "_Sampler" ); - - if( m_texConnectedId == -1 ) - m_texConnectedId = Shader.PropertyToID( "_TexConnected" ); - - if( m_cachedUnpackId == -1 ) - m_cachedUnpackId = Shader.PropertyToID( "_Unpack" ); - - if( m_cachedLodId == -1 ) - m_cachedLodId = Shader.PropertyToID( "_LodType" ); - - PreviewMaterial.SetFloat( m_cachedLodId, ( m_mipMode == MipType.MipLevel ? 1 : 0 ) ); - PreviewMaterial.SetFloat( m_cachedUnpackId, m_autoUnpackNormals ? 1 : 0 ); - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - { - if( (ParentNode)m_referenceSampler != m_referenceSampler.PreviewTextProp ) - { - PreviewMaterial.SetInt( m_texConnectedId, 1 ); - PreviewMaterial.SetTexture( "_G", m_referenceSampler.PreviewTextProp.PreviewTexture ); - } - else - { - PreviewMaterial.SetInt( m_texConnectedId, 0 ); - PreviewMaterial.SetTexture( m_cachedSamplerId, m_referenceSampler.TextureArray ); - } - } - else if( m_texPort.IsConnected ) - { - PreviewMaterial.SetInt( m_texConnectedId, 1 ); - } - else - { - PreviewMaterial.SetInt( m_texConnectedId, 0 ); - PreviewMaterial.SetTexture( m_cachedSamplerId, TextureArray ); - } - PreviewMaterial.SetFloat( m_cachedUvsId, ( m_uvPort.IsConnected ? 1 : 0 ) ); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterTextureArrayNode( this ); - UIUtils.RegisterPropertyNode( this ); - } - - if( UniqueId > -1 ) - ContainerGraph.TextureArrayNodes.OnReorderEventComplete += OnReorderEventComplete; - - } - - private void OnReorderEventComplete() - { - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - { - m_referenceArrayId = ContainerGraph.TextureArrayNodes.GetNodeRegisterIdx( m_referenceSampler.UniqueId ); - } - } - - new void ShowDefaults() - { - m_uvSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_uvSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ); - - MipType newMipMode = (MipType)EditorGUILayoutPopup( "Mip Mode", (int)m_mipMode, m_mipOptions ); - if( newMipMode != m_mipMode ) - { - m_mipMode = newMipMode; - } - - switch( m_mipMode ) - { - case MipType.Auto: - m_lodPort.Visible = false; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - break; - case MipType.MipLevel: - m_lodPort.Visible = true; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - break; - case MipType.MipBias: - case MipType.Derivative: - m_ddxPort.Visible = true; - m_ddyPort.Visible = true; - m_lodPort.Visible = false; - break; - } - - if( m_ddxPort.Visible ) - { - EditorGUILayout.HelpBox( "Warning: Derivative Mip Mode only works on some platforms (D3D11 XBOXONE GLES3 GLCORE)", MessageType.Warning ); - } - - if( !m_lodPort.IsConnected && m_lodPort.Visible ) - { - m_lodPort.FloatInternalData = EditorGUILayoutFloatField( "Mip Level", m_lodPort.FloatInternalData ); - } - - if( !m_indexPort.IsConnected ) - { - m_indexPort.FloatInternalData = EditorGUILayoutFloatField( "Index", m_indexPort.FloatInternalData ); - } - - - } - - public override void DrawMainPropertyBlock() - { - EditorGUI.BeginChangeCheck(); - m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterTextureArrayNode( this ); - UIUtils.RegisterPropertyNode( this ); - - SetTitleText( m_propertyInspectorName ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - m_referenceArrayId = -1; - m_referenceNodeId = -1; - m_referenceSampler = null; - } - else - { - UIUtils.UnregisterTextureArrayNode( this ); - UIUtils.UnregisterPropertyNode( this ); - } - UpdateHeaderColor(); - } - - if( m_referenceType == TexReferenceType.Object ) - { - EditorGUI.BeginChangeCheck(); - base.DrawMainPropertyBlock(); - if( EditorGUI.EndChangeCheck() ) - { - OnPropertyNameChanged(); - } - } - else - { - string[] arr = UIUtils.TextureArrayNodeArr(); - 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; - - ShowDefaults(); - - DrawSamplerOptions(); - } - } - - public override void OnPropertyNameChanged() - { - base.OnPropertyNameChanged(); - UIUtils.UpdateTextureArrayDataNode( UniqueId, PropertyInspectorName ); - } - - public override void DrawSubProperties() - { - ShowDefaults(); - - DrawSamplerOptions(); - - EditorGUI.BeginChangeCheck(); - m_defaultTextureArray = EditorGUILayoutObjectField( Constants.DefaultValueLabel, m_defaultTextureArray, typeof( Texture2DArray ), false ) as Texture2DArray; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - } - } - - public override void DrawMaterialProperties() - { - ShowDefaults(); - - DrawSamplerOptions(); - - EditorGUI.BeginChangeCheck(); - m_materialTextureArray = EditorGUILayoutObjectField( Constants.MaterialValueLabel, m_materialTextureArray, typeof( Texture2DArray ), false ) as Texture2DArray; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - m_requireMaterialUpdate = true; - } - } - - public void DrawSamplerOptions() - { - EditorGUI.BeginChangeCheck(); - bool autoUnpackNormals = EditorGUILayoutToggle( "Normal Map", m_autoUnpackNormals ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_autoUnpackNormals != autoUnpackNormals ) - { - AutoUnpackNormals = autoUnpackNormals; - - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - } - - if( m_autoUnpackNormals && !m_normalPort.IsConnected ) - { - m_normalPort.FloatInternalData = EditorGUILayoutFloatField( NormalScaleStr, m_normalPort.FloatInternalData ); - } - } - - public void ConfigureInputPorts() - { - m_normalPort.Visible = AutoUnpackNormals; - - m_sizeIsDirty = true; - } - - public void ConfigureOutputPorts() - { - m_outputPorts[ m_colorPort.PortId + 4 ].Visible = !AutoUnpackNormals; - - if( !AutoUnpackNormals ) - { - m_colorPort.ChangeProperties( "RGBA", WirePortDataType.FLOAT4, false ); - m_outputPorts[ m_colorPort.PortId + 1 ].ChangeProperties( "R", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 2 ].ChangeProperties( "G", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 3 ].ChangeProperties( "B", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 4 ].ChangeProperties( "A", WirePortDataType.FLOAT, false ); - - } - else - { - m_colorPort.ChangeProperties( "XYZ", WirePortDataType.FLOAT3, false ); - m_outputPorts[ m_colorPort.PortId + 1 ].ChangeProperties( "X", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 2 ].ChangeProperties( "Y", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 3 ].ChangeProperties( "Z", WirePortDataType.FLOAT, false ); - } - - m_sizeIsDirty = true; - } - - public virtual void CheckTextureImporter( bool additionalCheck ) - { - m_requireMaterialUpdate = true; - Texture2DArray texture = m_materialMode ? m_materialTextureArray : m_defaultTextureArray; - - UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath( AssetDatabase.GetAssetPath( texture ), typeof( UnityEngine.Object ) ); - - if( obj != null ) - { - SerializedObject serializedObject = new UnityEditor.SerializedObject( obj ); - - if( serializedObject != null ) - { - SerializedProperty colorSpace = serializedObject.FindProperty( "m_ColorSpace" ); - m_linearTexture = ( colorSpace.intValue == 0 ); - } - } - } - - void UpdateHeaderColor() - { - m_headerColorModifier = ( m_referenceType == TexReferenceType.Object ) ? Color.white : ReferenceHeaderColor; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( !( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp || drawInfo.CurrentEventType == EventType.ExecuteCommand || drawInfo.CurrentEventType == EventType.DragPerform ) ) - return; - - bool insideBox = m_previewRect.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - m_isEditingPicker = true; - } - else if( m_isEditingPicker && !insideBox && drawInfo.CurrentEventType != EventType.ExecuteCommand ) - { - GUI.FocusControl( null ); - m_isEditingPicker = false; - } - - if( m_state != ReferenceState.Self && drawInfo.CurrentEventType == EventType.MouseDown && m_previewRect.Contains( drawInfo.MousePosition ) ) - { - UIUtils.FocusOnNode( m_previewTextProp, 1, true ); - Event.current.Use(); - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - if( m_drawPreview ) - { - m_iconPos = m_globalPosition; - m_iconPos.width = 19 * drawInfo.InvertedZoom; - m_iconPos.height = 19 * drawInfo.InvertedZoom; - - m_iconPos.y += 10 * drawInfo.InvertedZoom; - m_iconPos.x += m_globalPosition.width - m_iconPos.width - 5 * drawInfo.InvertedZoom; - } - - bool instanced = CheckReference(); - if( instanced ) - { - m_state = ReferenceState.Instance; - m_previewTextProp = m_referenceSampler; - } - else if( m_texPort.IsConnected ) - { - m_state = ReferenceState.Connected; - m_previewTextProp = m_texPort.GetOutputNode( 0 ) as ParentNode; - } - else - { - m_state = ReferenceState.Self; - m_previewTextProp = this; - } - - if( m_previewTextProp == null ) - m_previewTextProp = this; - - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_isEditingPicker && m_drawPicker ) - { - Rect hitRect = m_previewRect; - hitRect.height = 14 * drawInfo.InvertedZoom; - hitRect.y = m_previewRect.yMax - hitRect.height; - hitRect.width = 4 * 14 * drawInfo.InvertedZoom; - - bool restoreMouse = false; - if( Event.current.type == EventType.MouseDown && hitRect.Contains( drawInfo.MousePosition ) ) - { - restoreMouse = true; - Event.current.type = EventType.Ignore; - } - - EditorGUI.BeginChangeCheck(); - m_colorBuffer = GUI.color; - GUI.color = Color.clear; - if( m_materialMode ) - m_materialTextureArray = EditorGUIObjectField( m_previewRect, m_materialTextureArray, typeof( Texture2DArray ), false ) as Texture2DArray; - else - m_defaultTextureArray = EditorGUIObjectField( m_previewRect, m_defaultTextureArray, typeof( Texture2DArray ), false ) as Texture2DArray; - GUI.color = m_colorBuffer; - - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - CheckTextureImporter( true ); - SetTitleText( PropertyInspectorName ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - BeginDelayedDirtyProperty(); - m_requireMaterialUpdate = true; - } - - if( restoreMouse ) - { - Event.current.type = EventType.MouseDown; - } - - if( ( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp ) ) - DrawPreviewMaskButtonsLayout( drawInfo, m_previewRect ); - } - - if( drawInfo.CurrentEventType != EventType.Repaint ) - return; - - switch( m_state ) - { - default: - case ReferenceState.Self: - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - m_drawPreview = false; - m_drawPicker = true; - - DrawTexturePicker( drawInfo ); - } - break; - case ReferenceState.Connected: - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - m_drawPreview = true; - m_drawPicker = false; - - if( m_previewTextProp != null ) - { - SetTitleTextOnCallback( m_previewTextProp.TitleContent.text, ( instance, newTitle ) => instance.TitleContent.text = newTitle + " (Input)" ); - SetAdditonalTitleText( m_previewTextProp.AdditonalTitleContent.text ); - } - - // Draw chain lock - GUI.Label( m_iconPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ) ); - - // Draw frame around preview - GUI.Label( m_previewRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - break; - case ReferenceState.Instance: - { - m_drawPreview = true; - m_drawPicker = false; - - if( m_referenceSampler != null ) - { - SetTitleTextOnCallback( m_referenceSampler.PreviewTextProp.TitleContent.text, ( instance, newTitle ) => instance.TitleContent.text = newTitle + Constants.InstancePostfixStr ); - SetAdditonalTitleText( m_referenceSampler.PreviewTextProp.AdditonalTitleContent.text ); - } - - // Draw chain lock - GUI.Label( m_iconPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ) ); - - // Draw frame around preview - GUI.Label( m_previewRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - break; - } - } - - protected void DrawTexturePicker( DrawInfo drawInfo ) - { - Rect newRect = m_previewRect; - Texture2DArray currentValue = m_materialMode ? m_materialTextureArray : m_defaultTextureArray; - - if( currentValue == null ) - GUI.Label( newRect, string.Empty, UIUtils.ObjectFieldThumb ); - else - DrawPreview( drawInfo, m_previewRect ); - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - Rect butRect = m_previewRect; - butRect.y -= 1; - butRect.x += 1; - - Rect smallButton = newRect; - smallButton.height = 14 * drawInfo.InvertedZoom; - smallButton.y = newRect.yMax - smallButton.height - 2; - smallButton.width = 40 * drawInfo.InvertedZoom; - smallButton.x = newRect.xMax - smallButton.width - 2; - if( currentValue == null ) - { - GUI.Label( newRect, m_labelText, UIUtils.ObjectFieldThumbOverlay ); - } - else - { - DrawPreviewMaskButtonsRepaint( drawInfo, butRect ); - } - GUI.Label( smallButton, "Select", UIUtils.GetCustomStyle( CustomStyle.SamplerButton ) ); - } - - GUI.Label( newRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - - 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 ) ); - - - OnPropertyNameChanged(); - - if( CheckReference() ) - { - OrderIndex = m_referenceSampler.RawOrderIndex; - OrderIndexOffset = m_referenceSampler.OrderIndexOffset; - } - - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - - bool instanced = false; - - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - instanced = true; - - if( instanced ) - { - if( !m_referenceSampler.TexPort.IsConnected ) - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else if( !m_texPort.IsConnected ) - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - string level = string.Empty; - if( m_lodPort.Visible ) - { - level = m_lodPort.GeneratePortInstructions( ref dataCollector ); - } - - if( isVertex && !m_lodPort.Visible ) - level = "0"; - - string propertyName = string.Empty; - if( instanced ) - { - if( m_referenceSampler.TexPort.IsConnected ) - propertyName = m_referenceSampler.TexPort.GeneratePortInstructions( ref dataCollector ); - else - propertyName = m_referenceSampler.PropertyName; - } - else if( m_texPort.IsConnected ) - propertyName = m_texPort.GeneratePortInstructions( ref dataCollector ); - else - propertyName = PropertyName; - - string uvs = string.Empty; - if( m_uvPort.IsConnected ) - { - uvs = m_uvPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - if( dataCollector.IsTemplate ) - { - uvs = dataCollector.TemplateDataCollectorInstance.GetTextureCoord( m_uvSet, propertyName/*( instanced ? m_referenceSampler.PropertyName : PropertyName )*/, UniqueId, CurrentPrecisionType ); - } - else - { - if( isVertex ) - uvs = TexCoordVertexDataNode.GenerateVertexUVs( ref dataCollector, UniqueId, m_uvSet, propertyName ); - else - uvs = TexCoordVertexDataNode.GenerateFragUVs( ref dataCollector, UniqueId, m_uvSet, propertyName ); - } - } - string index = m_indexPort.GeneratePortInstructions( ref dataCollector ); - - string m_normalMapUnpackMode = ""; - if( m_autoUnpackNormals ) - { - bool isScaledNormal = false; - if( m_normalPort.IsConnected ) - { - isScaledNormal = true; - } - else - { - if( m_normalPort.FloatInternalData != 1 ) - { - isScaledNormal = true; - } - } - - string scaleValue = isScaledNormal ? m_normalPort.GeneratePortInstructions( ref dataCollector ) : "1.0"; - m_normalMapUnpackMode = TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, isScaledNormal, scaleValue ); - if( isScaledNormal && ( !dataCollector.IsTemplate || !dataCollector.IsSRP ) ) - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ); - } - - } - - string result = string.Empty; - - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - //CAREFUL mipbias here means derivative (this needs index changes) - //TODO: unity now supports bias as well - if( m_mipMode == MipType.MipBias ) - { - dataCollector.UsingArrayDerivatives = true; - result = propertyName + ".SampleGrad(sampler" + propertyName + ", float3(" + uvs + ", " + index + "), " + m_ddxPort.GeneratePortInstructions( ref dataCollector ) + ", " + m_ddyPort.GeneratePortInstructions( ref dataCollector ) + ");"; - } - else if( m_lodPort.Visible || isVertex ) - { - result = "SAMPLE_TEXTURE2D_ARRAY_LOD(" + propertyName + ", sampler" + propertyName + ", " + uvs + ", " + index + ", " + level + " )"; - } - else - { - result = "SAMPLE_TEXTURE2D_ARRAY(" + propertyName + ", sampler" + propertyName + ", " + uvs + ", " + index + " )"; - } - } - else - { - //CAREFUL mipbias here means derivative (this needs index changes) - if( m_mipMode == MipType.MipBias ) - { - dataCollector.UsingArrayDerivatives = true; - result = "ASE_SAMPLE_TEX2DARRAY_GRAD(" + propertyName + ", float3(" + uvs + ", " + index + "), " + m_ddxPort.GeneratePortInstructions( ref dataCollector ) + ", " + m_ddyPort.GeneratePortInstructions( ref dataCollector ) + " )"; - } - else if( m_lodPort.Visible || isVertex ) - { - result = "UNITY_SAMPLE_TEX2DARRAY_LOD(" + propertyName + ", float3(" + uvs + ", " + index + "), " + level + " )"; - } - else - { - result = "UNITY_SAMPLE_TEX2DARRAY" + ( m_lodPort.Visible || isVertex ? "_LOD" : "" ) + "(" + propertyName + ", float3(" + uvs + ", " + index + ") " + ( m_lodPort.Visible || isVertex ? ", " + level : "" ) + " )"; - } - } - - if( m_autoUnpackNormals ) - result = string.Format( m_normalMapUnpackMode, result ); - - RegisterLocalVariable( 0, result, ref dataCollector, "texArray" + OutputId ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - public override string PropertyName - { - get - { - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - return m_referenceSampler.PropertyName; - else - return base.PropertyName; - } - } - - public override string PropertyInspectorName - { - get - { - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - return m_referenceSampler.PropertyInspectorName; - else - return base.PropertyInspectorName; - } - } - - public override string GetPropertyValue() - { - return PropertyAttributes + PropertyName + "(\"" + PropertyInspectorName + "\", 2DArray ) = \"\" {}"; - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - MasterNode currMasterNode = ( m_containerGraph.CurrentMasterNode != null ) ? m_containerGraph.CurrentMasterNode : m_containerGraph.ParentWindow.OutsideGraph.CurrentMasterNode; - if( currMasterNode != null && currMasterNode.CurrentDataCollector.IsTemplate && currMasterNode.CurrentDataCollector.IsSRP ) - { - dataType = "TEXTURE2D_ARRAY( " + PropertyName + ""; - dataName = ");\nuniform SAMPLER( sampler" + PropertyName + " )"; - return true; - } - dataType = "UNITY_DECLARE_TEX2DARRAY("; - dataName = PropertyName + " )"; - return true; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string textureName = GetCurrentParam( ref nodeParams ); - m_defaultTextureArray = AssetDatabase.LoadAssetAtPath<Texture2DArray>( textureName ); - m_uvSet = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) ); - m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 3202 ) - m_mipMode = (MipType)Enum.Parse( typeof( MipType ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 5105 ) - m_autoUnpackNormals = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - if( m_referenceType == TexReferenceType.Instance ) - { - UIUtils.UnregisterTextureArrayNode( this ); - UIUtils.UnregisterPropertyNode( this ); - } - - ConfigureInputPorts(); - ConfigureOutputPorts(); - - m_lodPort.Visible = ( m_mipMode == MipType.MipLevel ); - m_ddxPort.Visible = ( m_mipMode == MipType.MipBias ); //not really bias, it's derivative - m_ddyPort.Visible = ( m_mipMode == MipType.MipBias ); //not really bias, it's derivative - - UpdateHeaderColor(); - - if( m_defaultTextureArray ) - { - m_materialTextureArray = m_defaultTextureArray; - } - - if( !m_isNodeBeingCopied && m_referenceType == TexReferenceType.Object ) - { - ContainerGraph.TextureArrayNodes.UpdateDataOnNode( UniqueId, DataToArray ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - - m_referenceSampler = UIUtils.GetNode( m_referenceNodeId ) as TextureArrayNode; - m_referenceArrayId = UIUtils.GetTextureArrayNodeRegisterId( m_referenceNodeId ); - OnPropertyNameChanged(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultTextureArray != null ) ? AssetDatabase.GetAssetPath( m_defaultTextureArray ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_uvSet.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceType ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( ( m_referenceSampler != null ) ? m_referenceSampler.UniqueId : -1 ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mipMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoUnpackNormals ); - } - - public override void ReadAdditionalClipboardData( ref string[] nodeParams ) - { - base.ReadAdditionalClipboardData( ref nodeParams ); - string textureName = GetCurrentParam( ref nodeParams ); - m_materialTextureArray = AssetDatabase.LoadAssetAtPath<Texture2DArray>( textureName ); - } - - public override void WriteAdditionalClipboardData( ref string nodeInfo ) - { - base.WriteAdditionalClipboardData( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialTextureArray != null ) ? AssetDatabase.GetAssetPath( m_materialTextureArray ) : Constants.NoStringValue ); - } - - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction && m_referenceType == TexReferenceType.Object ) - { - OnPropertyNameChanged(); - if( mat.HasProperty( PropertyName ) ) - { - mat.SetTexture( PropertyName, m_materialTextureArray ); - } - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) ) - { - if( mat.HasProperty( PropertyName ) ) - { - m_materialTextureArray = (Texture2DArray)mat.GetTexture( PropertyName ); - if( m_materialTextureArray == null ) - m_materialTextureArray = m_defaultTextureArray; - } - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( PropertyName ) ) - { - m_materialTextureArray = (Texture2DArray)material.GetTexture( PropertyName ); - if( m_materialTextureArray == null ) - m_materialTextureArray = m_defaultTextureArray; - - PreviewIsDirty = true; - } - } - - public override bool UpdateShaderDefaults( ref Shader shader, ref TextureDefaultsDataColector defaultCol ) - { - if( m_defaultTextureArray != null ) - { - defaultCol.AddValue( PropertyName, m_defaultTextureArray ); - } - - return true; - } - - public override string GetPropertyValStr() - { - return m_materialMode ? ( m_materialTextureArray != null ? m_materialTextureArray.name : IOUtils.NO_TEXTURES ) : ( m_defaultTextureArray != null ? m_defaultTextureArray.name : IOUtils.NO_TEXTURES ); - } - - public bool CheckReference() - { - if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 ) - { - m_referenceSampler = UIUtils.GetTextureArrayNode( m_referenceArrayId ); - - if( m_referenceSampler == null ) - { - m_texPort.Locked = false; - m_referenceArrayId = -1; - } - else - m_texPort.Locked = true; - } - else - { - m_texPort.Locked = false; - } - - return m_referenceSampler != null; - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - base.SetupFromCastObject( obj ); - SetupFromObject( obj ); - } - - public override void OnObjectDropped( UnityEngine.Object obj ) - { - SetupFromObject( obj ); - } - - private void SetupFromObject( UnityEngine.Object obj ) - { - if( m_materialMode ) - m_materialTextureArray = obj as Texture2DArray; - else - m_defaultTextureArray = obj as Texture2DArray; - } - - public Texture2DArray TextureArray { get { return ( m_materialMode ? m_materialTextureArray : m_defaultTextureArray ); } } - - public bool IsLinearTexture { get { return m_linearTexture; } } - - public bool AutoUnpackNormals - { - get { return m_autoUnpackNormals; } - set { m_autoUnpackNormals = value; } - } - - public override string DataToArray { get { return PropertyInspectorName; } } - - public override void Destroy() - { - base.Destroy(); - m_defaultTextureArray = null; - m_materialTextureArray = null; - - m_texPort = null; - m_uvPort = null; - m_indexPort = null; - m_lodPort = null; - m_normalPort = null; - m_ddxPort = null; - m_ddyPort = null; - - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.UnregisterTextureArrayNode( this ); - UIUtils.UnregisterPropertyNode( this ); - } - - if( UniqueId > -1 ) - ContainerGraph.TextureArrayNodes.OnReorderEventComplete -= OnReorderEventComplete; - } - - public ParentNode PreviewTextProp { get { return m_previewTextProp; } } - public InputPort TexPort { get { return m_texPort; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs.meta deleted file mode 100644 index 54332f0b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/TextureArrayNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3c5be6f9c03445d4fb70955f594877dc -timeCreated: 1485801067 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs deleted file mode 100644 index 306816ba..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs +++ /dev/null @@ -1,301 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vector2", "Constants And Properties", "Vector2 property", null, KeyCode.Alpha2 )] - public sealed class Vector2Node : PropertyNode - { - [SerializeField] - private Vector2 m_defaultValue = Vector2.zero; - - [SerializeField] - private Vector2 m_materialValue = Vector2.zero; - - private const float LabelWidth = 8; - - private int m_cachedPropertyId = -1; - - private bool m_isEditingFields; - private Vector2 m_previousValue = Vector2.zero; - private string[] m_fieldText = new string[] { "0", "0" }; - - public Vector2Node() : base() { } - public Vector2Node( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Vector" ); - m_insideSize.Set(50,20); - m_selectedLocation = PreviewLocation.BottomCenter; - AddOutputVectorPorts( WirePortDataType.FLOAT2, "XY" ); - m_availableAttribs.Add( new PropertyAttributes( "Remap Sliders", "[RemapSliders]" ) ); - m_previewShaderGUID = "88b4191eb06084d4da85d1dd2f984085"; - m_srpBatcherCompatible = true; - m_showHybridInstancedUI = true; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - m_defaultValue = EditorGUILayoutVector2Field( Constants.DefaultValueLabel, m_defaultValue ); - } - - public override void DrawMaterialProperties() - { - if ( m_materialMode ) - EditorGUI.BeginChangeCheck(); - - m_materialValue = EditorGUILayoutVector2Field( Constants.MaterialValueLabel, m_materialValue ); - if ( m_materialMode && EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputVector" ); - - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_materialValue[ 0 ], m_materialValue[ 1 ], 0, 0 ) ); - else - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_defaultValue[ 0 ], m_defaultValue[ 1 ], 0, 0 ) ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if ( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if ( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( m_isEditingFields && m_currentParameterType != PropertyType.Global) - { - EditorGUI.BeginChangeCheck(); - for ( int i = 0; i < 2; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - float val = m_materialValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_materialValue[ i ] = val; - } - else - { - float val = m_defaultValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_defaultValue[ i ] = val; - } - } - if ( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = m_materialMode; - BeginDelayedDirtyProperty(); - } - } - else if ( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - for ( int i = 0; i < 2; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - if( GUI.enabled ) - { - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - } - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - if ( m_previousValue[ i ] != m_materialValue[ i ] ) - { - m_previousValue[ i ] = m_materialValue[ i ]; - m_fieldText[ i ] = m_materialValue[ i ].ToString(); - } - } - else - { - if ( m_previousValue[ i ] != m_defaultValue[ i ] ) - { - m_previousValue[ i ] = m_defaultValue[ i ]; - m_fieldText[ i ] = m_defaultValue[ i ].ToString(); - } - } - - GUI.Label( fakeField, m_fieldText[ i ], UIUtils.MainSkin.textField ); - } - GUI.enabled = guiEnabled; - } - } - - public override void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector ) - { - Vector2 value = m_defaultValue; - dataCollector.AddLocalVariable( UniqueId, CreateLocalVarDec( value.x + "," + value.y ) ); - m_outputPorts[ 0 ].SetLocalValue( m_propertyName, dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( m_propertyName + ".x" , dataCollector.PortCategory); - m_outputPorts[ 2 ].SetLocalValue( m_propertyName + ".y", dataCollector.PortCategory ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId,ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if ( m_currentParameterType != PropertyType.Constant ) - return GetOutputVectorItem( 0, outputId, PropertyData( dataCollector.PortCategory ) ); - - if ( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - if ( CheckLocalVariable( ref dataCollector ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - Vector2 value = m_defaultValue; - string result = string.Empty; - switch ( outputId ) - { - case 0: - { - result = m_precisionString+"( " + value.x + "," + value.y + " )"; - } - break; - - case 1: - { - result = value.x.ToString(); - } - break; - case 2: - { - result = value.y.ToString(); - } - break; - } - - if ( result.Equals( string.Empty ) ) - { - UIUtils.ShowMessage( UniqueId, "Vector2Node generating empty code", MessageSeverity.Warning ); - } - return result; - } - - public override string GetPropertyValue() - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Vector) = (" + m_defaultValue.x + "," + m_defaultValue.y + ",0,0)"; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetVector( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat , bool fetchMaterialValues ) - { - base.SetMaterialMode( mat , fetchMaterialValues ); - if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetVector( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetVector( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToVector2( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - m_materialValue = IOUtils.StringToVector2( GetCurrentParam( ref nodeParams ) ); - } - - public override void SetGlobalValue() { Shader.SetGlobalVector( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalVector( m_propertyName ); } - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector2ToString( m_defaultValue ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector2ToString( m_materialValue ) ); - } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue.x.ToString( Mathf.Abs( m_materialValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.y.ToString( Mathf.Abs( m_materialValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) : - m_defaultValue.x.ToString( Mathf.Abs( m_defaultValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.y.ToString( Mathf.Abs( m_defaultValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ); - } - - public Vector2 Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs.meta deleted file mode 100644 index a241974a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector2Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6ca8f5d67cf4c5f428a6dd646099897c -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs deleted file mode 100644 index 62be0696..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs +++ /dev/null @@ -1,315 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vector3", "Constants And Properties", "Vector3 property", null, KeyCode.Alpha3 )] - public sealed class Vector3Node : PropertyNode - { - [SerializeField] - private Vector3 m_defaultValue = Vector3.zero; - - [SerializeField] - private Vector3 m_materialValue = Vector3.zero; - - private const float LabelWidth = 8; - - private int m_cachedPropertyId = -1; - - public Vector3Node() : base() { } - public Vector3Node( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Vector" ); - m_insideSize.Set( 50, 30 ); - m_selectedLocation = PreviewLocation.BottomCenter; - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_previewShaderGUID = "8a44d38f06246bf48944b3f314bc7920"; - m_srpBatcherCompatible = true; - m_showHybridInstancedUI = true; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - m_defaultValue = EditorGUILayoutVector3Field( Constants.DefaultValueLabel, m_defaultValue ); - } - - public override void DrawMaterialProperties() - { - EditorGUI.BeginChangeCheck(); - - m_materialValue = EditorGUILayoutVector3Field( Constants.MaterialValueLabel, m_materialValue ); - - if( EditorGUI.EndChangeCheck() ) - { - //MarkForPreviewUpdate(); - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputVector" ); - - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_materialValue[ 0 ], m_materialValue[ 1 ], m_materialValue[ 2 ], 0 ) ); - else - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_defaultValue[ 0 ], m_defaultValue[ 1 ], m_defaultValue[ 2 ], 0 ) ); - } - - private bool m_isEditingFields; - private Vector3 m_previousValue = Vector3.zero; - private string[] m_fieldText = new string[] { "0", "0", "0" }; - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( !m_isVisible ) - return; - - if( m_isEditingFields && m_currentParameterType != PropertyType.Global) - { - EditorGUI.BeginChangeCheck(); - for( int i = 0; i < 3; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - float val = m_materialValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_materialValue[ i ] = val; - } - else - { - float val = m_defaultValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_defaultValue[ i ] = val; - } - } - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = m_materialMode; - BeginDelayedDirtyProperty(); - } - } - else if( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - - for( int i = 0; i < 3; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - if( GUI.enabled ) - { - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - } - - if( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - if( m_previousValue[ i ] != m_materialValue[ i ] ) - { - m_previousValue[ i ] = m_materialValue[ i ]; - m_fieldText[ i ] = m_materialValue[ i ].ToString(); - } - } - else - { - if( m_previousValue[ i ] != m_defaultValue[ i ] ) - { - m_previousValue[ i ] = m_defaultValue[ i ]; - m_fieldText[ i ] = m_defaultValue[ i ].ToString(); - } - } - - GUI.Label( fakeField, m_fieldText[ i ], UIUtils.MainSkin.textField ); - } - GUI.enabled = guiEnabled; - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector ) - { - Vector3 value = m_defaultValue; - dataCollector.AddLocalVariable( UniqueId, CreateLocalVarDec( value.x + "," + value.y + "," + value.z ) ); - m_outputPorts[ 0 ].SetLocalValue( m_propertyName , dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( m_propertyName + ".x" , dataCollector.PortCategory ); - m_outputPorts[ 2 ].SetLocalValue( m_propertyName + ".y" , dataCollector.PortCategory ); - m_outputPorts[ 3 ].SetLocalValue( m_propertyName + ".z", dataCollector.PortCategory ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if( m_currentParameterType != PropertyType.Constant ) - return GetOutputVectorItem( 0, outputId, PropertyData( dataCollector.PortCategory ) ); - - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - if( CheckLocalVariable( ref dataCollector ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - Vector3 value = m_defaultValue; - string result = string.Empty; - switch( outputId ) - { - case 0: - { - result = m_precisionString + "(" + value.x + "," + value.y + "," + value.z + ")"; - } - break; - - case 1: - { - result = value.x.ToString(); - } - break; - case 2: - { - result = value.y.ToString(); - } - break; - case 3: - { - result = value.z.ToString(); - } - break; - } - - if( result.Equals( string.Empty ) ) - { - UIUtils.ShowMessage( UniqueId, "Vector3Node generating empty code", MessageSeverity.Warning ); - } - return result; - } - - public override string GetPropertyValue() - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Vector) = (" + m_defaultValue.x + "," + m_defaultValue.y + "," + m_defaultValue.z + ",0)"; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetVector( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetVector( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetVector( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToVector3( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - m_materialValue = IOUtils.StringToVector3( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector3ToString( m_defaultValue ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector3ToString( m_materialValue ) ); - } - - public override void SetGlobalValue() { Shader.SetGlobalVector( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalVector( m_propertyName ); } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue.x.ToString( Mathf.Abs( m_materialValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.y.ToString( Mathf.Abs( m_materialValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.z.ToString( Mathf.Abs( m_materialValue.z ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) : - m_defaultValue.x.ToString( Mathf.Abs( m_defaultValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.y.ToString( Mathf.Abs( m_defaultValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.z.ToString( Mathf.Abs( m_defaultValue.z ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ); - } - - public Vector3 Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs.meta deleted file mode 100644 index 467beba5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector3Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 943f4b4fc1fa5214b8934bf4fb76474b -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs deleted file mode 100644 index e729b0d0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs +++ /dev/null @@ -1,320 +0,0 @@ -// 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( "Vector4", "Constants And Properties", "Vector4 property", null, KeyCode.Alpha4 )] - public sealed class Vector4Node : PropertyNode - { - [SerializeField] - private Vector4 m_defaultValue = Vector4.zero; - - [SerializeField] - private Vector4 m_materialValue = Vector4.zero; - - private const float LabelWidth = 8; - - private int m_cachedPropertyId = -1; - - private bool m_isEditingFields; - private Vector4 m_previousValue = Vector4.zero; - private string[] m_fieldText = new string[] { "0", "0", "0", "0" }; - - public Vector4Node() : base() { } - public Vector4Node( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Vector" ); - m_insideSize.Set( 50, 40 ); - m_selectedLocation = PreviewLocation.BottomCenter; - AddOutputVectorPorts( WirePortDataType.FLOAT4, "XYZW" ); - m_previewShaderGUID = "aac241d0e47a5a84fbd2edcd640788dc"; - m_srpBatcherCompatible = true; - m_showHybridInstancedUI = true; - } - - public override void CopyDefaultsToMaterial() - { - m_materialValue = m_defaultValue; - } - - public override void DrawSubProperties() - { - m_defaultValue = EditorGUILayoutVector4Field( Constants.DefaultValueLabel, m_defaultValue ); - } - - public override void DrawMaterialProperties() - { - if ( m_materialMode ) - EditorGUI.BeginChangeCheck(); - - m_materialValue = EditorGUILayoutVector4Field( Constants.MaterialValueLabel, m_materialValue ); - if ( m_materialMode && EditorGUI.EndChangeCheck() ) - m_requireMaterialUpdate = true; - - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_InputVector" ); - - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_materialValue[ 0 ], m_materialValue[ 1 ], m_materialValue[ 2 ], m_materialValue[ 3 ] ) ); - else - PreviewMaterial.SetVector( m_cachedPropertyId, new Vector4( m_defaultValue[ 0 ], m_defaultValue[ 1 ], m_defaultValue[ 2 ], m_defaultValue[ 3 ] ) ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos = m_remainingBox; - m_propertyDrawPos.x = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if ( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if ( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( m_isEditingFields && m_currentParameterType != PropertyType.Global ) - { - EditorGUI.BeginChangeCheck(); - for ( int i = 0; i < 4; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - float val = m_materialValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_materialValue[ i ] = val; - } - else - { - float val = m_defaultValue[ i ]; - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom ); - m_defaultValue[ i ] = val; - } - } - if ( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_requireMaterialUpdate = m_materialMode; - BeginDelayedDirtyProperty(); - //m_propertyNameIsDirty = true; - } - } - else if ( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - bool guiEnabled = GUI.enabled; - GUI.enabled = m_currentParameterType != PropertyType.Global; - - for( int i = 0; i < 4; i++ ) - { - m_propertyDrawPos.y = m_outputPorts[ i + 1 ].Position.y - 2 * drawInfo.InvertedZoom; - - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - if( GUI.enabled ) - { - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - } - if ( m_materialMode && m_currentParameterType != PropertyType.Constant ) - { - if ( m_previousValue[ i ] != m_materialValue[ i ] ) - { - m_previousValue[ i ] = m_materialValue[ i ]; - m_fieldText[ i ] = m_materialValue[ i ].ToString(); - } - } - else - { - if ( m_previousValue[ i ] != m_defaultValue[ i ] ) - { - m_previousValue[ i ] = m_defaultValue[ i ]; - m_fieldText[ i ] = m_defaultValue[ i ].ToString(); - } - } - - GUI.Label( fakeField, m_fieldText[ i ], UIUtils.MainSkin.textField ); - } - GUI.enabled = guiEnabled; - } - } - - public override void ConfigureLocalVariable( ref MasterNodeDataCollector dataCollector ) - { - Vector4 value = m_defaultValue; - dataCollector.AddLocalVariable( UniqueId, CreateLocalVarDec( value.x + "," + value.y + "," + value.z + "," + value.w ) ); - m_outputPorts[ 0 ].SetLocalValue( m_propertyName, dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( m_propertyName + ".x" , dataCollector.PortCategory ); - m_outputPorts[ 2 ].SetLocalValue( m_propertyName + ".y" , dataCollector.PortCategory ); - m_outputPorts[ 3 ].SetLocalValue( m_propertyName + ".z" , dataCollector.PortCategory ); - m_outputPorts[ 4 ].SetLocalValue( m_propertyName + ".w", dataCollector.PortCategory ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - if ( m_currentParameterType != PropertyType.Constant ) - return GetOutputVectorItem( 0, outputId, PropertyData( dataCollector.PortCategory ) ); - - if ( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - if ( CheckLocalVariable( ref dataCollector ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - Vector4 value = m_defaultValue; - string result = string.Empty; - switch ( outputId ) - { - case 0: - { - result = m_precisionString+"(" + value.x + "," + value.y + "," + value.z + "," + value.w + ")"; - } - break; - - case 1: - { - result = value.x.ToString(); - } - break; - case 2: - { - result = value.y.ToString(); - } - break; - case 3: - { - result = value.z.ToString(); - } - break; - case 4: - { - result = value.w.ToString(); - } - break; - } - - if ( result.Equals( string.Empty ) ) - { - UIUtils.ShowMessage( UniqueId, "Vector4Node generating empty code", MessageSeverity.Warning ); - } - return result; - } - - public override string GetPropertyValue() - { - return PropertyAttributes + m_propertyName + "(\"" + m_propertyInspectorName + "\", Vector) = (" + m_defaultValue.x + "," + m_defaultValue.y + "," + m_defaultValue.z + "," + m_defaultValue.w + ")"; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetVector( m_propertyName, m_materialValue ); - } - } - - public override void SetMaterialMode( Material mat , bool fetchMaterialValues ) - { - base.SetMaterialMode( mat , fetchMaterialValues ); - if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_materialValue = mat.GetVector( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_materialValue = material.GetVector( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_defaultValue = IOUtils.StringToVector4( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - m_materialValue = IOUtils.StringToVector4( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector4ToString( m_defaultValue ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector4ToString( m_materialValue ) ); - } - - public override void SetGlobalValue() { Shader.SetGlobalVector( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalVector( m_propertyName ); } - - public override string GetPropertyValStr() - { - return ( m_materialMode && m_currentParameterType != PropertyType.Constant ) ? m_materialValue.x.ToString( Mathf.Abs( m_materialValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.y.ToString( Mathf.Abs( m_materialValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.z.ToString( Mathf.Abs( m_materialValue.z ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_materialValue.w.ToString( Mathf.Abs( m_materialValue.w ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) : - m_defaultValue.x.ToString( Mathf.Abs( m_defaultValue.x ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.y.ToString( Mathf.Abs( m_defaultValue.y ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.z.ToString( Mathf.Abs( m_defaultValue.z ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ) + IOUtils.VECTOR_SEPARATOR + - m_defaultValue.w.ToString( Mathf.Abs( m_defaultValue.w ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel ); - } - - public Vector4 Value - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs.meta deleted file mode 100644 index 1cccc215..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/Vector4Node.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3bc3c79c7cc57df49bedb9d9b64b0bea -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs deleted file mode 100644 index c0570974..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Custom Add Node", "Debug", "Custom Node Debug ( Only for debug purposes)", null, UnityEngine.KeyCode.None, false )] - public sealed class CustomAddNode : CustomNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputsFromString( "customOut0", "#IP2*(#IP0 + #IP1 / #IP2)" ); - AddOutputsFromString( "customOut1", "#IP3 + #IP0*#IP2 + #IP1 / #IP2" ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs.meta deleted file mode 100644 index 771b8a61..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomAddNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6fdecc48f5be618428240490565e9d8b -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs deleted file mode 100644 index bffd2b4f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs +++ /dev/null @@ -1,183 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class CustomNodeOutputData - { - public string expression; - public string name; - public List<CustomNodeInputData> inputData; - - public CustomNodeOutputData( string newName, string newExpression ) - { - name = newName; - expression = newExpression; - inputData = new List<CustomNodeInputData>(); - } - public void Destroy() - { - inputData.Clear(); - inputData = null; - } - - public override string ToString() - { - string result = "name: " + name + " outputExpression: " + expression + '\n'; - for ( int i = 0; i < inputData.Count; i++ ) - { - result += inputData[ i ].ToString() + '\n'; - } - return result; - } - } - - [Serializable] - public class CustomNodeInputData - { - public int index; - public int length; - public string name; - public CustomNodeInputData( int newIndex, int newLength, string newName ) - { - index = newIndex; - length = newLength; - name = newName; - - } - - public override string ToString() - { - return "index: " + index + " length: " + length + " name: " + name; - } - } - - [Serializable] - public class CustomNode : ParentNode - { - [SerializeField] - private List<string> m_includes; - - [SerializeField] - private List<CustomNodeOutputData> m_outputData; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_outputData = new List<CustomNodeOutputData>(); - } - - public void AddIncludes( string newInclude ) - { - m_includes.Add( newInclude ); - } - - protected void AddOutputsFromString( string outputName, string output ) - { - AddOutputPort( WirePortDataType.OBJECT, outputName ); - - CustomNodeOutputData currOutputData = new CustomNodeOutputData( outputName, output ); - - - // Get existing input nodes so we can test for duplicates - Dictionary<string, InputPort> existingPorts = InputPortsDict; - - // Create dictionary to prevent duplicates when dealing with expresssions with multiple occurences of an input - Dictionary<string, string> inputDuplicatePrevention = new Dictionary<string, string>(); - - - // Get all inputs on the expression and save their info - int[] indexes = output.AllIndexesOf( Constants.CNIP ); - for ( int i = 0; i < indexes.Length; i++ ) - { - string name = output.Substring( indexes[ i ], Constants.CNIP.Length + 1 ); - currOutputData.inputData.Add( new CustomNodeInputData( indexes[ i ], Constants.CNIP.Length + 1, name ) ); - - if ( !inputDuplicatePrevention.ContainsKey( name ) && !existingPorts.ContainsKey( name ) ) - { - inputDuplicatePrevention.Add( name, name ); - AddInputPort( WirePortDataType.OBJECT, false, name ); - } - } - - inputDuplicatePrevention.Clear(); - inputDuplicatePrevention = null; - - existingPorts.Clear(); - existingPorts = null; - - m_outputData.Add( currOutputData ); - - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - if ( outputId < m_outputData.Count ) - { - Dictionary<string, InputPort> inputs = InputPortsDict; - - string value = m_outputData[ outputId ].expression; - for ( int i = 0; i < m_outputData[ outputId ].inputData.Count; i++ ) - { - if ( inputs.ContainsKey( m_outputData[ outputId ].inputData[ i ].name ) ) - { - InputPort inputPort = inputs[ m_outputData[ outputId ].inputData[ i ].name ]; - if ( inputPort != null ) - { - string inputValue = inputPort.GenerateShaderForOutput( ref dataCollector, WirePortDataType.OBJECT, ignoreLocalvar ); - value = value.Replace( m_outputData[ outputId ].inputData[ i ].name, inputValue ); - } - else - { - UIUtils.ShowMessage( UniqueId, m_outputData[ outputId ].inputData[ i ].name + " invalid on the inputs list", MessageSeverity.Error ); - return string.Empty; - } - } - else - { - UIUtils.ShowMessage( UniqueId, m_outputData[ outputId ].inputData[ i ].name + " Not found on the inputs list", MessageSeverity.Error ); - return string.Empty; - } - } - return value; - - } - - return string.Empty; - } - public void DumpOutputData() - { - for ( int i = 0; i < m_outputData.Count; i++ ) - { - Debug.Log( m_outputData[ i ] ); - } - } - - public override void Destroy() - { - base.Destroy(); - - if ( m_outputData != null ) - { - for ( int i = 0; i < m_outputData.Count; i++ ) - { - m_outputData[ i ].Destroy(); - } - m_outputData.Clear(); - m_outputData = null; - } - if ( m_includes != null ) - { - m_includes.Clear(); - m_includes = null; - } - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs.meta deleted file mode 100644 index d5cd5ec0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/CustomNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c89fd369755de3e49a669e8e5daa8c2f -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs deleted file mode 100644 index 6a423446..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -namespace AmplifyShaderEditor -{ - public class DrawInfo - { - public Rect TransformedCameraArea; - public Rect CameraArea; - public Vector2 MousePosition; - public Vector2 CameraOffset; - public float InvertedZoom; - public bool LeftMouseButtonPressed; - public EventType CurrentEventType; - public Vector2 TransformedMousePos; - public bool ZoomChanged; - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs.meta deleted file mode 100644 index 8783ef2f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DrawInfo.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 36f40ed0b172d8f45810b3f6b8e2243d -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs deleted file mode 100644 index e4bb7e9f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs +++ /dev/null @@ -1,520 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class DynamicTypeNode : ParentNode - { - protected string m_inputA = string.Empty; - protected string m_inputB = string.Empty; - protected List<string> m_extensibleInputResults; - protected bool m_dynamicOutputType = true; - - protected bool m_extensibleInputPorts = false; - protected bool m_allowMatrixCheck = false; - protected bool m_vectorMatrixOps = false; - //[SerializeField] - private int m_inputCount = 2; - - //[SerializeField] - private int m_lastInputCount = 2; - - private bool m_previouslyDragging = false; - private int m_beforePreviewCount = 0; - - [UnityEngine.SerializeField] - protected WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - protected WirePortDataType[] m_dynamicRestrictions = - { - WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_useInternalPortData = true; - m_textLabelWidth = 35; - AddPorts(); - } - - protected virtual void AddPorts() - { - AddInputPort( WirePortDataType.FLOAT, false, "A" ); - AddInputPort( WirePortDataType.FLOAT, false, "B" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].CreatePortRestrictions( m_dynamicRestrictions ); - m_inputPorts[ 1 ].CreatePortRestrictions( m_dynamicRestrictions ); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - UpdateConnection( inputPortId ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateDisconnectedConnection( portId ); - UpdateConnection( portId ); - UpdateEmptyInputPorts( true ); - } - - void UpdateDisconnectedConnection( int portId ) - { - if( m_extensibleInputPorts || m_allowMatrixCheck ) - { - int higher = 0; - int groupOneType = 0; - int groupTwoType = 0; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - int currentPriority = UIUtils.GetPriority( m_inputPorts[ i ].DataType ); - if( !m_vectorMatrixOps && currentPriority < 3 ) - currentPriority += 7; - if( currentPriority > higher && currentPriority > 2 ) - { - higher = currentPriority; - m_mainDataType = m_inputPorts[ i ].DataType; - } - switch( m_inputPorts[ i ].DataType ) - { - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - groupOneType++; - groupTwoType++; - } - break; - case WirePortDataType.FLOAT3x3: - { - groupOneType++; - } - break; - case WirePortDataType.FLOAT4x4: - { - groupTwoType++; - } - break; - } - } - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( !m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].ChangeType( m_mainDataType, false ); - } - } - - if( groupOneType > 0 && m_mainDataType == WirePortDataType.FLOAT4x4 ) - { - m_errorMessageTooltip = "Doing this operation with FLOAT4x4 value only works against other FLOAT4x4 or FLOAT values"; - m_showErrorMessage = true; - } - else if( groupTwoType > 0 && m_mainDataType == WirePortDataType.FLOAT3x3 ) - { - m_errorMessageTooltip = "Doing this operation with FLOAT3x3 value only works against other FLOAT3x3 or FLOAT values"; - m_showErrorMessage = true; - } - else - { - m_showErrorMessage = false; - } - - if( m_dynamicOutputType ) - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - else - - if( m_inputPorts[ 0 ].DataType != m_inputPorts[ 1 ].DataType ) - { - int otherPortId = ( portId + 1 ) % 2; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainDataType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainDataType, false ); - if( m_dynamicOutputType ) - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - else - { - if( UIUtils.GetPriority( m_inputPorts[ 0 ].DataType ) > UIUtils.GetPriority( m_inputPorts[ 1 ].DataType ) ) - { - m_mainDataType = m_inputPorts[ 0 ].DataType; - m_inputPorts[ 1 ].ChangeType( m_mainDataType, false ); - } - else - { - m_mainDataType = m_inputPorts[ 1 ].DataType; - m_inputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - if( m_dynamicOutputType ) - { - if( m_mainDataType != m_outputPorts[ 0 ].DataType ) - { - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - } - } - } - } - - void UpdateConnection( int portId ) - { - if( m_extensibleInputPorts || m_allowMatrixCheck ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - - int higher = 0; - int groupOneType = 0; - int groupTwoType = 0; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - int currentPriority = UIUtils.GetPriority( m_inputPorts[ i ].DataType ); - if( !m_vectorMatrixOps && currentPriority < 3 ) - currentPriority += 7; - if( currentPriority > higher ) - { - higher = currentPriority; - m_mainDataType = m_inputPorts[ i ].DataType; - } - switch( m_inputPorts[ i ].DataType ) - { - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - groupOneType++; - groupTwoType++; - } - break; - case WirePortDataType.FLOAT3x3: - { - groupOneType++; - } - break; - case WirePortDataType.FLOAT4x4: - { - groupTwoType++; - } - break; - } - } - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( !m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].ChangeType( m_mainDataType, false ); - } - } - if( groupOneType > 0 && m_mainDataType == WirePortDataType.FLOAT4x4 ) - { - m_errorMessageTooltip = "Doing this operation with FLOAT4x4 value only works against other FLOAT4x4 or FLOAT values"; - m_showErrorMessage = true; - } - else if( groupTwoType > 0 && m_mainDataType == WirePortDataType.FLOAT3x3 ) - { - m_errorMessageTooltip = "Doing this operation with FLOAT3x3 value only works against other FLOAT3x3 or FLOAT values"; - m_showErrorMessage = true; - } - else - { - m_showErrorMessage = false; - } - - if( m_dynamicOutputType ) - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - else - { - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = ( portId + 1 ) % 2; - if( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_inputPorts[ portId ].DataType, false ); - } - - if( m_inputPorts[ 0 ].DataType == m_inputPorts[ 1 ].DataType ) - { - m_mainDataType = m_inputPorts[ 0 ].DataType; - if( m_dynamicOutputType ) - m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false ); - } - else - { - if( UIUtils.GetPriority( m_inputPorts[ 0 ].DataType ) > UIUtils.GetPriority( m_inputPorts[ 1 ].DataType ) ) - { - m_mainDataType = m_inputPorts[ 0 ].DataType; - } - else - { - m_mainDataType = m_inputPorts[ 1 ].DataType; - } - - if( m_dynamicOutputType ) - { - if( m_mainDataType != m_outputPorts[ 0 ].DataType ) - { - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - } - } - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - - if( !m_extensibleInputPorts ) - return; - - if( m_previouslyDragging != m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid && m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.NodeId != UniqueId ) - { - if( m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid ) - { - m_beforePreviewCount = 2; - for( int i = 2; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - m_beforePreviewCount++; - } - } - - m_inputCount = m_beforePreviewCount + 1; - if( m_inputCount <= 10 ) - { - if( m_inputCount > m_lastInputCount ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoCreateDynamicPortId ); - RecordObject( Constants.UndoCreateDynamicPortId ); - - AddInputPort( m_mainDataType, false, ( ( char ) ( 'A' + m_inputCount - 1 ) ).ToString() ); - m_inputPorts[ m_inputCount - 1 ].CreatePortRestrictions( m_dynamicRestrictions ); - } - - m_lastInputCount = m_inputCount; - m_sizeIsDirty = true; - m_isDirty = true; - SetSaveIsDirty(); - } - } - else - { - bool hasEmpty = CheckValidConnections(); - if( hasEmpty ) - UpdateEmptyInputPorts( false ); - } - - m_previouslyDragging = m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid; - } - - UpdateEmptyInputPorts( false ); - } - - private bool CheckValidConnections() - { - if( !m_extensibleInputPorts ) - return false; - - bool hasEmptyConnections = false; - - bool hasMatrix = m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 || m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4x4 || m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT3x3 || m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT4x4; - - if( m_inputPorts.Count != m_beforePreviewCount ) - { - if( hasMatrix ) - { - bool showError = false; - for( int i = m_inputPorts.Count - 1; i >= 2; i-- ) - { - if( m_inputPorts[ i ].IsConnected ) - { - showError = true; - m_inputPorts[ i ].FullDeleteConnections(); - } - - hasEmptyConnections = true; - } - if( showError ) - m_containerGraph.ParentWindow.ShowMessage( UniqueId, "Matrix operations are only valid for the first two inputs to prevent errors" ); - } - else - { - for( int i = m_inputPorts.Count - 1; i >= 2; i-- ) - { - if( m_inputPorts[ i ].DataType == WirePortDataType.FLOAT3x3 || m_inputPorts[ i ].DataType == WirePortDataType.FLOAT4x4 ) - { - m_containerGraph.ParentWindow.ShowMessage( UniqueId, "Matrix operations are only valid for the first two inputs to prevent errors" ); - m_inputPorts[ i ].FullDeleteConnections(); - hasEmptyConnections = true; - } - else if( !m_inputPorts[ i ].IsConnected ) - { - hasEmptyConnections = true; - } - } - } - } - - return hasEmptyConnections; - } - - private void UpdateEmptyInputPorts( bool recordUndo ) - { - if( !m_extensibleInputPorts ) - return; - NodeWireReferencesUtils wireReferenceUtils = m_containerGraph.ParentWindow.WireReferenceUtils; - if( !wireReferenceUtils.OutputPortReference.IsValid ) - { - if( recordUndo ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoDeleteDynamicPortId ); - RecordObject( Constants.UndoDeleteDynamicPortId ); - } - - bool hasDeleted = false; - m_inputCount = 2; - for( int i = m_inputPorts.Count - 1; i >= 2; i-- ) - { - if( !m_inputPorts[ i ].IsConnected ) - { - hasDeleted = true; - if( wireReferenceUtils.InputPortReference.IsValid && - wireReferenceUtils.InputPortReference.NodeId == UniqueId && - wireReferenceUtils.InputPortReference.PortId == m_inputPorts[ i ].PortId ) - { - wireReferenceUtils.InputPortReference.Invalidate(); - } - DeleteInputPortByArrayIdx( i ); - } - else - { - m_inputCount++; - } - } - - if( hasDeleted || m_inputCount != m_lastInputCount ) - { - for( int i = 2; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].Name = ( ( char ) ( 'A' + i ) ).ToString(); - } - - m_beforePreviewCount = m_inputPorts.Count; - m_inputCount = m_beforePreviewCount; - m_lastInputCount = m_inputCount; - m_sizeIsDirty = true; - m_isDirty = true; - SetSaveIsDirty(); - } - } - - m_inputCount = Mathf.Clamp( m_inputCount, 2, 10 ); - } - - public virtual string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !m_extensibleInputPorts ) - SetInputData( outputId, ref dataCollector, ignoreLocalvar ); - else - SetExtensibleInputData( outputId, ref dataCollector, ignoreLocalvar ); - return string.Empty; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - protected void SetInputData( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - m_inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_inputPorts[ 0 ].DataType != m_mainDataType ) - { - m_inputA = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, m_mainDataType, m_inputA ); - } - m_inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - if( m_inputPorts[ 1 ].DataType != m_mainDataType ) - { - m_inputB = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, m_mainDataType, m_inputB ); - } - } - - protected void SetExtensibleInputData( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - m_extensibleInputResults = new List<string>(); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_extensibleInputResults.Add( m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ) ); - if( m_inputPorts[ i ].DataType != m_mainDataType && m_inputPorts[ i ].DataType != WirePortDataType.FLOAT && m_inputPorts[ i ].DataType != WirePortDataType.INT ) - { - m_extensibleInputResults[ i ] = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_extensibleInputResults[ i ], m_inputPorts[ i ].DataType, m_mainDataType, m_extensibleInputResults[ i ] ); - } - } - } - - void UpdatePorts() - { - m_lastInputCount = Mathf.Clamp( m_inputCount, 2, 10 ); - - for( int i = 2; i < m_inputCount; i++ ) - { - AddInputPort( m_mainDataType, false, ( ( char ) ( 'A' + i ) ).ToString() ); - m_inputPorts[ i ].CreatePortRestrictions( m_dynamicRestrictions ); - } - - m_sizeIsDirty = true; - SetSaveIsDirty(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( m_extensibleInputPorts && UIUtils.CurrentShaderVersion() > 10005 ) - { - m_inputCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdatePorts(); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - if( m_extensibleInputPorts ) - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputCount ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs.meta deleted file mode 100644 index bac40f90..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/DynamicTypeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5b60c440b5db81c4d9df9c048aa22b48 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs.meta deleted file mode 100644 index 2eaea63d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 868823c936b45494aa7f3ce9f16b5372 -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs deleted file mode 100644 index e8c9fc58..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs +++ /dev/null @@ -1,130 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Camera Depth Fade", "Camera And Screen", "Outputs a 0 - 1 gradient representing the distance between the surface of this object and camera near plane" )] - public sealed class CameraDepthFade : ParentNode - { - //{0} - Eye Depth - //{1} - Offset - //{2} - Distance - private const string CameraDepthFadeFormat = "(( {0} -_ProjectionParams.y - {1} ) / {2})"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Vertex Position", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, "Length", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT, false, "Offset", -1, MasterNodePortCategory.Fragment, 1 ); - GetInputPortByUniqueId( 0 ).FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - m_useInternalPortData = true; - } - - 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 ); - - InputPort vertexPort = GetInputPortByUniqueId( 2 ); - InputPort lengthPort = GetInputPortByUniqueId( 0 ); - InputPort offsetPort = GetInputPortByUniqueId( 1 ); - - string distance = lengthPort.GeneratePortInstructions( ref dataCollector ); - string offset = offsetPort.GeneratePortInstructions( ref dataCollector ); - - string value = string.Empty; - string eyeDepth = string.Empty; - - if( dataCollector.IsTemplate ) - { - if( vertexPort.IsConnected ) - { - string varName = "customSurfaceDepth" + OutputId; - GenerateInputInVertex( ref dataCollector, 2, varName, false ); - - string formatStr = string.Empty; - if( dataCollector.IsSRP ) - formatStr = "-TransformWorldToView(TransformObjectToWorld({0})).z"; - else - formatStr = "-UnityObjectToViewPos({0}).z"; - - string eyeInstruction = string.Format( formatStr, varName ); - eyeDepth = "customEye" + OutputId; - dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( eyeDepth, WirePortDataType.FLOAT, CurrentPrecisionType, eyeInstruction ); - } - else - { - eyeDepth = dataCollector.TemplateDataCollectorInstance.GetEyeDepth( CurrentPrecisionType ); - } - - value = string.Format( CameraDepthFadeFormat, eyeDepth, offset, distance ); - RegisterLocalVariable( 0, value, ref dataCollector, "cameraDepthFade" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - string vertexVarName = string.Empty; - if( vertexPort.IsConnected ) - { - vertexVarName = vertexPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - vertexVarName = Constants.VertexShaderInputStr + ".vertex.xyz"; - } - - //dataCollector.AddVertexInstruction( "float cameraDepthFade" + UniqueId + " = (( -UnityObjectToViewPos( " + Constants.VertexShaderInputStr + ".vertex.xyz ).z -_ProjectionParams.y - " + offset + " ) / " + distance + ");", UniqueId ); - value = string.Format( CameraDepthFadeFormat, "-UnityObjectToViewPos( " + vertexVarName + " ).z", offset, distance ); - RegisterLocalVariable( 0, value, ref dataCollector, "cameraDepthFade" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - - if( dataCollector.TesselationActive ) - { - if( vertexPort.IsConnected ) - { - string vertexValue = vertexPort.GeneratePortInstructions( ref dataCollector ); - eyeDepth = "customSurfaceDepth" + OutputId; - RegisterLocalVariable( 0, string.Format( "-UnityObjectToViewPos( {0} ).z", vertexValue ), ref dataCollector, eyeDepth ); - } - else - { - eyeDepth = GeneratorUtils.GenerateScreenDepthOnFrag( ref dataCollector, UniqueId, CurrentPrecisionType ); - } - } - else - { - - if( vertexPort.IsConnected ) - { - string varName = "customSurfaceDepth" + OutputId; - GenerateInputInVertex( ref dataCollector, 2, varName, false ); - dataCollector.AddToInput( UniqueId, varName, WirePortDataType.FLOAT ); - string vertexInstruction = "-UnityObjectToViewPos( " + varName + " ).z"; - dataCollector.AddToVertexLocalVariables( UniqueId, Constants.VertexShaderOutputStr + "." + varName + " = " + vertexInstruction + ";" ); - eyeDepth = Constants.InputVarStr + "." + varName; - } - else - { - dataCollector.AddToInput( UniqueId, "eyeDepth", WirePortDataType.FLOAT ); - string instruction = "-UnityObjectToViewPos( " + Constants.VertexShaderInputStr + ".vertex.xyz ).z"; - dataCollector.AddToVertexLocalVariables( UniqueId, Constants.VertexShaderOutputStr + ".eyeDepth = " + instruction + ";" ); - eyeDepth = Constants.InputVarStr + ".eyeDepth"; - } - } - - value = string.Format( CameraDepthFadeFormat, eyeDepth, offset, distance ); - RegisterLocalVariable( 0, value, ref dataCollector, "cameraDepthFade" + OutputId ); - //dataCollector.AddToLocalVariables( UniqueId, "float cameraDepthFade" + UniqueId + " = (( " + Constants.InputVarStr + ".eyeDepth -_ProjectionParams.y - "+ offset + " ) / " + distance + ");" ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs.meta deleted file mode 100644 index 2e13b8fb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 96f38a9f14906ca49b505b8e305c37ec -timeCreated: 1491316341 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs deleted file mode 100644 index 362415d3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Compute Grab Screen Pos", "Camera And Screen", "Computes texture coordinate for doing a screenspace-mapped texture sample. Input is clip space position" )] - public sealed class ComputeGrabScreenPosHlpNode : HelperParentNode - { - private readonly string[] ComputeGrabScreenPosFunction = - { - "inline float4 ComputeGrabScreenPos( float4 pos )\n", - "{\n", - "#if UNITY_UV_STARTS_AT_TOP\n", - "\tfloat scale = -1.0;\n", - "#else\n", - "\tfloat scale = 1.0;\n", - "#endif\n", - "\tfloat4 o = pos * 0.5f;\n", - "\to.xy = float2( o.x, o.y*scale ) + o.w;\n", - "#ifdef UNITY_SINGLE_PASS_STEREO\n", - "\to.xy = TransformStereoScreenSpaceTex ( o.xy, pos.w );\n", - "#endif\n", - "\to.zw = pos.zw;\n", - "\treturn o;\n", - "}\n" - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "ComputeGrabScreenPos"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "XYZW"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "computeGrabScreenPos" + OutputId; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - { - dataCollector.AddFunction( m_funcType, ComputeGrabScreenPosFunction, false ); - } - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs.meta deleted file mode 100644 index 4e68be78..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5fe7f4be962b9e8459eb156503b99d41 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs deleted file mode 100644 index 883009b9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEngine; -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Compute Screen Pos", "Camera And Screen", "Computes texture coordinate for doing a screenspace-mapped texture sample. Input is clip space position" )] - public sealed class ComputeScreenPosHlpNode : HelperParentNode - { - [SerializeField] - private bool m_normalize = false; - private string NormalizeStr = "Normalize"; - private readonly string[] NormalizeOps = - { "{0} = {0} / {0}.w;", - "{0}.z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? {0}.z : {0}.z* 0.5 + 0.5;" - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "ComputeScreenPos"; - m_funcHDFormatOverride = "ComputeScreenPos( {0} , _ProjectionParams.x )"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "XYZW"; - m_autoWrapProperties = true; - m_previewShaderGUID = "97bd4895d847d764eb21d2bf7aa13671"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - m_previewMaterialPassId = m_normalize ? 1 : 0; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "computeScreenPos" + OutputId; - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_normalize = EditorGUILayoutToggle( NormalizeStr, m_normalize ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - if( m_normalize ) - { - dataCollector.AddLocalVariable( UniqueId, string.Format( NormalizeOps[ 0 ], m_localVarName ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( NormalizeOps[ 1 ], m_localVarName ) ); - } - return result; - } - - 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 ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 15404 ) - { - m_normalize = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs.meta deleted file mode 100644 index a5dba00e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c220606396d6e6048a901f217be1435e -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs deleted file mode 100644 index fc094119..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Decode Depth Normal", "Miscellaneous", "Decodes both Depth and Normal from a previously encoded pixel value" )] - public sealed class DecodeDepthNormalNode : ParentNode - { - private const string DecodeDepthNormalFunc = "DecodeDepthNormal( {0}, {1}, {2} );"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, "Encoded" ); - AddOutputPort( WirePortDataType.FLOAT, "Depth" ); - AddOutputPort( WirePortDataType.FLOAT3, "Normal" ); - m_previewShaderGUID = "dbf37c4d3ce0f0b41822584d6c9ba203"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - string encodedValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string depthDecodedVal = "depthDecodedVal" + OutputId; - string normalDecodedVal = "normalDecodedVal" + OutputId; - RegisterLocalVariable( 0, "0", ref dataCollector, depthDecodedVal ); - RegisterLocalVariable( 1, "float3(0,0,0)", ref dataCollector, normalDecodedVal ); - dataCollector.AddLocalVariable( UniqueId, string.Format( DecodeDepthNormalFunc, encodedValue , depthDecodedVal, normalDecodedVal) ); - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs.meta deleted file mode 100644 index 032de060..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1cc4e3c718669d54c97614ac6abcfaff -timeCreated: 1513695160 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs deleted file mode 100644 index a80ad39d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Decode Float RGBA", "Miscellaneous", "Decodes RGBA color into a float" )] - public sealed class DecodeFloatRGBAHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "DecodeFloatRGBA"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 0 ].Name = "RGBA"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - m_previewShaderGUID = "f71b31b15ff3f2042bafbed40acd29f4"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "decodeFloatRGBA" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs.meta deleted file mode 100644 index 132cd57d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2c5479ff48207cf43a308ec9f110fa9f -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs deleted file mode 100644 index 3751b228..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Decode Float RG", "Miscellaneous", "Decodes a previously-encoded RG float" )] - public sealed class DecodeFloatRGHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "DecodeFloatRG"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_inputPorts[ 0 ].Name = "RG"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - m_previewShaderGUID = "1fb3121b1c8febb4dbcc2a507a2df2db"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "decodeFloatRG" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs.meta deleted file mode 100644 index e436b075..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a965812ada2b83343a1f511273fcfc52 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs deleted file mode 100644 index a7f52ddf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Decode Lightmap", "Miscellaneous", "Decodes color from Unity lightmap (RGBM or dLDR depending on platform)" )] - public sealed class DecodeLightmapHlpNode : ParentNode - { - private const string m_funcStandard = "DecodeLightmap({0})"; - private string m_funcSRP = "DecodeLightmap({0},{1})"; - - private const string DecodeInstructionsLWValueStr = "half4 decodeLightmapInstructions = half4(LIGHTMAP_HDR_MULTIPLIER, LIGHTMAP_HDR_EXPONENT, 0.0h, 0.0h);"; - private const string DecodeInstructionsNameStr = "decodeLightmapInstructions"; - private readonly string[] DecodeInstructionsHDValueStr = - { - "#ifdef UNITY_LIGHTMAP_FULL_HDR//ase_decode_lightmap_0", - "\tbool useRGBMLightmap = false;//ase_decode_lightmap_1", - "\tfloat4 decodeLightmapInstructions = float4( 0.0, 0.0, 0.0, 0.0 );//ase_decode_lightmap_2", - "#else//ase_decode_lightmap//ase_decode_lightmap_3", - "\tbool useRGBMLightmap = true;//ase_decode_lightmap_4", - "#if defined(UNITY_LIGHTMAP_RGBM_ENCODING)//ase_decode_lightmap_5", - "\tfloat4 decodeLightmapInstructions = float4(34.493242, 2.2, 0.0, 0.0);//ase_decode_lightmap_6", - "#else//ase_decode_lightmap_7", - "\tfloat4 decodeLightmapInstructions = float4( 2.0, 2.2, 0.0, 0.0 );//ase_decode_lightmap_8", - "#endif//ase_decode_lightmap_9", - "#endif//ase_decode_lightmap_10" - }; - private string m_localVarName = null; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, "Value" ); - AddInputPort( WirePortDataType.FLOAT4, false, "Instructions" ); - - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - - m_previewShaderGUID = "c2d3bee1aee183343b31b9208cb402e9"; - m_useInternalPortData = true; - } - - public override string GetIncludes() - { - return Constants.UnityCgLibFuncs; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "decodeLightMap" + OutputId; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - m_inputPorts[ 1 ].Visible = m_containerGraph.ParentWindow.IsShaderFunctionWindow || m_containerGraph.IsSRP; - } - - 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 ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string finalResult = string.Empty; - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - string instructions = string.Empty; - if( m_inputPorts[ 1 ].IsConnected ) - { - instructions = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - if( dataCollector.TemplateDataCollectorInstance.IsHDRP ) - { - for( int i = 0; i < DecodeInstructionsHDValueStr.Length; i++ ) - { - dataCollector.AddLocalVariable( UniqueId, DecodeInstructionsHDValueStr[ i ] ); - } - } - else - { - dataCollector.AddLocalVariable( UniqueId, DecodeInstructionsLWValueStr ); - } - instructions = DecodeInstructionsNameStr; - - } - - finalResult = string.Format( m_funcSRP, value , instructions ); - - } - else - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - finalResult = string.Format( m_funcStandard, value ); - } - - RegisterLocalVariable( 0, finalResult, ref dataCollector, m_localVarName ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs.meta deleted file mode 100644 index 07aca766..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b3d1879d1e402b34f98b8e8cdf94d719 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs deleted file mode 100644 index a69b4997..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Decode View Normal Stereo", "Miscellaneous", "Decodes view space normal from enc4.xy" )] - public sealed class DecodeViewNormalStereoHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "DecodeViewNormalStereo"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - m_previewShaderGUID = "e996db1cc4510c84185cb9f933f916bb"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "decodeViewNormalStereo" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs.meta deleted file mode 100644 index 0bf44661..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 94df47461b7e6244eaf92b0dab7cc7ee -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs deleted file mode 100644 index cc6db43d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs +++ /dev/null @@ -1,168 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Depth Fade", "Surface Data", "Outputs a linear gradient representing the distance between the surface of this object and geometry behind" )] - public sealed class DepthFade : ParentNode - { - private const string ConvertToLinearStr = "Convert To Linear"; - private const string SaturateStr = "Saturate"; - private const string MirrorStr = "Mirror"; - - [SerializeField] - private bool m_convertToLinear = true; - - [SerializeField] - private bool m_saturate = false; - - [SerializeField] - private bool m_mirror = true; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Vertex Position", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "Distance",-1,MasterNodePortCategory.Fragment,0 ); - GetInputPortByUniqueId(0).FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - } - - 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; - InputPort vertexPosPort = GetInputPortByUniqueId( 1 ); - if( vertexPosPort.IsConnected ) - { - string vertexPosVar = "vertexPos" + OutputId; - GenerateInputInVertex( ref dataCollector, 1, vertexPosVar, false ); - screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalizedForValue( vertexPosVar, OutputId, ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos ); - } - else - { - if( dataCollector.IsTemplate ) - { - string ppsScreenPos = string.Empty; - if( !dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData( TemplateInfoOnSematics.SCREEN_POSITION_NORMALIZED, WirePortDataType.FLOAT4, PrecisionType.Float, ref ppsScreenPos, true, MasterNodePortCategory.Fragment ) ) - { - screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos ); - } - else - { - screenPosNorm = ppsScreenPos; - } - } - else - { - screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos ); - } - } - - string screenDepth = TemplateHelperFunctions.CreateDepthFetch( dataCollector, screenPosNorm ); - if( m_convertToLinear ) - { - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - screenDepth = string.Format( "LinearEyeDepth({0},_ZBufferParams)", screenDepth ); - else - screenDepth = string.Format( "LinearEyeDepth({0})", screenDepth ); - } - else - { - screenDepth = string.Format( "({0}*( _ProjectionParams.z - _ProjectionParams.y ))", screenDepth ); - } - - string distance = GetInputPortByUniqueId( 0 ).GeneratePortInstructions( ref dataCollector ); - - dataCollector.AddLocalVariable( UniqueId, "float screenDepth" + OutputId + " = " + screenDepth + ";" ); - - string finalVarName = "distanceDepth" + OutputId; - string finalVarValue = string.Empty; - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - finalVarValue = "( screenDepth" + OutputId + " - LinearEyeDepth( " + screenPosNorm + ".z,_ZBufferParams ) ) / ( " + distance + " )"; - else - finalVarValue = "( screenDepth" + OutputId + " - LinearEyeDepth( " + screenPosNorm + ".z ) ) / ( " + distance + " )"; - - if( m_mirror ) - { - finalVarValue = string.Format( "abs( {0} )", finalVarValue ); - } - - if( m_saturate ) - { - finalVarValue = string.Format( "saturate( {0} )", finalVarValue ); - } - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, finalVarName, finalVarValue ); - m_outputPorts[ 0 ].SetLocalValue( finalVarName, dataCollector.PortCategory ); - return GetOutputColorItem( 0, outputId, finalVarName ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_convertToLinear = EditorGUILayoutToggle( ConvertToLinearStr, m_convertToLinear ); - m_mirror = EditorGUILayoutToggle( MirrorStr, m_mirror ); - m_saturate = EditorGUILayoutToggle( SaturateStr, m_saturate ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() >= 13901 ) - { - m_convertToLinear = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 15607 ) - { - m_saturate = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15700 ) - { - m_mirror = 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_convertToLinear ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_saturate ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mirror ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs.meta deleted file mode 100644 index c302a611..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 279c74ce44e24204d803be6ec743c290 -timeCreated: 1491316341 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs deleted file mode 100644 index af599335..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Diffuse And Specular From Metallic", "Miscellaneous", "Gets Diffuse and Specular values from Metallic. Uses DiffuseAndSpecularFromMetallic function from UnityStandardUtils." )] - public class DiffuseAndSpecularFromMetallicNode : ParentNode - { - //half3 DiffuseAndSpecularFromMetallic (half3 albedo, half metallic, out half3 specColor, out half oneMinusReflectivity) - private const string FuncFormat = "DiffuseAndSpecularFromMetallic({0},{1},{2},{3})"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Albedo" ); - AddInputPort( WirePortDataType.FLOAT, false, "Metallic" ); - AddOutputPort( WirePortDataType.FLOAT3, "Out" ); - AddOutputPort( WirePortDataType.FLOAT3, "Spec Color" ); - AddOutputPort( WirePortDataType.FLOAT, "One Minus Reflectivity" ); - m_previewShaderGUID = "c7c4485750948a045b5dab0985896e17"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsSRP ) - { - UIUtils.ShowMessage( UniqueId, "Diffuse And Specular From Metallic Node not compatible with SRP" ); - return m_outputPorts[0].ErrorValue; - } - - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ); - - string albedo = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string metallic = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string specColorVar = "specColor" + OutputId; - string oneMinusReflectivityVar = "oneMinusReflectivity" + OutputId; - string varName = "diffuseAndSpecularFromMetallic" + OutputId; - - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT3, specColorVar, "(0).xxx" ); - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT, oneMinusReflectivityVar, "0" ); - - - string varValue = string.Format( FuncFormat, albedo, metallic, specColorVar, oneMinusReflectivityVar ); - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT3, varName, varValue ); - m_outputPorts[ 0 ].SetLocalValue( varName, dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( specColorVar, dataCollector.PortCategory ); - m_outputPorts[ 2 ].SetLocalValue( oneMinusReflectivityVar, dataCollector.PortCategory ); - - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs.meta deleted file mode 100644 index 4ab9e6f0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a792f114a5433af499dce78ebe05a9e6 -timeCreated: 1534266498 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs deleted file mode 100644 index a4dfafb1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs +++ /dev/null @@ -1,284 +0,0 @@ -// 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( "Dither", "Camera And Screen", "Generates a dithering pattern" )] - public sealed class DitheringNode : ParentNode - { - private const string InputTypeStr = "Pattern"; - private const string CustomScreenPosStr = "screenPosition"; - - private string m_functionHeader = "Dither4x4Bayer( {0}, {1} )"; - private string m_functionBody = string.Empty; - - [SerializeField] - private int m_selectedPatternInt = 0; - - [SerializeField] - private bool m_customScreenPos = false; - - private readonly string[] PatternsFuncStr = { "4x4Bayer", "8x8Bayer", "NoiseTex" }; - private readonly string[] PatternsStr = { "4x4 Bayer", "8x8 Bayer", "Noise Texture" }; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.SAMPLER2D, false, "Pattern"); - AddInputPort( WirePortDataType.FLOAT4, false, "Screen Position" ); - - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 110; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, PatternsStr[ m_selectedPatternInt ] ) ); - UpdatePorts(); - GeneratePattern(); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - - 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 Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_selectedPatternInt = m_upperLeftWidget.DrawWidget( this, m_selectedPatternInt, PatternsStr ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - GeneratePattern(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_selectedPatternInt = EditorGUILayoutPopup( "Pattern", m_selectedPatternInt, PatternsStr ); - if ( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - GeneratePattern(); - } - EditorGUI.BeginChangeCheck(); - m_customScreenPos = EditorGUILayoutToggle( "Screen Position", m_customScreenPos ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - } - - private void UpdatePorts() - { - m_inputPorts[ 1 ].Visible = ( m_selectedPatternInt == 2 ); - m_inputPorts[ 2 ].Visible = m_customScreenPos; - m_sizeIsDirty = true; - } - - private void GeneratePattern() - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, PatternsStr[ m_selectedPatternInt ] ) ); - switch ( m_selectedPatternInt ) - { - default: - case 0: - { - m_functionBody = string.Empty; - m_functionHeader = "Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( {0}, {1} )"; - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( int x, int y )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "const float dither[ 16 ] = {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " 1, 9, 3, 11," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 13, 5, 15, 7," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 4, 12, 2, 10," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 16, 8, 14, 6 };" ); - IOUtils.AddFunctionLine( ref m_functionBody, "int r = y * 4 + x;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "return dither[r] / 16; // same # of instructions as pre-dividing due to compiler magic" ); - IOUtils.CloseFunctionBody( ref m_functionBody ); - } - break; - case 1: - { - m_functionBody = string.Empty; - m_functionHeader = "Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( {0}, {1} )"; - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( int x, int y )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "const float dither[ 64 ] = {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " 1, 49, 13, 61, 4, 52, 16, 64," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 33, 17, 45, 29, 36, 20, 48, 32," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 9, 57, 5, 53, 12, 60, 8, 56," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 41, 25, 37, 21, 44, 28, 40, 24," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 3, 51, 15, 63, 2, 50, 14, 62," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 35, 19, 47, 31, 34, 18, 46, 30," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 11, 59, 7, 55, 10, 58, 6, 54," ); - IOUtils.AddFunctionLine( ref m_functionBody, " 43, 27, 39, 23, 42, 26, 38, 22};" ); - IOUtils.AddFunctionLine( ref m_functionBody, "int r = y * 8 + x;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "return dither[r] / 64; // same # of instructions as pre-dividing due to compiler magic" ); - IOUtils.CloseFunctionBody( ref m_functionBody ); - } - break; - case 2: - { - bool sampleThroughMacros = UIUtils.CurrentWindow.OutsideGraph.SamplingThroughMacros; - - m_functionBody = string.Empty; - m_functionHeader = "Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( {0}, {1}, {2})"; - - if( sampleThroughMacros ) - { - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( float4 screenPos, TEXTURE2D_PARAM( noiseTexture, samplernoiseTexture ), float4 noiseTexelSize )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float dither = SAMPLE_TEXTURE2D_LOD( noiseTexture, samplernoiseTexture, float3( screenPos.xy * _ScreenParams.xy * noiseTexelSize.xy, 0 ), 0 ).g;" ); - } - else - { - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float Dither" + PatternsFuncStr[ m_selectedPatternInt ] + "( float4 screenPos, sampler2D noiseTexture, float4 noiseTexelSize )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float dither = tex2Dlod( noiseTexture, float4( screenPos.xy * _ScreenParams.xy * noiseTexelSize.xy, 0, 0 ) ).g;" ); - } - IOUtils.AddFunctionLine( ref m_functionBody, "float ditherRate = noiseTexelSize.x * noiseTexelSize.y;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "dither = ( 1 - ditherRate ) * dither + ditherRate;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "return dither;" ); - IOUtils.CloseFunctionBody( ref m_functionBody ); - } - break; - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.UsingCustomScreenPos = true; - } - - 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 ); - - GeneratePattern(); - - if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - string varName = string.Empty; - bool isFragment = dataCollector.IsFragmentCategory; - if( m_customScreenPos && m_inputPorts[ 2 ].IsConnected ) - { - varName = "ditherCustomScreenPos" + OutputId; - string customScreenPosVal = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, varName, customScreenPosVal ); - } - else - { - if( dataCollector.TesselationActive && isFragment ) - { - varName = GeneratorUtils.GenerateClipPositionOnFrag( ref dataCollector, UniqueId, CurrentPrecisionType ); - } - else - { - if( dataCollector.IsTemplate ) - { - varName = dataCollector.TemplateDataCollectorInstance.GetScreenPosNormalized( CurrentPrecisionType ); - } - else - { - varName = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, CurrentPrecisionType, !dataCollector.UsingCustomScreenPos ); - } - } - } - string surfInstruction = varName + ".xy * _ScreenParams.xy"; - m_showErrorMessage = false; - string functionResult = ""; - switch ( m_selectedPatternInt ) - { - default: - case 0: - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT2, "clipScreen" + OutputId, surfInstruction ); - functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, "fmod(" + "clipScreen" + OutputId + ".x, 4)", "fmod(" + "clipScreen" + OutputId + ".y, 4)" ); - break; - case 1: - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT2, "clipScreen" + OutputId, surfInstruction ); - functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, "fmod(" + "clipScreen" + OutputId + ".x, 8)", "fmod(" + "clipScreen" + OutputId + ".y, 8)" ); - break; - case 2: - { - if( !m_inputPorts[ 1 ].IsConnected ) - { - m_showErrorMessage = true; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_errorMessageTooltip = "Please connect a texture object to the Pattern input port to generate a proper dithered pattern"; - return "0"; - } else - { - bool sampleThroughMacros = UIUtils.CurrentWindow.OutsideGraph.SamplingThroughMacros; - - string noiseTex = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddToUniforms( UniqueId, "float4 " + noiseTex + "_TexelSize;", dataCollector.IsSRP ); - if( sampleThroughMacros ) - { - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], noiseTex ) ); - functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, varName, noiseTex+", sampler"+noiseTex, noiseTex + "_TexelSize" ); - } - else - { - functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, varName, noiseTex, noiseTex + "_TexelSize" ); - } - } - } - break; - } - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, "dither" + OutputId, functionResult ); - - if( m_inputPorts[ 0 ].IsConnected ) - { - string driver = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, "dither" + OutputId+" = step( dither"+ OutputId + ", "+ driver + " );" ); - } - - //RegisterLocalVariable( 0, functionResult, ref dataCollector, "dither" + OutputId ); - m_outputPorts[ 0 ].SetLocalValue( "dither" + OutputId, dataCollector.PortCategory ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedPatternInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15404 ) - { - m_customScreenPos = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - UpdatePorts(); - GeneratePattern(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedPatternInt ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_customScreenPos ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs.meta deleted file mode 100644 index 0fc9587e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 284ebed5f88c13e45bc331b2df93aa75 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs deleted file mode 100644 index eec5532e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Encode Depth Normal", "Miscellaneous", "Encodes both Depth and Normal values into a Float4 value" )] - public sealed class EncodeDepthNormalNode : ParentNode - { - private const string EncodeDepthNormalFunc = "EncodeDepthNormal( {0}, {1} )"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Depth" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal" ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - } - - 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 ); - - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - string depthValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string normalValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - RegisterLocalVariable( 0, string.Format( EncodeDepthNormalFunc, depthValue, normalValue ), ref dataCollector, "encodedDepthNormal" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs.meta deleted file mode 100644 index acc45fcc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cabbbe25e4b26b54c84e27007c08a7dd -timeCreated: 1513695146 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs deleted file mode 100644 index b3f95a02..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Encode Float RGBA", "Miscellaneous", "Encodes [0..1] range float into RGBA color, for storage in low precision render target" )] - public sealed class EncodeFloatRGBAHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "EncodeFloatRGBA"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "RGBA"; - m_previewShaderGUID = "c21569bf5b9371b4ca13c0c00abd5562"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "encodeFloatRGBA" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs.meta deleted file mode 100644 index 0d25dc4c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6532496dc1791d94cbb46004000bda61 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs deleted file mode 100644 index 093389e5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Encode Float RG ", "Miscellaneous", "Encodes [0..1] range float into a float2" )] - public sealed class EncodeFloatRGHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "EncodeFloatRG "; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_outputPorts[ 0 ].Name = "RG"; - m_previewShaderGUID = "a44b520baa5c39e41bc69a22ea46f24d"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "encodeFloatRG" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs.meta deleted file mode 100644 index e5ce8e8b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d8bce5e7063ac6b4d93aaf15f7fd1b10 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs deleted file mode 100644 index 767097bc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Encode View Normal Stereo", "Miscellaneous", "Encodes view space normal into two numbers in [0..1] range" )] - public sealed class EncodeViewNormalStereoHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "EncodeViewNormalStereo"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 0 ].Name = "XYZ"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_previewShaderGUID = "3d0b3d482b7246c4cb60fa73e6ceac6c"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "encodeViewNormalStereo" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs.meta deleted file mode 100644 index 48043ee4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 17511ec398441ac479a2dd77d2531837 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs deleted file mode 100644 index afeaae0f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs +++ /dev/null @@ -1,122 +0,0 @@ -// 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( "Gamma To Linear", "Image Effects", "Converts color from gamma space to linear space" )] - public sealed class GammaToLinearNode : HelperParentNode - { - public readonly static string[] ModeListStr = { "Fast sRGB to Linear", "Exact sRGB to Linear" }; - public readonly static int[] ModeListInt = { 0, 1 }; - - public readonly static string[] ModeListStrLW = { "Fast sRGB to Linear", "Exact sRGB to Linear", "Gamma 2.0 to Linear", "Gamma 2.2 to Linear" }; - public readonly static int[] ModeListIntLW = { 0, 1, 2, 3 }; - - [SerializeField] - public int m_selectedMode = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "GammaToLinearSpace"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 0 ].Name = "RGB"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_autoWrapProperties = true; - m_previewShaderGUID = "e82a888a6ebdb1443823aafceaa051b9"; - m_textLabelWidth = 120; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "gammaToLinear" + OutputId; - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( ContainerGraph.IsSRP ) - { - m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStrLW, ModeListIntLW ); - EditorGUILayout.HelpBox( "Fast sRGB: fast approximation from sRGB to Linear\n\nExact sRGB: a more expensive but exact calculation from sRGB to Linear.\n\nGamma 2.0: crude approximation from Gamma to Linear using a power of 2.0 gamma value\n\nGamma 2.2: an approximation from Gamma to Linear using a power of 2.2 gamma value", MessageType.None ); - } - else - { - m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStr, ModeListInt ); - EditorGUILayout.HelpBox( "Fast sRGB: fast approximation from sRGB to Linear\n\nExact sRGB: a more expensive but exact calculation from sRGB to Linear.", MessageType.None ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - if( !dataCollector.IsSRP ) - { - m_selectedMode = Mathf.Min( m_selectedMode, 1 ); - - if( m_selectedMode == 1 ) - { - dataCollector.AddLocalVariable( UniqueId, "half3 " + m_localVarName + " = " + result + ";" ); - dataCollector.AddLocalVariable( UniqueId, m_localVarName + " = half3( GammaToLinearSpaceExact(" + m_localVarName + ".r), GammaToLinearSpaceExact(" + m_localVarName + ".g), GammaToLinearSpaceExact(" + m_localVarName + ".b) );" ); - return m_localVarName; - } - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else - { - dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreCommonLib ); - dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreColorLib ); - switch( m_selectedMode ) - { - default: - case 0: - m_funcLWFormatOverride = "FastSRGBToLinear( {0} )"; - m_funcHDFormatOverride = "FastSRGBToLinear( {0} )"; - break; - case 1: - m_funcLWFormatOverride = "SRGBToLinear( {0} )"; - m_funcHDFormatOverride = "SRGBToLinear( {0} )"; - break; - case 2: - m_funcLWFormatOverride = "Gamma20ToLinear( {0} )"; - m_funcHDFormatOverride = "Gamma20ToLinear( {0} )"; - break; - case 3: - m_funcLWFormatOverride = "Gamma22ToLinear( {0} )"; - m_funcHDFormatOverride = "Gamma22ToLinear( {0} )"; - break; - } - - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedMode ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 11003 && UIUtils.CurrentShaderVersion() <= 14503 ) - { - bool fast = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( fast ) - m_selectedMode = 1; - } - - if( UIUtils.CurrentShaderVersion() > 14503 ) - { - m_selectedMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs.meta deleted file mode 100644 index 5c2ec6af..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cb2775ac410d0134c85b7f1ac0a0399f -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs deleted file mode 100644 index 79c18bb1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs +++ /dev/null @@ -1,93 +0,0 @@ -// 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 ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs.meta deleted file mode 100644 index 504a4ccc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0eba64bdadd330743894a0623677cb83 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs deleted file mode 100644 index 81171cc4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs +++ /dev/null @@ -1,127 +0,0 @@ -// 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( "Linear To Gamma", "Image Effects", "Converts color from linear space to gamma space" )] - public sealed class LinearToGammaNode : HelperParentNode - { - //[SerializeField] - //private bool m_exact = false; - - //private readonly static GUIContent LGExactContent = new GUIContent( "Exact Conversion", "Uses a precise version of the conversion, it's more expensive and often not needed." ); - - public readonly static string[] ModeListStr = { "Fast Linear to sRGB", "Exact Linear to sRGB" }; - public readonly static int[] ModeListInt = { 0, 1 }; - - public readonly static string[] ModeListStrLW = { "Fast Linear to sRGB", "Exact Linear to sRGB", "Linear to Gamma 2.0", "Linear to Gamma 2.2" }; - public readonly static int[] ModeListIntLW = { 0, 1, 2, 3 }; - - [SerializeField] - public int m_selectedMode = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "LinearToGammaSpace"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 0 ].Name = "RGB"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_autoWrapProperties = true; - m_previewShaderGUID = "9027c408b928c5c4d8b450712049d541"; - m_textLabelWidth = 120; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "linearToGamma" + OutputId; - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( ContainerGraph.IsSRP ) - { - m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStrLW, ModeListIntLW ); - EditorGUILayout.HelpBox( "Fast Linear: fast approximation from Linear to sRGB\n\nExact Linear: a more expensive but exact calculation from Linear to sRGB.\n\nLinear 2.0: crude approximation from Linear to Gamma using a power of 1/2.0 gamma value\n\nLinear 2.2: an approximation from Linear to Gamma using a power of 1/2.2 gamma value", MessageType.None ); - } - else - { - m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStr, ModeListInt ); - EditorGUILayout.HelpBox( "Fast Linear: fast approximation from Linear to sRGB\n\nExact Linear: a more expensive but exact calculation from Linear to sRGB.", MessageType.None ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - if( !dataCollector.IsSRP ) - { - m_selectedMode = Mathf.Min( m_selectedMode, 1 ); - - if( m_selectedMode == 1 ) - { - dataCollector.AddLocalVariable( UniqueId, "half3 " + m_localVarName + " = " + result + ";" ); - dataCollector.AddLocalVariable( UniqueId, m_localVarName + " = half3( LinearToGammaSpaceExact(" + m_localVarName + ".r), LinearToGammaSpaceExact(" + m_localVarName + ".g), LinearToGammaSpaceExact(" + m_localVarName + ".b) );" ); - return m_localVarName; - } - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else - { - dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreCommonLib ); - dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreColorLib ); - switch( m_selectedMode ) - { - default: - case 0: - m_funcLWFormatOverride = "FastLinearToSRGB( {0} )"; - m_funcHDFormatOverride = "FastLinearToSRGB( {0} )"; - break; - case 1: - m_funcLWFormatOverride = "LinearToSRGB( {0} )"; - m_funcHDFormatOverride = "LinearToSRGB( {0} )"; - break; - case 2: - m_funcLWFormatOverride = "LinearToGamma20( {0} )"; - m_funcHDFormatOverride = "LinearToGamma20( {0} )"; - break; - case 3: - m_funcLWFormatOverride = "LinearToGamma22( {0} )"; - m_funcHDFormatOverride = "LinearToGamma22( {0} )"; - break; - } - - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedMode ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 11003 && UIUtils.CurrentShaderVersion() <= 14503 ) - { - bool fast = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( fast ) - m_selectedMode = 1; - } - - if( UIUtils.CurrentShaderVersion() > 14503 ) - { - m_selectedMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs.meta deleted file mode 100644 index a4065b8c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a5b8a474628aeca4e86b1599f0b26ebc -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs deleted file mode 100644 index 6f9dd6c6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Luminance", "Image Effects", "Converts color to luminance (grayscale)", Deprecated = true, DeprecatedAlternativeType = typeof( TFHCGrayscale ), DeprecatedAlternative = "Grayscale" )] - public sealed class LuminanceHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "Luminance"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 0 ].Name = "RGB"; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "luminance" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs.meta deleted file mode 100644 index 0b33efd1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e8567c2e3eb634a428819fbdfbff110f -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs deleted file mode 100644 index d862fdac..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Object Space Light Dir", "Light", "Computes object space light direction (not normalized)" )] - public sealed class ObjSpaceLightDirHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "ObjSpaceLightDir"; - m_inputPorts[ 0 ].Visible = false; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - - m_useInternalPortData = false; - m_previewShaderGUID = "c7852de24cec4a744b5358921e23feee"; - m_drawPreviewAsSphere = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - { - //Template must have its Light Mode correctly configured on tags to work as intended - return GetOutputVectorItem( 0, outputId, dataCollector.TemplateDataCollectorInstance.GetObjectSpaceLightDir( CurrentPrecisionType ) ); - } - - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - - string vertexPos = GeneratorUtils.GenerateVertexPosition( ref dataCollector, UniqueId, WirePortDataType.FLOAT4 ); - return GetOutputVectorItem( 0, outputId, GeneratorUtils.GenerateObjectLightDirection( ref dataCollector, UniqueId, CurrentPrecisionType, vertexPos ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs.meta deleted file mode 100644 index b8965aa4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0da9baf35c74c7e468cbe50c3d23ccf0 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs deleted file mode 100644 index 12c1ef80..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Object Space View Dir", "Object Transform", "Object space direction (not normalized) from given object space vertex position towards the camera" )] - public sealed class ObjSpaceViewDirHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "ObjSpaceViewDir"; - //TODO: revisit this later - m_funcLWFormatOverride = "( mul(GetWorldToObjectMatrix(), float4(_WorldSpaceCameraPos.xyz, 1)).xyz - {0}.xyz )"; - m_funcHDFormatOverride = "( mul(GetWorldToObjectMatrix(), float4(_WorldSpaceCameraPos.xyz, 1)).xyz - {0}.xyz )"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 0 ].Vector4InternalData = new UnityEngine.Vector4( 0, 0, 0, 1 ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - m_previewShaderGUID = "c7852de24cec4a744b5358921e23feee"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "objectSpaceViewDir" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs.meta deleted file mode 100644 index fc6c58f3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 590b8e54b63ad344f8d8c372e4fc5ed5 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs deleted file mode 100644 index 929f41ba..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs +++ /dev/null @@ -1,148 +0,0 @@ -using UnityEngine; -using UnityEditor; - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Parallax Mapping", "UV Coordinates", "Calculates offseted UVs for parallax mapping" )] - public sealed class ParallaxMappingNode : ParentNode - { - private enum ParallaxType { Normal, Planar } - - [SerializeField] - private int m_selectedParallaxTypeInt = 0; - - [SerializeField] - private ParallaxType m_selectedParallaxType = ParallaxType.Normal; - - private readonly string[] m_parallaxTypeStr = { "Normal", "Planar" }; - - private int m_cachedPropertyId = -1; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Height" ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - AddInputPort( WirePortDataType.FLOAT3, false, "ViewDir (tan)" ); - AddOutputPort( WirePortDataType.FLOAT2, "Out" ); - m_useInternalPortData = true; - m_autoDrawInternalPortData = true; - m_autoWrapProperties = true; - m_textLabelWidth = 105; - UpdateTitle(); - m_forceDrawPreviewAsPlane = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "589f12f68e00ac74286815aa56053fcc"; - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_ParallaxType" ); - - PreviewMaterial.SetFloat( m_cachedPropertyId, ( m_selectedParallaxType == ParallaxType.Normal ? 0 : 1 ) ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - string textcoords = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string height = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string scale = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string viewDirTan = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - string localVarName = "Offset" + OutputId; - string calculation = ""; - - switch( m_selectedParallaxType ) - { - default: - case ParallaxType.Normal: - calculation = "( ( " + height + " - 1 ) * " + viewDirTan + ".xy * " + scale + " ) + " + textcoords; - break; - case ParallaxType.Planar: - calculation = "( ( " + height + " - 1 ) * ( " + viewDirTan + ".xy / " + viewDirTan + ".z ) * " + scale + " ) + " + textcoords; - break; - } - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, localVarName, calculation ); - //dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, m_outputPorts[ 0 ].DataType, localVarName, calculation ); - return GetOutputVectorItem( 0, outputId, localVarName ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_selectedParallaxTypeInt = m_upperLeftWidget.DrawWidget( this, m_selectedParallaxTypeInt, m_parallaxTypeStr ); - if( EditorGUI.EndChangeCheck() ) - { - switch( m_selectedParallaxTypeInt ) - { - default: - case 0: m_selectedParallaxType = ParallaxType.Normal; break; - case 1: m_selectedParallaxType = ParallaxType.Planar; break; - } - UpdateTitle(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_selectedParallaxTypeInt = EditorGUILayoutPopup( "Parallax Type", m_selectedParallaxTypeInt, m_parallaxTypeStr ); - if( EditorGUI.EndChangeCheck() ) - { - switch( m_selectedParallaxTypeInt ) - { - default: - case 0: m_selectedParallaxType = ParallaxType.Normal; break; - case 1: m_selectedParallaxType = ParallaxType.Planar; break; - } - UpdateTitle(); - } - - EditorGUILayout.HelpBox( "Normal type does a cheaper approximation thats view dependent while Planar is more accurate but generates higher aliasing artifacts at steep angles.", MessageType.None ); - } - - - void UpdateTitle() - { - m_additionalContent.text = string.Format( Constants.SubTitleTypeFormatStr, m_parallaxTypeStr[ m_selectedParallaxTypeInt ] ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedParallaxType = (ParallaxType)Enum.Parse( typeof( ParallaxType ), GetCurrentParam( ref nodeParams ) ); - switch( m_selectedParallaxType ) - { - default: - case ParallaxType.Normal: m_selectedParallaxTypeInt = 0; break; - case ParallaxType.Planar: m_selectedParallaxTypeInt = 1; break; - } - UpdateTitle(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedParallaxType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs.meta deleted file mode 100644 index 97f1c33e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 96d8f50a7481d5247b16cb16c053d5f6 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs deleted file mode 100644 index a956b231..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs +++ /dev/null @@ -1,744 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; - -using System; -namespace AmplifyShaderEditor -{ - enum POMTexTypes - { - Texture2D, - Texture3D, - TextureArray - }; - - [Serializable] - [NodeAttributes( "Parallax Occlusion Mapping", "UV Coordinates", "Calculates offseted UVs for parallax occlusion mapping" )] - public sealed class ParallaxOcclusionMappingNode : ParentNode - { - private const string ArrayIndexStr = "Array Index"; - private const string Tex3DSliceStr = "Tex3D Slice"; - - private readonly string[] m_channelTypeStr = { "Red Channel", "Green Channel", "Blue Channel", "Alpha Channel" }; - private readonly string[] m_channelTypeVal = { "r", "g", "b", "a" }; - - [SerializeField] - private int m_selectedChannelInt = 0; - - //[SerializeField] - //private int m_minSamples = 8; - - //[SerializeField] - //private int m_maxSamples = 16; - [SerializeField] - private InlineProperty m_inlineMinSamples = new InlineProperty( 8 ); - - [SerializeField] - private InlineProperty m_inlineMaxSamples = new InlineProperty( 16 ); - - [ SerializeField] - private int m_sidewallSteps = 2; - - [SerializeField] - private float m_defaultScale = 0.02f; - - [SerializeField] - private float m_defaultRefPlane = 0f; - - [SerializeField] - private bool m_clipEnds = false; - - [SerializeField] - private Vector2 m_tilling = new Vector2( 1, 1 ); - - [SerializeField] - private bool m_useCurvature = false; - - //[SerializeField] - //private bool m_useTextureArray = false; - [SerializeField] - private POMTexTypes m_pomTexType = POMTexTypes.Texture2D; - - //[SerializeField] - //private bool m_useCurvature = false; - - [SerializeField] - private Vector2 m_CurvatureVector = new Vector2( 0, 0 ); - - private string m_functionHeader = "POM( {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13} )"; - private string m_functionBody = string.Empty; - - //private const string WorldDirVarStr = "worldViewDir"; - - private InputPort m_uvPort; - private InputPort m_texPort; - private InputPort m_scalePort; - private InputPort m_viewdirTanPort; - private InputPort m_refPlanePort; - private InputPort m_curvaturePort; - private InputPort m_arrayIndexPort; - - private OutputPort m_pomUVPort; - - private Vector4Node m_texCoordsHelper; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex" ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - AddInputPort( WirePortDataType.FLOAT3, false, "ViewDir (tan)" ); - AddInputPort( WirePortDataType.FLOAT, false, "Ref Plane" ); - AddInputPort( WirePortDataType.FLOAT2, false, "Curvature" ); - AddInputPort( WirePortDataType.FLOAT, false, ArrayIndexStr ); - AddOutputPort( WirePortDataType.FLOAT2, "Out" ); - - m_uvPort = m_inputPorts[ 0 ]; - m_texPort = m_inputPorts[ 1 ]; - m_scalePort = m_inputPorts[ 2 ]; - m_viewdirTanPort = m_inputPorts[ 3 ]; - m_refPlanePort = m_inputPorts[ 4 ]; - m_pomUVPort = m_outputPorts[ 0 ]; - m_curvaturePort = m_inputPorts[ 5 ]; - m_arrayIndexPort = m_inputPorts[ 6 ]; - m_scalePort.FloatInternalData = 0.02f; - m_useInternalPortData = false; - m_textLabelWidth = 130; - m_autoWrapProperties = true; - m_curvaturePort.Visible = false; - m_arrayIndexPort.Visible = false; - UpdateSampler(); - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_selectedChannelInt = EditorGUILayoutPopup( "Channel", m_selectedChannelInt, m_channelTypeStr ); - if ( EditorGUI.EndChangeCheck() ) - { - UpdateSampler(); - GeneratePOMfunction(); - } - EditorGUIUtility.labelWidth = 105; - - //m_minSamples = EditorGUILayoutIntSlider( "Min Samples", m_minSamples, 1, 128 ); - UndoParentNode inst = this; - m_inlineMinSamples.CustomDrawer( ref inst, ( x ) => { m_inlineMinSamples.IntValue = EditorGUILayoutIntSlider( "Min Samples", m_inlineMinSamples.IntValue, 1, 128 ); }, "Min Samples" ); - //m_maxSamples = EditorGUILayoutIntSlider( "Max Samples", m_maxSamples, 1, 128 ); - m_inlineMaxSamples.CustomDrawer( ref inst, ( x ) => { m_inlineMaxSamples.IntValue = EditorGUILayoutIntSlider( "Max Samples", m_inlineMaxSamples.IntValue, 1, 128 ); }, "Max Samples" ); - - EditorGUI.BeginChangeCheck(); - m_sidewallSteps = EditorGUILayoutIntSlider( "Sidewall Steps", m_sidewallSteps, 0, 10 ); - if ( EditorGUI.EndChangeCheck() ) - { - GeneratePOMfunction(); - } - - - EditorGUI.BeginDisabledGroup(m_scalePort.IsConnected ); - m_defaultScale = EditorGUILayoutSlider( "Default Scale", m_defaultScale, 0, 1 ); - EditorGUI.EndDisabledGroup(); - - EditorGUI.BeginDisabledGroup( m_refPlanePort.IsConnected ); - m_defaultRefPlane = EditorGUILayoutSlider( "Default Ref Plane", m_defaultRefPlane, 0, 1 ); - EditorGUI.EndDisabledGroup(); - EditorGUIUtility.labelWidth = m_textLabelWidth; - EditorGUI.BeginChangeCheck(); - //m_useTextureArray = EditorGUILayoutToggle( "Use Texture Array", m_useTextureArray ); - m_pomTexType = (POMTexTypes)EditorGUILayoutEnumPopup( "Texture Type", m_pomTexType ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateIndexPort(); - m_sizeIsDirty = true; - GeneratePOMfunction(); - //UpdateCurvaturePort(); - } - - if( m_arrayIndexPort.Visible && !m_arrayIndexPort.IsConnected ) - { - m_arrayIndexPort.FloatInternalData = EditorGUILayoutFloatField( "Array Index", m_arrayIndexPort.FloatInternalData ); - } - - //float cached = EditorGUIUtility.labelWidth; - //EditorGUIUtility.labelWidth = 70; - m_clipEnds = EditorGUILayoutToggle( "Clip Edges", m_clipEnds ); - //EditorGUIUtility.labelWidth = -1; - //EditorGUIUtility.labelWidth = 100; - //EditorGUILayout.BeginHorizontal(); - //EditorGUI.BeginDisabledGroup( !m_clipEnds ); - //m_tilling = EditorGUILayout.Vector2Field( string.Empty, m_tilling ); - //EditorGUI.EndDisabledGroup(); - //EditorGUILayout.EndHorizontal(); - //EditorGUIUtility.labelWidth = cached; - - EditorGUI.BeginChangeCheck(); - m_useCurvature = EditorGUILayoutToggle( "Clip Silhouette", m_useCurvature ); - if ( EditorGUI.EndChangeCheck() ) - { - GeneratePOMfunction(); - UpdateCurvaturePort(); - } - - EditorGUI.BeginDisabledGroup( !(m_useCurvature && !m_curvaturePort.IsConnected) ); - m_CurvatureVector = EditorGUILayoutVector2Field( string.Empty, m_CurvatureVector ); - EditorGUI.EndDisabledGroup(); - - EditorGUILayout.HelpBox( "WARNING:\nTex must be connected to a Texture Object for this node to work\n\nMin and Max samples:\nControl the minimum and maximum number of layers extruded\n\nSidewall Steps:\nThe number of interpolations done to smooth the extrusion result on the side of the layer extrusions, min is used at steep angles while max is used at orthogonal angles\n\n"+ - "Ref Plane:\nReference plane lets you adjust the starting reference height, 0 = deepen ground, 1 = raise ground, any value above 0 might cause distortions at higher angles\n\n"+ - "Clip Edges:\nThis will clip the ends of your uvs to give a more 3D look at the edges. It'll use the tilling given by your Heightmap input.\n\n"+ - "Clip Silhouette:\nTurning this on allows you to use the UV coordinates to clip the effect curvature in U or V axis, useful for cylinders, works best with 'Clip Edges' turned OFF", MessageType.None ); - } - - private void UpdateIndexPort() - { - m_arrayIndexPort.Visible = m_pomTexType != POMTexTypes.Texture2D; - if( m_arrayIndexPort.Visible ) - { - m_arrayIndexPort.Name = m_pomTexType == POMTexTypes.Texture3D ? Tex3DSliceStr : ArrayIndexStr; - } - } - - private void UpdateSampler() - { - m_texPort.Name = "Tex (" + m_channelTypeVal[ m_selectedChannelInt ].ToUpper() + ")"; - } - - private void UpdateCurvaturePort() - { - if ( m_useCurvature ) - m_curvaturePort.Visible = true; - else - m_curvaturePort.Visible = false; - - m_sizeIsDirty = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !m_texPort.IsConnected ) - { - UIUtils.ShowMessage( UniqueId, "Parallax Occlusion Mapping node only works if a Texture Object is connected to its Tex (R) port" ); - return "0"; - } - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - WirePortDataType texType = ( m_pomTexType == POMTexTypes.Texture3D )?WirePortDataType.SAMPLER3D: WirePortDataType.SAMPLER2D; - - GeneratePOMfunction(); - string arrayIndex = m_arrayIndexPort.Visible?m_arrayIndexPort.GeneratePortInstructions( ref dataCollector ):"0"; - string textcoords = m_uvPort.GeneratePortInstructions( ref dataCollector ); - if( m_pomTexType == POMTexTypes.Texture3D ) - { - string texName = "pomTexCoord" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, texName, string.Format( "float3({0},{1})", textcoords, arrayIndex ) ); - textcoords = texName; - } - - string texture = m_texPort.GenerateShaderForOutput( ref dataCollector, texType,false,true ); - string scale = m_defaultScale.ToString(); - if( m_scalePort.IsConnected ) - scale = m_scalePort.GeneratePortInstructions( ref dataCollector ); - - string viewDirTan = ""; - if ( !m_viewdirTanPort.IsConnected ) - { - if ( !dataCollector.DirtyNormal ) - dataCollector.ForceNormal = true; - - - if ( dataCollector.IsTemplate ) - { - viewDirTan = dataCollector.TemplateDataCollectorInstance.GetTangentViewDir( CurrentPrecisionType ); - } - else - { - viewDirTan = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.Tangent ); - //dataCollector.AddToInput( UniqueId, SurfaceInputs.VIEW_DIR, m_currentPrecisionType ); - //viewDirTan = Constants.InputVarStr + "." + UIUtils.GetInputValueFromType( SurfaceInputs.VIEW_DIR ); - } - } - else - { - viewDirTan = m_viewdirTanPort.GeneratePortInstructions( ref dataCollector ); - } - - //generate world normal - string normalWorld = string.Empty; - if ( dataCollector.IsTemplate ) - { - normalWorld = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( CurrentPrecisionType ); - } - else - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - normalWorld = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ); - } - - //string normalWorld = "WorldNormalVector( " + Constants.InputVarStr + ", float3( 0, 0, 1 ) )"; - - //generate viewDir in world space - - //string worldPos = string.Empty; - //if( dataCollector.IsTemplate ) - //{ - // worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos(); - //} - //else - //{ - // dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - // worldPos = Constants.InputVarStr + ".worldPos"; - //} - - //if( !dataCollector.IsTemplate ) - // dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - - string worldViewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.World ); - //dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, WorldDirVarStr, TemplateHelperFunctions.WorldSpaceViewDir( dataCollector, worldPos, true ) ); - string dx = "ddx("+ textcoords + ")"; - string dy = "ddy(" + textcoords + ")"; - - string refPlane = m_defaultRefPlane.ToString(); - if ( m_refPlanePort.IsConnected ) - refPlane = m_refPlanePort.GeneratePortInstructions( ref dataCollector ); - - - string curvature = "float2("+ m_CurvatureVector.x + "," + m_CurvatureVector.y + ")"; - if ( m_useCurvature ) - { - dataCollector.AddToProperties( UniqueId, "[Header(Parallax Occlusion Mapping)]", 300 ); - dataCollector.AddToProperties( UniqueId, "_CurvFix(\"Curvature Bias\", Range( 0 , 1)) = 1", 301 ); - dataCollector.AddToUniforms( UniqueId, "uniform float _CurvFix;" ); - - if ( m_curvaturePort.IsConnected ) - curvature = m_curvaturePort.GeneratePortInstructions( ref dataCollector ); - } - - - string localVarName = "OffsetPOM" + OutputId; - string textCoordsST = string.Empty; - //string textureSTType = dataCollector.IsSRP ? "float4 " : "uniform float4 "; - //dataCollector.AddToUniforms( UniqueId, textureSTType + texture +"_ST;"); - if( m_texCoordsHelper == null ) - { - m_texCoordsHelper = CreateInstance<Vector4Node>(); - m_texCoordsHelper.ContainerGraph = ContainerGraph; - m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ); - m_texCoordsHelper.RegisterPropertyOnInstancing = false; - m_texCoordsHelper.AddGlobalToSRPBatcher = true; - } - - if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader ) - { - m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty; - } - else - { - m_texCoordsHelper.CurrentParameterType = PropertyType.Global; - } - m_texCoordsHelper.ResetOutputLocals(); - m_texCoordsHelper.SetRawPropertyName( texture + "_ST" ); - textCoordsST = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ); - ////// - - if( m_pomTexType == POMTexTypes.TextureArray ) - dataCollector.UsingArrayDerivatives = true; - string textureArgs = string.Empty; - if( m_pomTexType == POMTexTypes.TextureArray ) - { - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - { - textureArgs = "TEXTURE2D_ARRAY_ARGS( " + texture + ", sampler" + texture + ")"; - } - else - { - textureArgs = "UNITY_PASS_TEX2DARRAY(" + texture + ")"; - } - } - else - { - bool sampleThroughMacros = UIUtils.CurrentWindow.OutsideGraph.SamplingThroughMacros; - if( sampleThroughMacros ) - { - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], texture ) ); - textureArgs = string.Format( "{0},sampler{0}", texture ); - } - else - { - textureArgs = texture; - } - } - //string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, ( (m_pomTexType == POMTexTypes.TextureArray) ? "UNITY_PASS_TEX2DARRAY(" + texture + ")": texture), textcoords, dx, dy, normalWorld, worldViewDir, viewDirTan, m_minSamples, m_maxSamples, scale, refPlane, texture+"_ST.xy", curvature, arrayIndex ); - string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, textureArgs, textcoords, dx, dy, normalWorld, worldViewDir, viewDirTan, m_inlineMinSamples.GetValueOrProperty(false), m_inlineMinSamples.GetValueOrProperty(false), scale, refPlane, textCoordsST + ".xy", curvature, arrayIndex ); - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_pomUVPort.DataType, localVarName, functionResult ); - - return GetOutputVectorItem( 0, outputId, localVarName ); - } - - private void GeneratePOMfunction() - { - bool sampleThroughMacros = UIUtils.CurrentWindow.OutsideGraph.SamplingThroughMacros; - m_functionBody = string.Empty; - switch( m_pomTexType ) - { - default: - case POMTexTypes.Texture2D: - { - string sampleParam = sampleThroughMacros ? "TEXTURE2D_PARAM(heightMap,samplerheightMap)" : "sampler2D heightMap"; - IOUtils.AddFunctionHeader( ref m_functionBody, string.Format("inline float2 POM( {0}, float2 uvs, float2 dx, float2 dy, float3 normalWorld, float3 viewWorld, float3 viewDirTan, int minSamples, int maxSamples, float parallax, float refPlane, float2 tilling, float2 curv, int index )", sampleParam )); - } - break; - case POMTexTypes.Texture3D: - { - string sampleParam = sampleThroughMacros ? "TEXTURE3D_PARAM( heightMap,samplerheightMap) " : "sampler3D heightMap"; - IOUtils.AddFunctionHeader( ref m_functionBody, string.Format("inline float2 POM( {0}, float3 uvs, float3 dx, float3 dy, float3 normalWorld, float3 viewWorld, float3 viewDirTan, int minSamples, int maxSamples, float parallax, float refPlane, float2 tilling, float2 curv, int index )", sampleParam ) ); - } - break; - case POMTexTypes.TextureArray: - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float2 POM( TEXTURE2D_ARRAY_PARAM(heightMap,samplerheightMap), float2 uvs, float2 dx, float2 dy, float3 normalWorld, float3 viewWorld, float3 viewDirTan, int minSamples, int maxSamples, float parallax, float refPlane, float2 tilling, float2 curv, int index )" ); - else - IOUtils.AddFunctionHeader( ref m_functionBody, "inline float2 POM( UNITY_ARGS_TEX2DARRAY(heightMap), float2 uvs, float2 dx, float2 dy, float3 normalWorld, float3 viewWorld, float3 viewDirTan, int minSamples, int maxSamples, float parallax, float refPlane, float2 tilling, float2 curv, int index )" ); - break; - } - - IOUtils.AddFunctionLine( ref m_functionBody, "float3 result = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "int stepIndex = 0;" ); - //IOUtils.AddFunctionLine( ref m_functionBody, "int numSteps = ( int )( minSamples + dot( viewWorld, normalWorld ) * ( maxSamples - minSamples ) );" ); - //IOUtils.AddFunctionLine( ref m_functionBody, "int numSteps = ( int )lerp( maxSamples, minSamples, length( fwidth( uvs ) ) * 10 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, "int numSteps = ( int )lerp( (float)maxSamples, (float)minSamples, saturate( dot( normalWorld, viewWorld ) ) );" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float layerHeight = 1.0 / numSteps;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float2 plane = parallax * ( viewDirTan.xy / viewDirTan.z );" ); - - switch( m_pomTexType ) - { - default: - case POMTexTypes.Texture2D: - IOUtils.AddFunctionLine( ref m_functionBody, "uvs += refPlane * plane;" ); - break; - case POMTexTypes.Texture3D: - IOUtils.AddFunctionLine( ref m_functionBody, "uvs.xy += refPlane * plane;" ); - break; - case POMTexTypes.TextureArray: - IOUtils.AddFunctionLine( ref m_functionBody, "uvs += refPlane * plane;" ); - break; - } - - IOUtils.AddFunctionLine( ref m_functionBody, "float2 deltaTex = -plane * layerHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float2 prevTexOffset = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float prevRayZ = 1.0f;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float prevHeight = 0.0f;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float2 currTexOffset = deltaTex;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float currRayZ = 1.0f - layerHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float currHeight = 0.0f;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float intersection = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float2 finalTexOffset = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "while ( stepIndex < numSteps + 1 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - if( m_useCurvature ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " result.z = dot( curv, currTexOffset * currTexOffset );" ); - - - switch( m_pomTexType ) - { - default: - case POMTexTypes.Texture2D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_GRAD( heightMap, samplerheightMap, uvs + currTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = tex2Dgrad( heightMap, uvs + currTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - } - } - break; - case POMTexTypes.Texture3D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_GRAD( heightMap, samplerheightMap, uvs + float3(currTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = tex3Dgrad( heightMap, uvs + float3(currTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - } - } - break; - case POMTexTypes.TextureArray: - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_ARRAY_GRAD( heightMap,samplerheightMap, uvs + currTexOffset,index, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = ASE_SAMPLE_TEX2DARRAY_GRAD( heightMap, float3(uvs + currTexOffset,index), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + " * ( 1 - result.z );" ); - break; - } - - } - else - { - switch( m_pomTexType ) - { - default: - case POMTexTypes.Texture2D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_GRAD( heightMap,samplerheightMap, uvs + currTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = tex2Dgrad( heightMap, uvs + currTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - } - break; - case POMTexTypes.Texture3D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_GRAD( heightMap, samplerheightMap, uvs + float3(currTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = tex3Dgrad( heightMap, uvs + float3(currTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - } - break; - case POMTexTypes.TextureArray: - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = SAMPLE_TEXTURE2D_ARRAY_GRAD( heightMap, samplerheightMap, uvs + currTexOffset,index, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = ASE_SAMPLE_TEX2DARRAY_GRAD( heightMap, float3(uvs + currTexOffset,index), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - break; - } - } - IOUtils.AddFunctionLine( ref m_functionBody, " if ( currHeight > currRayZ )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " stepIndex = numSteps + 1;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " }" ); - IOUtils.AddFunctionLine( ref m_functionBody, " else" ); - IOUtils.AddFunctionLine( ref m_functionBody, " {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " stepIndex++;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevTexOffset = currTexOffset;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevRayZ = currRayZ;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevHeight = currHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " currTexOffset += deltaTex;" ); - if ( m_useCurvature ) - IOUtils.AddFunctionLine( ref m_functionBody, " currRayZ -= layerHeight * ( 1 - result.z ) * (1+_CurvFix);" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, " currRayZ -= layerHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " }" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - - if ( m_sidewallSteps > 0 ) - { - IOUtils.AddFunctionLine( ref m_functionBody, "int sectionSteps = " + m_sidewallSteps + ";" ); - IOUtils.AddFunctionLine( ref m_functionBody, "int sectionIndex = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float newZ = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float newHeight = 0;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "while ( sectionIndex < sectionSteps )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - IOUtils.AddFunctionLine( ref m_functionBody, " intersection = ( prevHeight - prevRayZ ) / ( prevHeight - currHeight + currRayZ - prevRayZ );" ); - IOUtils.AddFunctionLine( ref m_functionBody, " finalTexOffset = prevTexOffset + intersection * deltaTex;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " newZ = prevRayZ - intersection * layerHeight;" ); - - switch( m_pomTexType ) - { - default: - case POMTexTypes.Texture2D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = SAMPLE_TEXTURE2D_GRAD( heightMap, samplerheightMap, uvs + finalTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = tex2Dgrad( heightMap, uvs + finalTexOffset, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - } - break; - case POMTexTypes.Texture3D: - { - if( sampleThroughMacros ) - { - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = SAMPLE_TEXTURE2D_GRAD( heightMap, samplerheightMap, uvs + float3(finalTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = tex3Dgrad( heightMap, uvs + float3(finalTexOffset,0), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - } - } - break; - case POMTexTypes.TextureArray: - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = SAMPLE_TEXTURE2D_ARRAY_GRAD( heightMap, samplerheightMap, uvs + finalTexOffset,index, dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, " newHeight = ASE_SAMPLE_TEX2DARRAY_GRAD( heightMap, float3(uvs + finalTexOffset,index), dx, dy )." + m_channelTypeVal[ m_selectedChannelInt ] + ";" ); - break; - } - - IOUtils.AddFunctionLine( ref m_functionBody, " if ( newHeight > newZ )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " currTexOffset = finalTexOffset;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " currHeight = newHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " currRayZ = newZ;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " deltaTex = intersection * deltaTex;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " layerHeight = intersection * layerHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " }" ); - IOUtils.AddFunctionLine( ref m_functionBody, " else" ); - IOUtils.AddFunctionLine( ref m_functionBody, " {" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevTexOffset = finalTexOffset;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevHeight = newHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " prevRayZ = newZ;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " deltaTex = ( 1 - intersection ) * deltaTex;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " layerHeight = ( 1 - intersection ) * layerHeight;" ); - IOUtils.AddFunctionLine( ref m_functionBody, " }" ); - IOUtils.AddFunctionLine( ref m_functionBody, " sectionIndex++;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, "finalTexOffset = currTexOffset;" ); - } - - if ( m_useCurvature ) - { - IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" ); - IOUtils.AddFunctionLine( ref m_functionBody, "if ( unity_LightShadowBias.z == 0.0 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#endif" ); - IOUtils.AddFunctionLine( ref m_functionBody, " if ( result.z > 1 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " clip( -1 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#endif" ); - } - - if ( m_clipEnds ) - { - IOUtils.AddFunctionLine( ref m_functionBody, "result.xy = uvs + finalTexOffset;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" ); - IOUtils.AddFunctionLine( ref m_functionBody, "if ( unity_LightShadowBias.z == 0.0 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#endif" ); - IOUtils.AddFunctionLine( ref m_functionBody, " if ( result.x < 0 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " clip( -1 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, " if ( result.x > tilling.x )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " clip( -1 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, " if ( result.y < 0 )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " clip( -1 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, " if ( result.y > tilling.y )" ); - IOUtils.AddFunctionLine( ref m_functionBody, " clip( -1 );" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#endif" ); - IOUtils.AddFunctionLine( ref m_functionBody, "return result.xy;" ); - } - else - { - IOUtils.AddFunctionLine( ref m_functionBody, "return uvs + finalTexOffset;" ); - } - IOUtils.CloseFunctionBody( ref m_functionBody ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedChannelInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - //m_minSamples = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - //m_maxSamples = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() < 15406 ) - { - m_inlineMinSamples.IntValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_inlineMaxSamples.IntValue = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - else - { - m_inlineMinSamples.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - m_inlineMaxSamples.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - m_sidewallSteps = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_defaultScale = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_defaultRefPlane = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - if ( UIUtils.CurrentShaderVersion() > 3001 ) - { - m_clipEnds = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - string[] vector2Component = GetCurrentParam( ref nodeParams ).Split( IOUtils.VECTOR_SEPARATOR ); - if ( vector2Component.Length == 2 ) - { - m_tilling.x = Convert.ToSingle( vector2Component[ 0 ] ); - m_tilling.y = Convert.ToSingle( vector2Component[ 1 ] ); - } - } - - if ( UIUtils.CurrentShaderVersion() > 5005 ) - { - m_useCurvature = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_CurvatureVector = IOUtils.StringToVector2( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 13103 ) - { - if( UIUtils.CurrentShaderVersion() < 15307 ) - { - bool arrayIndexVisible = false; - arrayIndexVisible = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_pomTexType = arrayIndexVisible ? POMTexTypes.TextureArray : POMTexTypes.Texture2D; - } - else - { - m_pomTexType = (POMTexTypes)Enum.Parse( typeof(POMTexTypes), GetCurrentParam( ref nodeParams ) ); - } - - UpdateIndexPort(); - } - - UpdateSampler(); - GeneratePOMfunction(); - UpdateCurvaturePort(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedChannelInt ); - //IOUtils.AddFieldValueToString( ref nodeInfo, m_minSamples ); - //IOUtils.AddFieldValueToString( ref nodeInfo, m_maxSamples ); - m_inlineMinSamples.WriteToString( ref nodeInfo ); - m_inlineMaxSamples.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_sidewallSteps ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultScale ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultRefPlane ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_clipEnds ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tilling.x.ToString() + IOUtils.VECTOR_SEPARATOR + m_tilling.y.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_useCurvature ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.Vector2ToString( m_CurvatureVector ) ); - //IOUtils.AddFieldValueToString( ref nodeInfo, m_useTextureArray ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_pomTexType); - } - - public override void Destroy() - { - base.Destroy(); - //Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff - if( m_texCoordsHelper != null ) - { - DestroyImmediate( m_texCoordsHelper ); - m_texCoordsHelper = null; - } - - - m_uvPort = null; - m_texPort = null; - m_scalePort = null; - m_viewdirTanPort = null; - m_pomUVPort = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs.meta deleted file mode 100644 index 3a7443c6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b2350150f3f2a0443827ca8925d5e759 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs deleted file mode 100644 index 26b8a542..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Parallax Offset", "UV Coordinates", "Calculates UV offset for parallax normal mapping" )] - public sealed class ParallaxOffsetHlpNode : HelperParentNode - { - public readonly string[] ParallaxOffsetFunc = - { - "inline float2 ParallaxOffset( half h, half height, half3 viewDir )\n", - "{\n", - "\th = h * height - height/2.0;\n", - "\tfloat3 v = normalize( viewDir );\n", - "\tv.z += 0.42;\n", - "\treturn h* (v.xy / v.z);\n", - "}\n" - }; - - void OnSRPActionEvent( int outputId, ref MasterNodeDataCollector dataCollector ) - { - dataCollector.AddFunction( ParallaxOffsetFunc[ 0 ], ParallaxOffsetFunc, false ); - } - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "ParallaxOffset"; - m_inputPorts[ 0 ].ChangeProperties( "H", WirePortDataType.FLOAT, false ); - AddInputPort( WirePortDataType.FLOAT, false, "Height" ); - AddInputPort( WirePortDataType.FLOAT3, false, "ViewDir (tan)" ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_outputPorts[ 0 ].Name = "Out"; - OnHDAction = OnSRPActionEvent; - OnLightweightAction = OnSRPActionEvent; - m_previewShaderGUID = "6085f804c6fbf354eac039c11feaa7cc"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "paralaxOffset" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs.meta deleted file mode 100644 index 76316eed..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 83b7d6fe57585b74d80c429aef719200 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs deleted file mode 100644 index e337326b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Shade Vertex Lights", "Light", "Computes illumination from four per-vertex lights and ambient, given object space position & normal" )] - public sealed class ShadeVertexLightsHlpNode : ParentNode - { - private const string HelperMessage = "Shade Vertex Lights node only outputs correct results on\nTemplate Vertex/Frag shaders with their LightMode set to Vertex."; - private const string ShadeVertexLightFunc = "ShadeVertexLightsFull({0},{1},{2},{3})"; - private const string LightCount = "Light Count"; - private const string IsSpotlight = "Is Spotlight"; - private const int MinLightCount = 0; - private const int MaxLightCount = 8; - [SerializeField] - private int m_lightCount = 4; - - [SerializeField] - private bool m_enableSpotlight = false; - - private int _LightCountId; - private int _IsSpotlightId; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, "Vertex Position" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Vertex Normal" ); - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - m_useInternalPortData = true; - //m_autoWrapProperties = true; - m_textLabelWidth = 90; - m_previewShaderGUID = "3b6075034a85ad047be2d31dd213fb4f"; - } - - public override void OnEnable() - { - base.OnEnable(); - _LightCountId = Shader.PropertyToID( "_LightCount" ); - _IsSpotlightId = Shader.PropertyToID( "_IsSpotlight" ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawGeneralProperties ); - EditorGUILayout.HelpBox( HelperMessage, MessageType.Info ); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - PreviewMaterial.SetInt( _LightCountId, m_lightCount ); - PreviewMaterial.SetInt( _IsSpotlightId, ( m_enableSpotlight ? 1 : 0 ) ); - - } - - void DrawGeneralProperties() - { - m_lightCount = EditorGUILayoutIntSlider( LightCount, m_lightCount, MinLightCount, MaxLightCount ); - m_enableSpotlight = EditorGUILayoutToggle( IsSpotlight, m_enableSpotlight ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.SurfaceShader ) - UIUtils.ShowMessage( UniqueId, HelperMessage, MessageSeverity.Warning ); - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - - string vertexPosition = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string vertexNormal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string value = string.Format( ShadeVertexLightFunc, vertexPosition, vertexNormal, m_lightCount, m_enableSpotlight.ToString().ToLower() ); - - RegisterLocalVariable( 0, value, ref dataCollector, "shadeVertexLight" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 14301 ) - { - m_lightCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_enableSpotlight = 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_lightCount ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_enableSpotlight ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs.meta deleted file mode 100644 index 100f876b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 74f44334b702bce4ba8e2681dc80fe3c -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs deleted file mode 100644 index 93e01b41..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs +++ /dev/null @@ -1,184 +0,0 @@ -using UnityEngine; -using UnityEditor; - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Surface Depth", "Surface Data", "Returns the surface view depth" )] - public sealed class SurfaceDepthNode : ParentNode - { - [SerializeField] - private int m_viewSpaceInt = 0; - - 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.FLOAT3, false, "Vertex Position" ); - AddOutputPort( WirePortDataType.FLOAT, "Depth" ); - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, m_viewSpaceStr[ m_viewSpaceInt ] ) ); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - 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 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 ] ) ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - { - if( m_inputPorts[ 0 ].IsConnected ) - { - string space = string.Empty; - if( m_viewSpaceInt == 1 ) - space = " * _ProjectionParams.w"; - - string varName = "customSurfaceDepth" + OutputId; - GenerateInputInVertex( ref dataCollector, 0, varName, false ); - string instruction = "-UnityObjectToViewPos( " + varName + " ).z" + space; - if( dataCollector.IsSRP ) - instruction = "-TransformWorldToView(TransformObjectToWorld( " + varName + " )).z" + space; - string eyeVarName = "customEye" + OutputId; - dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( eyeVarName, WirePortDataType.FLOAT, CurrentPrecisionType, instruction ); - return eyeVarName; - } - else - { - return dataCollector.TemplateDataCollectorInstance.GetEyeDepth( CurrentPrecisionType, true, MasterNodePortCategory.Fragment, m_viewSpaceInt ); - } - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - string vertexVarName = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - { - vertexVarName = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - vertexVarName = Constants.VertexShaderInputStr + ".vertex.xyz"; - } - - string vertexSpace = m_viewSpaceInt == 1 ? " * _ProjectionParams.w" : ""; - string vertexInstruction = "-UnityObjectToViewPos( " + vertexVarName + " ).z" + vertexSpace; - dataCollector.AddVertexInstruction( "float " + m_vertexNameStr[ m_viewSpaceInt ] + " = " + vertexInstruction, UniqueId ); - - return m_vertexNameStr[ m_viewSpaceInt ]; - } - - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - - - if( dataCollector.TesselationActive ) - { - if( m_inputPorts[ 0 ].IsConnected ) - { - string space = string.Empty; - if( m_viewSpaceInt == 1 ) - space = " * _ProjectionParams.w"; - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - RegisterLocalVariable( 0, string.Format( "-UnityObjectToViewPos( {0} ).z", value ) + space, ref dataCollector, "customSurfaceDepth" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - else - { - string eyeDepth = GeneratorUtils.GenerateScreenDepthOnFrag( ref dataCollector, UniqueId, CurrentPrecisionType ); - if( m_viewSpaceInt == 1 ) - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, m_vertexNameStr[ 1 ], eyeDepth + " * _ProjectionParams.w" ); - return m_vertexNameStr[ 1 ]; - } - else - { - return eyeDepth; - } - } - } - else - { - - string space = string.Empty; - if( m_viewSpaceInt == 1 ) - space = " * _ProjectionParams.w"; - - if( m_inputPorts[ 0 ].IsConnected ) - { - string varName = "customSurfaceDepth" + OutputId; - GenerateInputInVertex( ref dataCollector, 0, varName, false ); - dataCollector.AddToInput( UniqueId, varName, WirePortDataType.FLOAT ); - string instruction = "-UnityObjectToViewPos( " + varName + " ).z" + space; - dataCollector.AddToVertexLocalVariables( UniqueId , Constants.VertexShaderOutputStr + "." + varName + " = " + instruction+";" ); - return Constants.InputVarStr + "." + varName; - } - else - { - dataCollector.AddToInput( UniqueId, m_vertexNameStr[ m_viewSpaceInt ], WirePortDataType.FLOAT ); - string instruction = "-UnityObjectToViewPos( " + Constants.VertexShaderInputStr + ".vertex.xyz ).z" + space; - dataCollector.AddToVertexLocalVariables( UniqueId , Constants.VertexShaderOutputStr + "." + m_vertexNameStr[ m_viewSpaceInt ] + " = " + instruction+";" ); - return Constants.InputVarStr + "." + m_vertexNameStr[ m_viewSpaceInt ]; - } - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_viewSpaceInt = Convert.ToInt32( 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 ); - } - } - -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs.meta deleted file mode 100644 index e1aa08a6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d3b0855152b8c5d478f236423cfb1959 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs deleted file mode 100644 index ef31fac3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs +++ /dev/null @@ -1,1494 +0,0 @@ -using UnityEngine; -using UnityEditor; - -using System; -using System.Collections.Generic; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Triplanar Sample", "Textures", "Triplanar Mapping" )] - public sealed class TriplanarNode : ParentNode - { - [SerializeField] - private string m_uniqueName; - - private bool m_editPropertyNameMode = false; - [SerializeField] - private string m_propertyInspectorName = "Triplanar Sampler"; - - private enum TriplanarType { Spherical, Cylindrical } - - [SerializeField] - private TriplanarType m_selectedTriplanarType = TriplanarType.Spherical; - - private enum TriplanarSpace { Object, World } - - [SerializeField] - private TriplanarSpace m_selectedTriplanarSpace = TriplanarSpace.World; - - [SerializeField] - private bool m_normalCorrection = false; - - [SerializeField] - private bool m_arraySupport = false; - - [SerializeField] - private TexturePropertyNode m_topTexture; - [SerializeField] - private TexturePropertyNode m_midTexture; - [SerializeField] - private TexturePropertyNode m_botTexture; - - bool m_texturesInitialize = false; - - [SerializeField] - private string m_tempTopInspectorName = string.Empty; - [SerializeField] - private string m_tempTopName = string.Empty; - private TexturePropertyValues m_tempTopDefaultValue = TexturePropertyValues.white; - private int m_tempTopOrderIndex = -1; - private Texture2D m_tempTopDefaultTexture = null; - - private string m_tempMidInspectorName = string.Empty; - private string m_tempMidName = string.Empty; - private TexturePropertyValues m_tempMidDefaultValue = TexturePropertyValues.white; - private int m_tempMidOrderIndex = -1; - private Texture2D m_tempMidDefaultTexture = null; - - private string m_tempBotInspectorName = string.Empty; - private string m_tempBotName = string.Empty; - private TexturePropertyValues m_tempBotDefaultValue = TexturePropertyValues.white; - private int m_tempBotOrderIndex = -1; - private Texture2D m_tempBotDefaultTexture = null; - - private bool m_topTextureFoldout = true; - private bool m_midTextureFoldout = true; - private bool m_botTextureFoldout = true; - - private InputPort m_topTexPort; - private InputPort m_midTexPort; - private InputPort m_botTexPort; - private InputPort m_tilingPort; - private InputPort m_falloffPort; - private InputPort m_topIndexPort; - private InputPort m_midIndexPort; - private InputPort m_botIndexPort; - private InputPort m_scalePort; - private InputPort m_posPort; - - - private readonly string m_functionCall = "TriplanarSampling{0}( {1} )"; - private readonly string m_functionHeader = "inline {0} TriplanarSampling{1}( {2}float3 worldPos, float3 worldNormal, float falloff, float2 tiling, float3 normalScale, float3 index )"; - - private readonly string m_singularTextureRegular = "sampler2D topTexMap, "; - private readonly string m_topmidbotTextureRegular = "sampler2D topTexMap, sampler2D midTexMap, sampler2D botTexMap, "; - - private readonly string m_singularTextureSRP = "TEXTURE2D_PARAM( topTexMap, samplertopTexMap), "; - private readonly string m_topmidbotTextureSRP = "TEXTURE2D_PARAM( topTexMap, samplertopTexMap), TEXTURE2D_PARAM( midTexMap , samplermidTexMap), TEXTURE2D_PARAM( botTexMap , samplerbotTexMap), "; - - - private readonly string m_singularArrayTextureStandard = "UNITY_ARGS_TEX2DARRAY( topTexMap ), "; - private readonly string m_topmidbotArrayTextureStandard = "UNITY_ARGS_TEX2DARRAY( topTexMap ), UNITY_ARGS_TEX2DARRAY( midTexMap ), UNITY_ARGS_TEX2DARRAY( botTexMap ), "; - - private readonly string m_singularArrayTextureSRP = "ASE_TEXTURE2D_ARRAY_ARGS( topTexMap ), "; - private readonly string m_topmidbotArrayTextureSRP = "ASE_TEXTURE2D_ARRAY_ARGS( topTexMap ), ASE_TEXTURE2D_ARRAY_ARGS( midTexMap ), ASE_TEXTURE2D_ARRAY_ARGS( botTexMap ), "; - - private readonly List<string> m_functionSamplingBodyProj = new List<string>() { - "float3 projNormal = ( pow( abs( worldNormal ), falloff ) );", - "projNormal /= ( projNormal.x + projNormal.y + projNormal.z ) + 0.00001;",// 0.00001 is to prevent division by 0 - "float3 nsign = sign( worldNormal );" - }; - - private readonly List<string> m_functionSamplingBodyNegProj = new List<string>() { - "float negProjNormalY = max( 0, projNormal.y * -nsign.y );", - "projNormal.y = max( 0, projNormal.y * nsign.y );" - }; - - // Sphere sampling - private readonly List<string> m_functionSamplingBodySampSphere = new List<string>() { - "half4 xNorm; half4 yNorm; half4 zNorm;", - "xNorm = ( {0}( ASE_TEXTURE_PARAMS( topTexMap ), {1}tiling * worldPos.zy * float2( nsign.x, 1.0 ){2} ) );", - "yNorm = ( {0}( ASE_TEXTURE_PARAMS( topTexMap ), {1}tiling * worldPos.xz * float2( nsign.y, 1.0 ){2} ) );", - "zNorm = ( {0}( ASE_TEXTURE_PARAMS( topTexMap ), {1}tiling * worldPos.xy * float2( -nsign.z, 1.0 ){2} ) );" - }; - - // Cylinder sampling - private readonly List<string> m_functionSamplingBodySampCylinder = new List<string>() { - "half4 xNorm; half4 yNorm; half4 yNormN; half4 zNorm;", - "xNorm = ( {0}( ASE_TEXTURE_PARAMS( midTexMap ), {1}tiling * worldPos.zy * float2( nsign.x, 1.0 ){3} ) );", - "yNorm = ( {0}( ASE_TEXTURE_PARAMS( topTexMap ), {1}tiling * worldPos.xz * float2( nsign.y, 1.0 ){2} ) );", - "yNormN = ( {0}( ASE_TEXTURE_PARAMS( botTexMap ), {1}tiling * worldPos.xz * float2( nsign.y, 1.0 ){4} ) );", - "zNorm = ( {0}( ASE_TEXTURE_PARAMS( midTexMap ), {1}tiling * worldPos.xy * float2( -nsign.z, 1.0 ){3} ) );" - }; - - private readonly List<string> m_functionSamplingBodySignsSphere = new List<string>() { - "xNorm.xyz = half3( {0}( xNorm{1} ).xy * float2( nsign.x, 1.0 ) + worldNormal.zy, worldNormal.x ).zyx;", - "yNorm.xyz = half3( {0}( yNorm{1} ).xy * float2( nsign.y, 1.0 ) + worldNormal.xz, worldNormal.y ).xzy;", - "zNorm.xyz = half3( {0}( zNorm{1} ).xy * float2( -nsign.z, 1.0 ) + worldNormal.xy, worldNormal.z ).xyz;" - }; - - private readonly List<string> m_functionSamplingBodySignsSphereScale = new List<string>() { - "xNorm.xyz = half3( {0}( xNorm, normalScale.y ).xy * float2( nsign.x, 1.0 ) + worldNormal.zy, worldNormal.x ).zyx;", - "yNorm.xyz = half3( {0}( yNorm, normalScale.x ).xy * float2( nsign.y, 1.0 ) + worldNormal.xz, worldNormal.y ).xzy;", - "zNorm.xyz = half3( {0}( zNorm, normalScale.y ).xy * float2( -nsign.z, 1.0 ) + worldNormal.xy, worldNormal.z ).xyz;" - }; - - private readonly List<string> m_functionSamplingBodySignsCylinder = new List<string>() { - "yNormN.xyz = half3( {0}( yNormN {1} ).xy * float2( nsign.y, 1.0 ) + worldNormal.xz, worldNormal.y ).xzy;" - }; - - private readonly List<string> m_functionSamplingBodySignsCylinderScale = new List<string>() { - "yNormN.xyz = half3( {0}( yNormN, normalScale.z ).xy * float2( nsign.y, 1.0 ) + worldNormal.xz, worldNormal.y ).xzy;" - }; - - private readonly List<string> m_functionSamplingBodyReturnSphereNormalize = new List<string>() { - "return normalize( xNorm.xyz * projNormal.x + yNorm.xyz * projNormal.y + zNorm.xyz * projNormal.z );" - }; - - private readonly List<string> m_functionSamplingBodyReturnCylinderNormalize = new List<string>() { - "return normalize( xNorm.xyz * projNormal.x + yNorm.xyz * projNormal.y + yNormN.xyz * negProjNormalY + zNorm.xyz * projNormal.z );" - }; - - private readonly List<string> m_functionSamplingBodyReturnSphere = new List<string>() { - "return xNorm * projNormal.x + yNorm * projNormal.y + zNorm * projNormal.z;" - }; - - private readonly List<string> m_functionSamplingBodyReturnCylinder = new List<string>() { - "return xNorm * projNormal.x + yNorm * projNormal.y + yNormN * negProjNormalY + zNorm * projNormal.z;" - }; - - private Rect m_allPicker; - private Rect m_startPicker; - private Rect m_pickerButton; - private bool m_editing; - - void ConvertListTo( MasterNodeDataCollector dataCollector, bool scaleInfo, List<string> original, List<string> dest ) - { - int count = original.Count; - string scale = string.Empty; - string func = string.Empty; - bool applyScale = false; - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - if( dataCollector.TemplateDataCollectorInstance.IsHDRP ) - { - func = "UnpackNormalmapRGorAG"; - } - else - { - func = "UnpackNormalScale"; - } - - if( !scaleInfo ) - { - scale = " , 1.0"; - applyScale = true; - } - } - else - { - func = scaleInfo ? "UnpackScaleNormal" : "UnpackNormal"; - applyScale = !scaleInfo; - } - - for( int i = 0; i < count; i++ ) - { - if( applyScale ) - dest.Add( string.Format( original[ i ], func, scale ) ); - else - dest.Add( string.Format( original[ i ], func ) ); - } - } - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.SAMPLER2D, true, "Top", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT, true, "Top Index", -1, MasterNodePortCategory.Fragment, 5 ); - AddInputPort( WirePortDataType.SAMPLER2D, true, "Middle", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, true, "Mid Index", -1, MasterNodePortCategory.Fragment, 6 ); - AddInputPort( WirePortDataType.SAMPLER2D, true, "Bottom", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, true, "Bot Index", -1, MasterNodePortCategory.Fragment, 7 ); - AddInputPort( WirePortDataType.FLOAT3, true, "Pos", -1, MasterNodePortCategory.Fragment, 9 ); - AddInputPort( WirePortDataType.FLOAT3, true, "Scale", -1, MasterNodePortCategory.Fragment, 8 ); - AddInputPort( WirePortDataType.FLOAT2, true, "Tiling", -1, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, true, "Falloff", -1, MasterNodePortCategory.Fragment, 4 ); - AddOutputColorPorts( "RGBA" ); - m_useInternalPortData = true; - m_topTexPort = InputPorts[ 0 ]; - m_topIndexPort = InputPorts[ 1 ]; - m_midTexPort = InputPorts[ 2 ]; - m_midIndexPort = InputPorts[ 3 ]; - m_botTexPort = InputPorts[ 4 ]; - m_botIndexPort = InputPorts[ 5 ]; - m_posPort = InputPorts[ 6 ]; - m_scalePort = InputPorts[ 7 ]; - m_tilingPort = InputPorts[ 8 ]; - m_falloffPort = InputPorts[ 9 ]; - - m_scalePort.Visible = false; - m_scalePort.Vector3InternalData = Vector3.one; - m_tilingPort.FloatInternalData = 1; - m_tilingPort.Vector2InternalData = Vector2.one; - m_topIndexPort.FloatInternalData = 1; - m_falloffPort.FloatInternalData = 1; - m_topIndexPort.Visible = false; - m_selectedLocation = PreviewLocation.TopCenter; - m_marginPreviewLeft = 43; - m_drawPreviewAsSphere = true; - m_drawPreviewExpander = false; - m_drawPreview = true; - m_showPreview = true; - m_autoDrawInternalPortData = false; - m_textLabelWidth = 125; - //m_propertyInspectorName = "Triplanar Sampler"; - m_previewShaderGUID = "8723015ec59743143aadfbe480e34391"; - } - - public void ReadPropertiesData() - { - // Top - if( UIUtils.IsUniformNameAvailable( m_tempTopName ) ) - { - UIUtils.ReleaseUniformName( UniqueId, m_topTexture.PropertyName ); - if( !string.IsNullOrEmpty( m_tempTopInspectorName ) ) - { - m_topTexture.SetInspectorName( m_tempTopInspectorName ); - } - if( !string.IsNullOrEmpty( m_tempTopName ) ) - m_topTexture.SetPropertyName( m_tempTopName ); - UIUtils.RegisterUniformName( UniqueId, m_topTexture.PropertyName ); - } - m_topTexture.DefaultTextureValue = m_tempTopDefaultValue; - m_topTexture.OrderIndex = m_tempTopOrderIndex; - m_topTexture.DefaultValue = m_tempTopDefaultTexture; - //m_topTexture.SetMaterialMode( UIUtils.CurrentWindow.CurrentGraph.CurrentMaterial, true ); - - // Mid - if( UIUtils.IsUniformNameAvailable( m_tempMidName ) ) - { - UIUtils.ReleaseUniformName( UniqueId, m_midTexture.PropertyName ); - if( !string.IsNullOrEmpty( m_tempMidInspectorName ) ) - m_midTexture.SetInspectorName( m_tempMidInspectorName ); - if( !string.IsNullOrEmpty( m_tempMidName ) ) - m_midTexture.SetPropertyName( m_tempMidName ); - UIUtils.RegisterUniformName( UniqueId, m_midTexture.PropertyName ); - } - m_midTexture.DefaultTextureValue = m_tempMidDefaultValue; - m_midTexture.OrderIndex = m_tempMidOrderIndex; - m_midTexture.DefaultValue = m_tempMidDefaultTexture; - - // Bot - if( UIUtils.IsUniformNameAvailable( m_tempBotName ) ) - { - UIUtils.ReleaseUniformName( UniqueId, m_botTexture.PropertyName ); - if( !string.IsNullOrEmpty( m_tempBotInspectorName ) ) - m_botTexture.SetInspectorName( m_tempBotInspectorName ); - if( !string.IsNullOrEmpty( m_tempBotName ) ) - m_botTexture.SetPropertyName( m_tempBotName ); - UIUtils.RegisterUniformName( UniqueId, m_botTexture.PropertyName ); - } - m_botTexture.DefaultTextureValue = m_tempBotDefaultValue; - m_botTexture.OrderIndex = m_tempBotOrderIndex; - m_botTexture.DefaultValue = m_tempBotDefaultTexture; - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - - if( !m_texturesInitialize ) - return; - - m_topTexture.SetMaterialMode( mat, fetchMaterialValues ); - m_midTexture.SetMaterialMode( mat, fetchMaterialValues ); - m_botTexture.SetMaterialMode( mat, fetchMaterialValues ); - } - - public void Init() - { - if( m_texturesInitialize ) - return; - else - m_texturesInitialize = true; - - // Top - if( m_topTexture == null ) - { - m_topTexture = ScriptableObject.CreateInstance<TexturePropertyNode>(); - } - m_topTexture.ContainerGraph = ContainerGraph; - m_topTexture.CustomPrefix = "Top Texture "; - m_topTexture.UniqueId = UniqueId; - m_topTexture.DrawAutocast = false; - m_topTexture.CurrentParameterType = PropertyType.Property; - - // Mid - if( m_midTexture == null ) - { - m_midTexture = ScriptableObject.CreateInstance<TexturePropertyNode>(); - } - m_midTexture.ContainerGraph = ContainerGraph; - m_midTexture.CustomPrefix = "Mid Texture "; - m_midTexture.UniqueId = UniqueId; - m_midTexture.DrawAutocast = false; - m_midTexture.CurrentParameterType = PropertyType.Property; - - // Bot - if( m_botTexture == null ) - { - m_botTexture = ScriptableObject.CreateInstance<TexturePropertyNode>(); - } - m_botTexture.ContainerGraph = ContainerGraph; - m_botTexture.CustomPrefix = "Bot Texture "; - m_botTexture.UniqueId = UniqueId; - m_botTexture.DrawAutocast = false; - m_botTexture.CurrentParameterType = PropertyType.Property; - - if( m_materialMode ) - SetDelayedMaterialMode( ContainerGraph.CurrentMaterial ); - - if( m_nodeAttribs != null ) - m_uniqueName = m_nodeAttribs.Name + UniqueId; - - ConfigurePorts(); - - ReRegisterPorts(); - } - - public override void Destroy() - { - base.Destroy(); - - //UIUtils.UnregisterPropertyNode( m_topTexture ); - //UIUtils.UnregisterTexturePropertyNode( m_topTexture ); - - //UIUtils.UnregisterPropertyNode( m_midTexture ); - //UIUtils.UnregisterTexturePropertyNode( m_midTexture ); - - //UIUtils.UnregisterPropertyNode( m_botTexture ); - //UIUtils.UnregisterTexturePropertyNode( m_botTexture ); - if( m_topTexture != null ) - m_topTexture.Destroy(); - m_topTexture = null; - if( m_midTexture != null ) - m_midTexture.Destroy(); - m_midTexture = null; - if( m_botTexture != null ) - m_botTexture.Destroy(); - m_botTexture = null; - - m_tempTopDefaultTexture = null; - m_tempMidDefaultTexture = null; - m_tempBotDefaultTexture = null; - - m_topTexPort = null; - m_midTexPort = null; - m_botTexPort = null; - m_tilingPort = null; - m_falloffPort = null; - m_topIndexPort = null; - m_midIndexPort = null; - m_botIndexPort = null; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - if( m_topTexture == null ) - return; - - - if( m_topTexPort.IsConnected ) - { - PreviewMaterial.SetTexture( "_A", m_topTexPort.InputPreviewTexture( ContainerGraph ) ); - } - else - { - PreviewMaterial.SetTexture( "_A", m_topTexture.Value ); - } - if( m_selectedTriplanarType == TriplanarType.Cylindrical && m_midTexture != null ) - { - if( m_midTexPort.IsConnected ) - PreviewMaterial.SetTexture( "_B", m_midTexPort.InputPreviewTexture( ContainerGraph ) ); - else - PreviewMaterial.SetTexture( "_B", m_midTexture.Value ); - if( m_botTexPort.IsConnected ) - PreviewMaterial.SetTexture( "_C", m_botTexPort.InputPreviewTexture( ContainerGraph ) ); - else - PreviewMaterial.SetTexture( "_C", m_botTexture.Value ); - } - - PreviewMaterial.SetFloat( "_IsNormal", ( m_normalCorrection ? 1 : 0 ) ); - PreviewMaterial.SetFloat( "_IsSpherical", ( m_selectedTriplanarType == TriplanarType.Spherical ? 1 : 0 ) ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( m_texturesInitialize ) - ReRegisterPorts(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( m_texturesInitialize ) - ReRegisterPorts(); - } - - public void ReRegisterPorts() - { - if( m_topTexPort.IsConnected ) - { - UIUtils.UnregisterPropertyNode( m_topTexture ); - UIUtils.UnregisterTexturePropertyNode( m_topTexture ); - } - else if( m_topTexPort.Visible ) - { - UIUtils.RegisterPropertyNode( m_topTexture ); - UIUtils.RegisterTexturePropertyNode( m_topTexture ); - } - - if( m_midTexPort.IsConnected || m_selectedTriplanarType == TriplanarType.Spherical ) - { - UIUtils.UnregisterPropertyNode( m_midTexture ); - UIUtils.UnregisterTexturePropertyNode( m_midTexture ); - } - else if( m_midTexPort.Visible && m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - UIUtils.RegisterPropertyNode( m_midTexture ); - UIUtils.RegisterTexturePropertyNode( m_midTexture ); - } - - if( m_botTexPort.IsConnected || m_selectedTriplanarType == TriplanarType.Spherical ) - { - UIUtils.UnregisterPropertyNode( m_botTexture ); - UIUtils.UnregisterTexturePropertyNode( m_botTexture ); - } - else if( m_botTexPort.Visible && m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - UIUtils.RegisterPropertyNode( m_botTexture ); - UIUtils.RegisterTexturePropertyNode( m_botTexture ); - } - } - - public void ConfigurePorts() - { - switch( m_selectedTriplanarType ) - { - case TriplanarType.Spherical: - m_topTexPort.Name = "Tex"; - m_midTexPort.Visible = false; - m_botTexPort.Visible = false; - m_scalePort.ChangeType( WirePortDataType.FLOAT, false ); - break; - case TriplanarType.Cylindrical: - m_topTexPort.Name = "Top"; - m_midTexPort.Visible = true; - m_botTexPort.Visible = true; - m_scalePort.ChangeType( WirePortDataType.FLOAT3, false ); - break; - } - - if( m_normalCorrection ) - { - m_outputPorts[ 0 ].ChangeProperties( "XYZ", WirePortDataType.FLOAT3, false ); - m_outputPorts[ 1 ].ChangeProperties( "X", WirePortDataType.FLOAT, false ); - m_outputPorts[ 2 ].ChangeProperties( "Y", WirePortDataType.FLOAT, false ); - m_outputPorts[ 3 ].ChangeProperties( "Z", WirePortDataType.FLOAT, false ); - - m_outputPorts[ 4 ].Visible = false; - - m_scalePort.Visible = true; - } - else - { - m_outputPorts[ 0 ].ChangeProperties( "RGBA", WirePortDataType.FLOAT4, false ); - m_outputPorts[ 1 ].ChangeProperties( "R", WirePortDataType.FLOAT, false ); - m_outputPorts[ 2 ].ChangeProperties( "G", WirePortDataType.FLOAT, false ); - m_outputPorts[ 3 ].ChangeProperties( "B", WirePortDataType.FLOAT, false ); - m_outputPorts[ 4 ].ChangeProperties( "A", WirePortDataType.FLOAT, false ); - - m_outputPorts[ 4 ].Visible = true; - - m_scalePort.Visible = false; - } - - if( m_arraySupport ) - { - m_topIndexPort.Visible = true; - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - m_midIndexPort.Visible = true; - m_botIndexPort.Visible = true; - } - else - { - m_midIndexPort.Visible = false; - m_botIndexPort.Visible = false; - } - } - else - { - m_topIndexPort.Visible = false; - m_midIndexPort.Visible = false; - m_botIndexPort.Visible = false; - } - - if( m_selectedTriplanarSpace == TriplanarSpace.World ) - m_posPort.Name = "World Pos"; - else - m_posPort.Name = "Local Pos"; - - m_outputPorts[ 0 ].DirtyLabelSize = true; - m_sizeIsDirty = true; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, "Parameters", DrawMainOptions ); - DrawInternalDataGroup(); - if( m_selectedTriplanarType == TriplanarType.Spherical && !m_topTexPort.IsConnected ) - NodeUtils.DrawPropertyGroup( ref m_topTextureFoldout, "Texture", DrawTopTextureOptions ); - else if( !m_topTexPort.IsConnected ) - NodeUtils.DrawPropertyGroup( ref m_topTextureFoldout, "Top Texture", DrawTopTextureOptions ); - - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - if( !m_midTexPort.IsConnected ) - NodeUtils.DrawPropertyGroup( ref m_midTextureFoldout, "Middle Texture", DrawMidTextureOptions ); - if( !m_botTexPort.IsConnected ) - NodeUtils.DrawPropertyGroup( ref m_botTextureFoldout, "Bottom Texture", DrawBotTextureOptions ); - } - } - - void DrawMainOptions() - { - EditorGUI.BeginChangeCheck(); - m_propertyInspectorName = EditorGUILayoutTextField( "Name", m_propertyInspectorName ); - - m_selectedTriplanarType = (TriplanarType)EditorGUILayoutEnumPopup( "Mapping", m_selectedTriplanarType ); - - m_selectedTriplanarSpace = (TriplanarSpace)EditorGUILayoutEnumPopup( "Space", m_selectedTriplanarSpace ); - - m_normalCorrection = EditorGUILayoutToggle( "Normal Map", m_normalCorrection ); - - m_arraySupport = EditorGUILayoutToggle( "Use Texture Array", m_arraySupport ); - if( m_arraySupport ) - EditorGUILayout.HelpBox( "Please connect all texture ports to a Texture Object node with a texture array asset for this option to work correctly", MessageType.Info ); - - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_propertyInspectorName ); - ConfigurePorts(); - ReRegisterPorts(); - } - } - - void DrawTopTextureOptions() - { - EditorGUI.BeginChangeCheck(); - m_topTexture.ShowPropertyInspectorNameGUI(); - m_topTexture.ShowPropertyNameGUI( true ); - m_topTexture.ShowToolbar(); - if( EditorGUI.EndChangeCheck() ) - { - m_topTexture.BeginPropertyFromInspectorCheck(); - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - - m_topTexture.CheckPropertyFromInspector(); - } - - void DrawMidTextureOptions() - { - if( m_midTexture == null ) - return; - - EditorGUI.BeginChangeCheck(); - m_midTexture.ShowPropertyInspectorNameGUI(); - m_midTexture.ShowPropertyNameGUI( true ); - m_midTexture.ShowToolbar(); - if( EditorGUI.EndChangeCheck() ) - { - m_midTexture.BeginPropertyFromInspectorCheck(); - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - - m_midTexture.CheckPropertyFromInspector(); - } - - void DrawBotTextureOptions() - { - if( m_botTexture == null ) - return; - - EditorGUI.BeginChangeCheck(); - m_botTexture.ShowPropertyInspectorNameGUI(); - m_botTexture.ShowPropertyNameGUI( true ); - m_botTexture.ShowToolbar(); - if( EditorGUI.EndChangeCheck() ) - { - m_botTexture.BeginPropertyFromInspectorCheck(); - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - - m_botTexture.CheckPropertyFromInspector(); - } - - public override void OnEnable() - { - base.OnEnable(); - //if( !m_afterDeserialize ) - //Init(); //Generate texture properties - //else - //m_afterDeserialize = false; - - //if( m_topTexture != null ) - // m_topTexture.ReRegisterName = true; - - //if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - //{ - // if( m_midTexture != null ) - // m_midTexture.ReRegisterName = true; - - // if( m_botTexture != null ) - // m_botTexture.ReRegisterName = true; - //} - } - - //bool m_afterDeserialize = false; - - //public override void OnAfterDeserialize() - //{ - // base.OnAfterDeserialize(); - // m_afterDeserialize = true; - //} - - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - - Init(); - - if( m_topTexture.ReRegisterName ) - { - m_topTexture.ReRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, m_topTexture.PropertyName ); - } - - m_topTexture.CheckDelayedDirtyProperty(); - m_topTexture.CheckPropertyFromInspector(); - m_topTexture.CheckDuplicateProperty(); - - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - if( m_midTexture.ReRegisterName ) - { - m_midTexture.ReRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, m_midTexture.PropertyName ); - } - - m_midTexture.CheckDelayedDirtyProperty(); - m_midTexture.CheckPropertyFromInspector(); - m_midTexture.CheckDuplicateProperty(); - - if( m_botTexture.ReRegisterName ) - { - m_botTexture.ReRegisterName = false; - UIUtils.RegisterUniformName( UniqueId, m_botTexture.PropertyName ); - } - - m_botTexture.CheckDelayedDirtyProperty(); - m_botTexture.CheckPropertyFromInspector(); - m_botTexture.CheckDuplicateProperty(); - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_allPicker = m_previewRect; - m_allPicker.x -= 43 * drawInfo.InvertedZoom; - m_allPicker.width = 43 * drawInfo.InvertedZoom; - - m_startPicker = m_previewRect; - m_startPicker.x -= 43 * drawInfo.InvertedZoom; - m_startPicker.width = 43 * drawInfo.InvertedZoom; - m_startPicker.height = 43 * drawInfo.InvertedZoom; - - m_pickerButton = m_startPicker; - m_pickerButton.width = 30 * drawInfo.InvertedZoom; - m_pickerButton.x = m_startPicker.xMax - m_pickerButton.width - 2; - m_pickerButton.height = 10 * drawInfo.InvertedZoom; - m_pickerButton.y = m_startPicker.yMax - m_pickerButton.height - 2; - } - - - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( !( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp || drawInfo.CurrentEventType == EventType.ExecuteCommand || drawInfo.CurrentEventType == EventType.DragPerform ) ) - return; - - bool insideBox = m_allPicker.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - m_editing = true; - } - else if( m_editing && !insideBox && drawInfo.CurrentEventType != EventType.ExecuteCommand ) - { - GUI.FocusControl( null ); - m_editing = false; - } - } - private int m_pickId = 0; - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - Rect pickerButtonClone = m_pickerButton; - Rect startPickerClone = m_startPicker; - - if( m_editing ) - { - if( GUI.Button( pickerButtonClone, string.Empty, GUIStyle.none ) ) - { - int controlID = EditorGUIUtility.GetControlID( FocusType.Passive ); - EditorGUIUtility.ShowObjectPicker<Texture2D>( m_topTexture.Value, false, "", controlID ); - m_pickId = 0; - } - - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - pickerButtonClone.y += startPickerClone.height; - if( GUI.Button( pickerButtonClone, string.Empty, GUIStyle.none ) ) - { - int controlID = EditorGUIUtility.GetControlID( FocusType.Passive ); - EditorGUIUtility.ShowObjectPicker<Texture2D>( m_midTexture.Value, false, "", controlID ); - m_pickId = 1; - } - - pickerButtonClone.y += startPickerClone.height; - if( GUI.Button( pickerButtonClone, string.Empty, GUIStyle.none ) ) - { - int controlID = EditorGUIUtility.GetControlID( FocusType.Passive ); - EditorGUIUtility.ShowObjectPicker<Texture2D>( m_botTexture.Value, false, "", controlID ); - m_pickId = 2; - } - } - - string commandName = Event.current.commandName; - UnityEngine.Object newValue = null; - if( commandName.Equals( "ObjectSelectorUpdated" ) || commandName.Equals( "ObjectSelectorClosed" ) ) - { - newValue = EditorGUIUtility.GetObjectPickerObject(); - if( m_pickId == 2 ) - { - if( newValue != (UnityEngine.Object)m_botTexture.Value ) - { - PreviewIsDirty = true; - UndoRecordObject( "Changing value EditorGUIObjectField on node Triplanar Node" ); - m_botTexture.Value = newValue != null ? (Texture2D)newValue : null; - - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - else if( m_pickId == 1 ) - { - if( newValue != (UnityEngine.Object)m_midTexture.Value ) - { - PreviewIsDirty = true; - UndoRecordObject( "Changing value EditorGUIObjectField on node Triplanar Node" ); - m_midTexture.Value = newValue != null ? (Texture2D)newValue : null; - - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - else - { - if( newValue != (UnityEngine.Object)m_topTexture.Value ) - { - PreviewIsDirty = true; - UndoRecordObject( "Changing value EditorGUIObjectField on node Triplanar Node" ); - m_topTexture.Value = newValue != null ? (Texture2D)newValue : null; - - if( m_materialMode ) - m_requireMaterialUpdate = true; - } - } - - if( commandName.Equals( "ObjectSelectorClosed" ) ) - m_editing = false; - } - - if( GUI.Button( startPickerClone, string.Empty, GUIStyle.none ) ) - { - if( m_topTexPort.IsConnected ) - { - UIUtils.FocusOnNode( m_topTexPort.GetOutputNode( 0 ), 1, true ); - } - else - { - if( m_topTexture.Value != null ) - { - Selection.activeObject = m_topTexture.Value; - EditorGUIUtility.PingObject( Selection.activeObject ); - } - } - m_editing = false; - } - - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - startPickerClone.y += startPickerClone.height; - if( GUI.Button( startPickerClone, string.Empty, GUIStyle.none ) ) - { - if( m_midTexPort.IsConnected ) - { - UIUtils.FocusOnNode( m_midTexPort.GetOutputNode( 0 ), 1, true ); - } - else - { - if( m_midTexture.Value != null ) - { - Selection.activeObject = m_midTexture.Value; - EditorGUIUtility.PingObject( Selection.activeObject ); - } - } - m_editing = false; - } - - startPickerClone.y += startPickerClone.height; - if( GUI.Button( startPickerClone, string.Empty, GUIStyle.none ) ) - { - if( m_botTexPort.IsConnected ) - { - UIUtils.FocusOnNode( m_botTexPort.GetOutputNode( 0 ), 1, true ); - } - else - { - if( m_botTexture.Value != null ) - { - Selection.activeObject = m_botTexture.Value; - EditorGUIUtility.PingObject( Selection.activeObject ); - } - } - m_editing = false; - } - } - } - - pickerButtonClone = m_pickerButton; - startPickerClone = m_startPicker; - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - // Top - if( m_topTexPort.IsConnected ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_topTexPort.GetOutputConnection( 0 ).OutputPreviewTexture, null, ScaleMode.ScaleAndCrop ); - } - else if( m_topTexture.Value != null ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_topTexture.Value, null, ScaleMode.ScaleAndCrop ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - else - { - GUI.Label( startPickerClone, string.Empty, UIUtils.ObjectFieldThumb ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - GUI.Label( startPickerClone, "None (Texture2D)", UIUtils.MiniObjectFieldThumbOverlay ); - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - } - GUI.Label( startPickerClone, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - // Mid - startPickerClone.y += startPickerClone.height; - pickerButtonClone.y += startPickerClone.height; - if( m_midTexPort.IsConnected ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_midTexPort.GetOutputConnection( 0 ).OutputPreviewTexture, null, ScaleMode.ScaleAndCrop ); - } - else if( m_midTexture.Value != null ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_midTexture.Value, null, ScaleMode.ScaleAndCrop ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - else - { - GUI.Label( startPickerClone, string.Empty, UIUtils.ObjectFieldThumb ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - GUI.Label( startPickerClone, "None (Texture2D)", UIUtils.MiniObjectFieldThumbOverlay ); - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - } - GUI.Label( startPickerClone, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - - // Bot - startPickerClone.y += startPickerClone.height; - startPickerClone.height = 42 * drawInfo.InvertedZoom; - pickerButtonClone.y += startPickerClone.height; - if( m_botTexPort.IsConnected ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_botTexPort.GetOutputConnection( 0 ).OutputPreviewTexture, null, ScaleMode.ScaleAndCrop ); - } - else if( m_botTexture.Value != null ) - { - EditorGUI.DrawPreviewTexture( startPickerClone, m_botTexture.Value, null, ScaleMode.ScaleAndCrop ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - else - { - GUI.Label( startPickerClone, string.Empty, UIUtils.ObjectFieldThumb ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - GUI.Label( startPickerClone, "None (Texture2D)", UIUtils.MiniObjectFieldThumbOverlay ); - GUI.Label( pickerButtonClone, "Select", UIUtils.MiniSamplerButton ); - } - } - GUI.Label( startPickerClone, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - } - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( currentMousePos2D.y - m_globalPosition.y > Constants.NODE_HEADER_HEIGHT + Constants.NODE_HEADER_EXTRA_HEIGHT ) - { - ContainerGraph.ParentWindow.ParametersWindow.IsMaximized = !ContainerGraph.ParentWindow.ParametersWindow.IsMaximized; - } - else - { - m_editPropertyNameMode = true; - GUI.FocusControl( m_uniqueName ); - TextEditor te = (TextEditor)GUIUtility.GetStateObject( typeof( TextEditor ), GUIUtility.keyboardControl ); - if( te != null ) - { - te.SelectAll(); - } - } - } - - public override void OnNodeSelected( bool value ) - { - base.OnNodeSelected( value ); - if( !value ) - m_editPropertyNameMode = false; - } - - public override void DrawTitle( Rect titlePos ) - { - if( m_editPropertyNameMode ) - { - titlePos.height = Constants.NODE_HEADER_HEIGHT; - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_uniqueName ); - m_propertyInspectorName = GUITextField( titlePos, m_propertyInspectorName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_propertyInspectorName ); - } - - if( Event.current.isKey && ( Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter ) ) - { - m_editPropertyNameMode = false; - GUIUtility.keyboardControl = 0; - } - } - else - { - base.DrawTitle( titlePos ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - bool sampleThroughMacros = UIUtils.CurrentWindow.OutsideGraph.SamplingThroughMacros; - //ConfigureFunctions(); - if( dataCollector.IsSRP ) - { - if( m_arraySupport ) - { - dataCollector.AddToDirectives( Constants.CustomASEStandardSamplerParams ); - for( int i = 0; i < Constants.CustomASESRPTextureArrayMacros.Length; i++ ) - dataCollector.AddToDirectives( Constants.CustomASESRPTextureArrayMacros[ i ] ); - } - else - { - if( sampleThroughMacros ) - { - dataCollector.AddToDirectives( Constants.CustomASESRPSamplerParams ); - } - else - { - dataCollector.AddToDirectives( Constants.CustomASEStandardSamplerParams ); - } - } - } - else - { - dataCollector.AddToDirectives( Constants.CustomASEStandardSamplerParams ); - } - dataCollector.AddPropertyNode( m_topTexture ); - dataCollector.AddPropertyNode( m_midTexture ); - dataCollector.AddPropertyNode( m_botTexture ); - - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Tessellation || dataCollector.PortCategory == MasterNodePortCategory.Vertex ); - - string texTop = string.Empty; - string texMid = string.Empty; - string texBot = string.Empty; - - if( m_topTexPort.IsConnected ) - { - texTop = m_topTexPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - dataCollector.AddToUniforms( UniqueId, m_topTexture.GetTexture2DUniformValue() ); - dataCollector.AddToProperties( UniqueId, m_topTexture.GetTexture2DPropertyValue(), m_topTexture.OrderIndex ); - texTop = m_topTexture.PropertyName; - } - - if( m_selectedTriplanarType == TriplanarType.Spherical ) - { - texMid = texTop; - texBot = texTop; - - if( sampleThroughMacros ) - { - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], texTop ) ); - texTop = string.Format( "TEXTURE2D_ARGS({0},sampler{0})", texTop ); - } - } - else - { - if( m_midTexPort.IsConnected ) - { - texMid = m_midTexPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - dataCollector.AddToUniforms( UniqueId, m_midTexture.GetTexture2DUniformValue() ); - dataCollector.AddToProperties( UniqueId, m_midTexture.GetTexture2DPropertyValue(), m_midTexture.OrderIndex ); - texMid = m_midTexture.PropertyName; - } - - if( m_botTexPort.IsConnected ) - { - texBot = m_botTexPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - dataCollector.AddToUniforms( UniqueId, m_botTexture.GetTexture2DUniformValue() ); - dataCollector.AddToProperties( UniqueId, m_botTexture.GetTexture2DPropertyValue(), m_botTexture.OrderIndex ); - texBot = m_botTexture.PropertyName; - } - - if( sampleThroughMacros ) - { - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], texTop ) ); - texTop = string.Format( "TEXTURE2D_ARGS({0},sampler{0})", texTop ); - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], texMid ) ); - texMid = string.Format( "TEXTURE2D_ARGS({0},sampler{0})", texMid ); - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ TextureType.Texture2D ], texBot ) ); - texBot = string.Format( "TEXTURE2D_ARGS({0},sampler{0})", texBot ); - } - } - - if( !isVertex ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - } - - string topIndex = "0"; - string midIndex = "0"; - string botIndex = "0"; - - if( m_arraySupport && ( !m_topTexPort.IsConnected && m_selectedTriplanarType == TriplanarType.Spherical - || m_selectedTriplanarType == TriplanarType.Cylindrical && !( m_topTexPort.IsConnected && m_midTexPort.IsConnected && m_botTexPort.IsConnected ) ) ) - m_arraySupport = false; - - if( m_arraySupport ) - { - topIndex = m_topIndexPort.GeneratePortInstructions( ref dataCollector ); - if( m_selectedTriplanarType == TriplanarType.Cylindrical ) - { - midIndex = m_midIndexPort.GeneratePortInstructions( ref dataCollector ); - botIndex = m_botIndexPort.GeneratePortInstructions( ref dataCollector ); - } - } - - string tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ); - string falloff = m_falloffPort.GeneratePortInstructions( ref dataCollector ); - - bool scaleNormals = false; - if( m_scalePort.IsConnected || ( m_scalePort.IsConnected && ( m_scalePort.Vector3InternalData == Vector3.one || m_scalePort.FloatInternalData == 1 ) ) ) - scaleNormals = true; - - string samplingTriplanar = string.Empty; - string headerID = string.Empty; - string header = string.Empty; - string callHeader = string.Empty; - string samplers = string.Empty; - string extraArguments = string.Empty; - List<string> triplanarBody = new List<string>(); - - triplanarBody.AddRange( m_functionSamplingBodyProj ); - if( m_selectedTriplanarType == TriplanarType.Spherical ) - { - headerID += "S"; - samplers = m_arraySupport ? ( dataCollector.IsSRP ? m_singularArrayTextureSRP : m_singularArrayTextureStandard ) : (sampleThroughMacros? m_singularTextureSRP : m_singularTextureRegular); - - triplanarBody.AddRange( m_functionSamplingBodySampSphere ); - - if( m_normalCorrection ) - { - headerID += "N"; - if( scaleNormals ) - { - ConvertListTo( dataCollector, true, m_functionSamplingBodySignsSphereScale, triplanarBody ); - //triplanarBody.AddRange( m_functionSamplingBodySignsSphereScale ); - } - else - { - ConvertListTo( dataCollector, false, m_functionSamplingBodySignsSphere, triplanarBody ); - //triplanarBody.AddRange( m_functionSamplingBodySignsSphere ); - } - triplanarBody.AddRange( m_functionSamplingBodyReturnSphereNormalize ); - } - else - { - triplanarBody.AddRange( m_functionSamplingBodyReturnSphere ); - } - } - else - { - headerID += "C"; - samplers = m_arraySupport ? ( dataCollector.IsSRP ? m_topmidbotArrayTextureSRP : m_topmidbotArrayTextureStandard ) :( sampleThroughMacros? m_topmidbotTextureSRP: m_topmidbotTextureRegular); - extraArguments = ", {7}, {8}"; - triplanarBody.AddRange( m_functionSamplingBodyNegProj ); - - triplanarBody.AddRange( m_functionSamplingBodySampCylinder ); - - if( m_normalCorrection ) - { - headerID += "N"; - if( scaleNormals ) - { - //triplanarBody.AddRange( m_functionSamplingBodySignsSphereScale ); - ConvertListTo( dataCollector, true, m_functionSamplingBodySignsSphereScale, triplanarBody ); - ConvertListTo( dataCollector, true, m_functionSamplingBodySignsCylinderScale, triplanarBody ); - //triplanarBody.AddRange( m_functionSamplingBodySignsCylinderScale ); - } - else - { - //triplanarBody.AddRange( m_functionSamplingBodySignsSphere ); - ConvertListTo( dataCollector, false, m_functionSamplingBodySignsSphere, triplanarBody ); - ConvertListTo( dataCollector, false, m_functionSamplingBodySignsCylinder, triplanarBody ); - //triplanarBody.AddRange( m_functionSamplingBodySignsCylinder ); - } - triplanarBody.AddRange( m_functionSamplingBodyReturnCylinderNormalize ); - } - else - { - triplanarBody.AddRange( m_functionSamplingBodyReturnCylinder ); - } - } - - if( isVertex ) - { - if( m_arraySupport ) - { - string arrayFetch = dataCollector.IsSRP ? "ASE_SAMPLE_TEXTURE2D_ARRAY_LOD" : "UNITY_SAMPLE_TEX2DARRAY_LOD"; - - headerID += "VA"; - for( int i = 0; i < triplanarBody.Count; i++ ) - triplanarBody[ i ] = string.Format( triplanarBody[ i ], arrayFetch, "float3( ", ", 0 ), index.x", ", 0 ), index.y", ", 0 ), index.z" ); - } - else - { - headerID += "V"; - string sampleFunc = sampleThroughMacros ? "SAMPLE_TEXTURE2DLOD" : "tex2Dlod"; - for( int i = 0; i < triplanarBody.Count; i++ ) - triplanarBody[ i ] = string.Format( triplanarBody[ i ], sampleFunc, "float4( ", ", 0, 0 )", ", 0, 0 )", ", 0, 0 )" ); - } - } - else - { - if( m_arraySupport ) - { - string arrayFetch = dataCollector.IsSRP ? "ASE_SAMPLE_TEXTURE2D_ARRAY" : "UNITY_SAMPLE_TEX2DARRAY"; - headerID += "FA"; - for( int i = 0; i < triplanarBody.Count; i++ ) - triplanarBody[ i ] = string.Format( triplanarBody[ i ], arrayFetch, "float3( ", ", index.x )", ", index.y )", ", index.z )" ); - } - else - { - headerID += "F"; - string sampleFunc = sampleThroughMacros ? "SAMPLE_TEXTURE2D" : "tex2D"; - for( int i = 0; i < triplanarBody.Count; i++ ) - { - triplanarBody[ i ] = string.Format( triplanarBody[ i ], sampleFunc, "", "", "", "" ); - - } - } - } - - string type = UIUtils.WirePortToCgType( m_outputPorts[ 0 ].DataType ); - header = string.Format( m_functionHeader, type, headerID, samplers ); - callHeader = string.Format( m_functionCall, headerID, "{0}, {1}, {2}, {3}, {4}, {5}, {6}" + extraArguments ); - - IOUtils.AddFunctionHeader( ref samplingTriplanar, header ); - foreach( string line in triplanarBody ) - IOUtils.AddFunctionLine( ref samplingTriplanar, line ); - IOUtils.CloseFunctionBody( ref samplingTriplanar ); - - string pos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, UniqueId ); - string norm = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ); - string worldToTangent = string.Empty; - if( m_normalCorrection ) - worldToTangent = GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - - if( m_selectedTriplanarSpace == TriplanarSpace.Object ) - { - if( m_normalCorrection ) - { - string vt = GeneratorUtils.GenerateVertexTangent( ref dataCollector, UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3 ); - string vbt = GeneratorUtils.GenerateVertexBitangent( ref dataCollector, UniqueId, CurrentPrecisionType ); - norm = GeneratorUtils.GenerateVertexNormal( ref dataCollector, UniqueId, CurrentPrecisionType ); - dataCollector.AddLocalVariable( UniqueId, "float3x3 objectToTangent = float3x3("+ vt + ", "+ vbt + ", "+ norm + ");" ); - pos = GeneratorUtils.GenerateVertexPosition( ref dataCollector, UniqueId, WirePortDataType.FLOAT3 ); - worldToTangent = "objectToTangent"; - } - else - { - pos = GeneratorUtils.GenerateVertexPosition( ref dataCollector, UniqueId, WirePortDataType.FLOAT3 ); - norm = GeneratorUtils.GenerateVertexNormal( ref dataCollector, UniqueId, CurrentPrecisionType ); - } - } - - if( m_posPort.IsConnected ) - { - pos = m_posPort.GeneratePortInstructions( ref dataCollector ); - } - - string call = string.Empty; - - if( m_arraySupport ) - { - string arrayPassParams = dataCollector.IsSRP ? "ASE_TEXTURE2D_ARRAY_PARAM" : "UNITY_PASS_TEX2DARRAY"; - texTop = arrayPassParams + "(" + texTop + ")"; - texMid = arrayPassParams + "(" + texMid + ")"; - texBot = arrayPassParams + "(" + texBot + ")"; - } - - string normalScale = m_scalePort.GeneratePortInstructions( ref dataCollector ); - - if( m_selectedTriplanarType == TriplanarType.Spherical ) - call = dataCollector.AddFunctions( callHeader, samplingTriplanar, texTop, pos, norm, falloff, tiling, normalScale, topIndex ); - else - call = dataCollector.AddFunctions( callHeader, samplingTriplanar, texTop, texMid, texBot, pos, norm, falloff, tiling, normalScale, "float3(" + topIndex + "," + midIndex + "," + botIndex + ")" ); - dataCollector.AddToLocalVariables( dataCollector.PortCategory, UniqueId, type + " triplanar" + OutputId + " = " + call + ";" ); - if( m_normalCorrection ) - { - dataCollector.AddToLocalVariables( dataCollector.PortCategory, UniqueId, "float3 tanTriplanarNormal" + OutputId + " = mul( " + worldToTangent + ", triplanar" + OutputId + " );" ); - return GetOutputVectorItem( 0, outputId, "tanTriplanarNormal" + OutputId ); - } - else - { - return GetOutputVectorItem( 0, outputId, "triplanar" + OutputId ); - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - m_topTexture.OnPropertyNameChanged(); - if( mat.HasProperty( m_topTexture.PropertyName ) && !InsideShaderFunction ) - { - mat.SetTexture( m_topTexture.PropertyName, m_topTexture.MaterialValue ); - } - - m_midTexture.OnPropertyNameChanged(); - if( mat.HasProperty( m_midTexture.PropertyName ) && !InsideShaderFunction ) - { - mat.SetTexture( m_midTexture.PropertyName, m_midTexture.MaterialValue ); - } - - m_botTexture.OnPropertyNameChanged(); - if( mat.HasProperty( m_botTexture.PropertyName ) && !InsideShaderFunction ) - { - mat.SetTexture( m_botTexture.PropertyName, m_botTexture.MaterialValue ); - } - } - - public void SetDelayedMaterialMode( Material mat ) - { - m_topTexture.SetMaterialMode( mat, false ); - if( mat.HasProperty( m_topTexture.PropertyName ) ) - { - m_topTexture.MaterialValue = mat.GetTexture( m_topTexture.PropertyName ); - } - - m_midTexture.SetMaterialMode( mat, false ); - if( mat.HasProperty( m_midTexture.PropertyName ) ) - { - m_midTexture.MaterialValue = mat.GetTexture( m_midTexture.PropertyName ); - } - - m_botTexture.SetMaterialMode( mat, false ); - if( mat.HasProperty( m_botTexture.PropertyName ) ) - { - m_botTexture.MaterialValue = mat.GetTexture( m_botTexture.PropertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - base.ForceUpdateFromMaterial( material ); - if( material.HasProperty( m_topTexture.PropertyName ) ) - { - m_topTexture.MaterialValue = material.GetTexture( m_topTexture.PropertyName ); - PreviewIsDirty = true; - } - - if( material.HasProperty( m_midTexture.PropertyName ) ) - { - m_midTexture.MaterialValue = material.GetTexture( m_midTexture.PropertyName ); - PreviewIsDirty = true; - } - - if( material.HasProperty( m_botTexture.PropertyName ) ) - { - m_botTexture.MaterialValue = material.GetTexture( m_botTexture.PropertyName ); - PreviewIsDirty = true; - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedTriplanarType = (TriplanarType)Enum.Parse( typeof( TriplanarType ), GetCurrentParam( ref nodeParams ) ); - m_selectedTriplanarSpace = (TriplanarSpace)Enum.Parse( typeof( TriplanarSpace ), GetCurrentParam( ref nodeParams ) ); - m_normalCorrection = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - m_tempTopInspectorName = GetCurrentParam( ref nodeParams ); - m_tempTopName = GetCurrentParam( ref nodeParams ); - m_tempTopDefaultValue = (TexturePropertyValues)Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_tempTopOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_tempTopDefaultTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( GetCurrentParam( ref nodeParams ) ); - - m_tempMidInspectorName = GetCurrentParam( ref nodeParams ); - m_tempMidName = GetCurrentParam( ref nodeParams ); - m_tempMidDefaultValue = (TexturePropertyValues)Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_tempMidOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_tempMidDefaultTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( GetCurrentParam( ref nodeParams ) ); - - m_tempBotInspectorName = GetCurrentParam( ref nodeParams ); - m_tempBotName = GetCurrentParam( ref nodeParams ); - m_tempBotDefaultValue = (TexturePropertyValues)Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_tempBotOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_tempBotDefaultTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( GetCurrentParam( ref nodeParams ) ); - - if( UIUtils.CurrentShaderVersion() > 6102 ) - m_propertyInspectorName = GetCurrentParam( ref nodeParams ); - - if( UIUtils.CurrentShaderVersion() > 13701 ) - m_arraySupport = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - SetTitleText( m_propertyInspectorName ); - - ConfigurePorts(); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - - Init(); - - ReadPropertiesData(); - - ConfigurePorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedTriplanarType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedTriplanarSpace ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalCorrection ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_topTexture.PropertyInspectorName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_topTexture.PropertyName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_topTexture.DefaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_topTexture.OrderIndex.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_topTexture.DefaultValue != null ) ? AssetDatabase.GetAssetPath( m_topTexture.DefaultValue ) : Constants.NoStringValue ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_midTexture.PropertyInspectorName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_midTexture.PropertyName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_midTexture.DefaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_midTexture.OrderIndex.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_midTexture.DefaultValue != null ) ? AssetDatabase.GetAssetPath( m_midTexture.DefaultValue ) : Constants.NoStringValue ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_botTexture.PropertyInspectorName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_botTexture.PropertyName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_botTexture.DefaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_botTexture.OrderIndex.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_botTexture.DefaultValue != null ) ? AssetDatabase.GetAssetPath( m_botTexture.DefaultValue ) : Constants.NoStringValue ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_propertyInspectorName ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_arraySupport ); - } - public override void RefreshOnUndo() - { - base.RefreshOnUndo(); - if( m_topTexture != null ) - { - m_topTexture.BeginPropertyFromInspectorCheck(); - } - - if( m_midTexture != null ) - { - m_midTexture.BeginPropertyFromInspectorCheck(); - } - - if( m_botTexture != null ) - { - m_botTexture.BeginPropertyFromInspectorCheck(); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs.meta deleted file mode 100644 index 39ce8dae..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 396e5bf33f08d3a42a19d7b161f573f2 -timeCreated: 1490358806 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs deleted file mode 100644 index 277effc3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Object To Clip Pos", "Object Transform", "Transforms a point from object space to the camera’s clip space in homogeneous coordinates" )] - public sealed class UnityObjToClipPosHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "UnityObjectToClipPos"; - //TODO: revisit this later - m_funcLWFormatOverride = "TransformWorldToHClip(TransformObjectToWorld({0}))"; - m_funcHDFormatOverride = "TransformWorldToHClip(TransformObjectToWorld({0}))"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "XYZW"; - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - AddOutputPort( WirePortDataType.FLOAT, "W" ); - m_previewShaderGUID = "14ec765a147a53340877b489e73f1c9f"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "unityObjectToClipPos" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs.meta deleted file mode 100644 index 0f62b63f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c01e190d996825f42bdc81e1fab5e897 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs deleted file mode 100644 index 89258e80..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Object To View Pos", "Object Transform", "Transforms a point from object space to view space" )] - public sealed class UnityObjToViewPosHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "UnityObjectToViewPos"; - //TODO: revisit this later - m_funcLWFormatOverride = "TransformWorldToView( TransformObjectToWorld( {0}) )"; - m_funcHDFormatOverride = "TransformWorldToView( TransformObjectToWorld( {0}) )"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - m_previewShaderGUID = "b790bc1d468a51840a9facef372b4729"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "unityObjectToViewPos" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs.meta deleted file mode 100644 index c0ea4e5a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5f35cf284cf7d2b47be5a32426fc7a77 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs deleted file mode 100644 index 28480030..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Space Light Dir", "Light", "Computes normalized world space light direction" )] - public sealed class WorldSpaceLightDirHlpNode : HelperParentNode - { - private const string NormalizeOptionStr = "Safe Normalize"; - - [SerializeField] - private bool m_safeNormalize = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "UnityWorldSpaceLightDir"; - m_inputPorts[ 0 ].Visible = false; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - - m_useInternalPortData = false; - m_drawPreviewAsSphere = true; - m_autoWrapProperties = true; - m_textLabelWidth = 120; - m_previewShaderGUID = "2e8dc46eb6fb2124d9f0007caf9567e3"; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( m_safeNormalize ) - dataCollector.SafeNormalizeLightDir = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_safeNormalize = EditorGUILayoutToggle( NormalizeOptionStr, m_safeNormalize ); - EditorGUILayout.HelpBox( "Having safe normalize ON makes sure your light vector is not zero even if there's no lights in your scene.", MessageType.None ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - return GetOutputVectorItem( 0, outputId, dataCollector.TemplateDataCollectorInstance.GetWorldSpaceLightDir( CurrentPrecisionType ) ); ; - - dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - - return GetOutputVectorItem( 0, outputId, GeneratorUtils.GenerateWorldLightDirection( ref dataCollector, UniqueId, CurrentPrecisionType ) ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 15201 ) - { - m_safeNormalize = 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_safeNormalize ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs.meta deleted file mode 100644 index 87a3bc36..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2134a58fb8235524d84046a051bce6b5 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs deleted file mode 100644 index 27b3dcbd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Space View Dir", "Object Transform", "World space direction (not normalized) from given object space vertex position towards the camera" )] - public sealed class WorldSpaceViewDirHlpNode : HelperParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_funcType = "WorldSpaceViewDir"; - //TODO: revisit this later - m_funcLWFormatOverride = "( _WorldSpaceCameraPos.xyz - mul(GetObjectToWorldMatrix(), {0} ).xyz )"; - m_funcHDFormatOverride = "( _WorldSpaceCameraPos.xyz - mul(GetObjectToWorldMatrix(), {0} ).xyz )"; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 0 ].Vector4InternalData = new UnityEngine.Vector4( 0, 0, 0, 1 ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - m_previewShaderGUID = "fe0e09756a8a0ba408015b43e66cb8a6"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_localVarName = "worldSpaceViewDir" + OutputId; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs.meta deleted file mode 100644 index 4097cec0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 61d7064bd5523634496fa412627603d7 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs deleted file mode 100644 index aa649046..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - interface ISignalGenerator - { - void GenerateSignalPropagation(); - void GenerateSignalInibitor(); - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs.meta deleted file mode 100644 index 3bfa978a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ISignalGenerator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cfeab503d3318794ea1af322505320ef -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects.meta deleted file mode 100644 index ba29e65e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2a5d24ae30c4ee74f81a2fa0615e2e95 -folderAsset: yes -timeCreated: 1481126945 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs deleted file mode 100644 index d7ac724f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs +++ /dev/null @@ -1,443 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -//https://www.shadertoy.com/view/XdS3RW -//http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html -//http://www.pegtop.net/delphi/articles/blendmodes/softlight.htm - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum BlendOps - { - ColorBurn, - ColorDodge, - Darken, - Divide, - Difference, - Exclusion, - SoftLight, - HardLight, - HardMix, - Lighten, - LinearBurn, - LinearDodge, - LinearLight, - Multiply, - Overlay, - PinLight, - Subtract, - Screen, - VividLight - } - [Serializable] - [NodeAttributes( "Blend Operations", "Image Effects", "Common layer blending modes" )] - public class BlendOpsNode : ParentNode - { - //private const string ASEHardLightCall = "ASEHardLight({0},{1})"; - //private const string ASEHardLightFunc = - //"inline float ASEHardLight( float srcLocalVar, float dstLocalVar ){" + - //" return ( ( srcLocalVar > 0.5 ) ? ( 1.0 - ( 1.0 - 2.0 * ( srcLocalVar - 0.5 ) ) * ( 1.0 - dstLocalVar ) ) : ( 2.0 * srcLocalVar * dstLocalVar ) ); }"; - - //private const string ASELinearLightCall = "ASELinearLight({0},{1})"; - //private const string ASELinearLightFunc = - //"inline float ASELinearLight( float srcLocalVar, float dstLocalVar ){" + - //" return ( ( srcLocalVar > 0.5 ) ? ( dstLocalVar + 2.0 * srcLocalVar - 1.0 ) : ( dstLocalVar + 2.0 * ( srcLocalVar - 0.5 ) ) ); }"; - - //private const string ASEOverlayCall = "ASEOverlay({0},{1})"; - //private const string ASEOverlayFunc = - //"inline float ASEOverlay( float srcLocalVar, float dstLocalVar ){" + - //" return ( ( dstLocalVar > 0.5 ) ? ( 1.0 - ( 1.0 - 2.0 * ( dstLocalVar - 0.5 ) ) * ( 1.0 - srcLocalVar ) ) : ( 2.0 * dstLocalVar * srcLocalVar ) ); }"; - ////" return (dstLocalVar < 0.5) ? 2.0 * srcLocalVar * dstLocalVar : 1.0 - 2.0 * (1.0 - srcLocalVar) * (1.0 - dstLocalVar); }"; - - //private const string ASEPinLightCall = "ASEPinLight({0},{1})"; - //private const string ASEPinLightFunc = - //"inline float ASEPinLight( float srcLocalVar, float dstLocalVar ){" + - //" return ( ( srcLocalVar > 0.5 ) ? max( dstLocalVar , 2.0 * ( srcLocalVar - 0.5 ) ) : min( dstLocalVar , 2.0 * srcLocalVar ) ); }"; - - //private const string ASEVividLightCall = "ASEVividLight({0},{1})"; - //private const string ASEVividLightFunc = "inline float ASEVividLight( float srcLocalVar, float dstLocalVar ){" + - //" return ( ( srcLocalVar > 0.5 ) ? ( dstLocalVar / ( ( 1.0 - srcLocalVar ) * 2.0 ) ) : ( 1.0 - ( ( ( 1.0 - dstLocalVar ) * 0.5 ) / srcLocalVar ) ) ); }"; - - private const string ASEDarkerColorCall = "ASEDarkerColor{}({0},{1})"; - private const string ASEDarkerColorFunc = "inline float ASEDarkerColor{0}( float srcLocalVar, float dstLocalVar ){" + - " return ({1} < {2}) ? s : d; }"; - - private const string ASELighterColorCall = "ASELighterColor{}({0},{1})"; - private const string ASELighterColorFunc = "inline float ASELighterColor{0}( float srcLocalVar, float dstLocalVar ){" + - " return ({1} > {2}) ? s : d; }"; - - private const string BlendOpsModeStr = "Blend Op"; - private const string SaturateResultStr = "Saturate"; - - [SerializeField] - private BlendOps m_currentBlendOp = BlendOps.ColorBurn; - - [SerializeField] - private WirePortDataType m_mainDataType = WirePortDataType.COLOR; - - [SerializeField] - private bool m_saturate = true; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.COLOR, false, "Source" ); - AddInputPort( WirePortDataType.COLOR, false, "Destiny" ); - AddInputPort( WirePortDataType.FLOAT, false,"Alpha" ); - m_inputPorts[ 2 ].FloatInternalData = 1; - AddOutputPort( WirePortDataType.COLOR, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].AddPortForbiddenTypes( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.SAMPLER1D, - WirePortDataType.SAMPLER2D, - WirePortDataType.SAMPLER3D, - WirePortDataType.SAMPLERCUBE ); - m_inputPorts[ 1 ].AddPortForbiddenTypes( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.SAMPLER1D, - WirePortDataType.SAMPLER2D, - WirePortDataType.SAMPLER3D, - WirePortDataType.SAMPLERCUBE ); - m_textLabelWidth = 75; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_currentBlendOp ) ); - m_useInternalPortData = true; - m_previewShaderGUID = "6d6b3518705b3ba49acdc6e18e480257"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - m_previewMaterialPassId = (int)m_currentBlendOp; - PreviewMaterial.SetInt( "_Sat", m_saturate ? 1 : 0 ); - int lerpMode = ( m_inputPorts[ 2 ].IsConnected || m_inputPorts[ 2 ].FloatInternalData < 1 ) ? 1 : 0; - PreviewMaterial.SetInt( "_Lerp", lerpMode ); - } - - 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 ); - 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 ); - UpdateDisconnection( portId ); - } - - void UpdateConnection( int portId ) - { - if( portId == 2 ) - return; - - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = ( portId + 1 ) % 2; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainDataType = UIUtils.GetPriority( m_inputPorts[ 0 ].DataType ) > UIUtils.GetPriority( m_inputPorts[ 1 ].DataType ) ? m_inputPorts[ 0 ].DataType : m_inputPorts[ 1 ].DataType; - } - else - { - m_mainDataType = m_inputPorts[ portId ].DataType; - m_inputPorts[ otherPortId ].ChangeType( m_mainDataType, false ); - } - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - void UpdateDisconnection( int portId ) - { - if( portId == 2 ) - return; - - int otherPortId = ( portId + 1 ) % 2; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainDataType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainDataType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_currentBlendOp = (BlendOps)EditorGUILayoutEnumPopup( BlendOpsModeStr, m_currentBlendOp ); - if( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_currentBlendOp ) ); - } - m_saturate = EditorGUILayoutToggle( SaturateResultStr, m_saturate ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - m_upperLeftWidget.DrawWidget<BlendOps>( ref m_currentBlendOp, this, OnWidgetUpdate ); - } - - private readonly Action<ParentNode> OnWidgetUpdate = ( x ) => - { - x.SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, ( x as BlendOpsNode ).m_currentBlendOp ) ); - }; - - private string CreateMultiChannel( ref MasterNodeDataCollector dataCollector, string function, string srcLocalVar, string dstLocalVar, string varName ) - { - switch( m_outputPorts[ 0 ].DataType ) - { - default: - { - return string.Format( function, srcLocalVar, dstLocalVar ); - } - case WirePortDataType.FLOAT2: - { - string xChannelName = varName + OutputId + "X"; - string xChannelValue = string.Format( function, srcLocalVar + ".x", dstLocalVar + ".x" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, xChannelName, xChannelValue ); - - string yChannelName = varName + OutputId + "Y"; - string yChannelValue = string.Format( function, srcLocalVar + ".y", dstLocalVar + ".y" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, yChannelName, yChannelValue ); - - return string.Format( "float2({0},{1})", xChannelName, yChannelName ); - } - case WirePortDataType.FLOAT3: - { - string xChannelName = varName + OutputId + "X"; - string xChannelValue = string.Format( function, srcLocalVar + ".x", dstLocalVar + ".x" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, xChannelName, xChannelValue ); - - string yChannelName = varName + OutputId + "Y"; - string yChannelValue = string.Format( function, srcLocalVar + ".y", dstLocalVar + ".y" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, yChannelName, yChannelValue ); - - string zChannelName = varName + OutputId + "Z"; - string zChannelValue = string.Format( function, srcLocalVar + ".z", dstLocalVar + ".z" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, zChannelName, zChannelValue ); - - return string.Format( "float3({0},{1},{2})", xChannelName, yChannelName, zChannelName ); - } - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - string xChannelName = varName + OutputId + "X"; - string xChannelValue = string.Format( function, srcLocalVar + ".x", dstLocalVar + ".x" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, xChannelName, xChannelValue ); - - string yChannelName = varName + OutputId + "Y"; - string yChannelValue = string.Format( function, srcLocalVar + ".y", dstLocalVar + ".y" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, yChannelName, yChannelValue ); - - string zChannelName = varName + OutputId + "Z"; - string zChannelValue = string.Format( function, srcLocalVar + ".z", dstLocalVar + ".z" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, zChannelName, zChannelValue ); - - string wChannelName = varName + OutputId + "W"; - string wChannelValue = string.Format( function, srcLocalVar + ".w", dstLocalVar + ".w" ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, wChannelName, wChannelValue ); - - return string.Format( "float4({0},{1},{2},{3})", xChannelName, yChannelName, zChannelName, wChannelName ); - } - } - } - - 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 src = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, false, true ); - string dst = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, false, true ); - - string srcLocalVar = "blendOpSrc" + OutputId; - string dstLocalVar = "blendOpDest" + OutputId; - dataCollector.AddLocalVariable( UniqueId, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_mainDataType ) + " " + srcLocalVar, src + ";" ); - dataCollector.AddLocalVariable( UniqueId, UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_mainDataType ) + " " + dstLocalVar, dst + ";" ); - - int currIndent = UIUtils.ShaderIndentLevel; - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - UIUtils.ShaderIndentLevel = 0; - } - else - { - UIUtils.ShaderIndentLevel = 1; - UIUtils.ShaderIndentLevel++; - } - - string result = string.Empty; - switch( m_currentBlendOp ) - { - case BlendOps.ColorBurn: - { - result = string.Format( "( 1.0 - ( ( 1.0 - {0}) / max( {1}, 0.00001) ) )", dstLocalVar, srcLocalVar); - } - break; - case BlendOps.ColorDodge: - { - result = string.Format( "( {0}/ max( 1.0 - {1}, 0.00001 ) )", dstLocalVar, srcLocalVar ); - } - break; - case BlendOps.Darken: - { - result = "min( " + srcLocalVar + " , " + dstLocalVar + " )"; - } - break; - case BlendOps.Divide: - { - result = string.Format( "( {0} / max({1},0.00001) )", dstLocalVar, srcLocalVar ); - } - break; - case BlendOps.Difference: - { - result = "abs( " + srcLocalVar + " - " + dstLocalVar + " )"; - } - break; - case BlendOps.Exclusion: - { - result = "( 0.5 - 2.0 * ( " + srcLocalVar + " - 0.5 ) * ( " + dstLocalVar + " - 0.5 ) )"; - } - break; - case BlendOps.SoftLight: - { - result = string.Format( "2.0f*{0}*{1} + {0}*{0}*(1.0f - 2.0f*{1})", dstLocalVar, srcLocalVar ); - } - break; - case BlendOps.HardLight: - { - result = " (( " + srcLocalVar + " > 0.5 ) ? ( 1.0 - ( 1.0 - 2.0 * ( " + srcLocalVar + " - 0.5 ) ) * ( 1.0 - " + dstLocalVar + " ) ) : ( 2.0 * " + srcLocalVar + " * " + dstLocalVar + " ) )"; - //dataCollector.AddFunction( ASEHardLightCall, UIUtils.ShaderIndentTabs + ASEHardLightFunc ); - //result = CreateMultiChannel( ref dataCollector, ASEHardLightCall, srcLocalVar, dstLocalVar, "hardLightBlend" ); - } - break; - case BlendOps.HardMix: - { - result = " round( 0.5 * ( " + srcLocalVar + " + " + dstLocalVar + " ) )"; - } - break; - case BlendOps.Lighten: - { - result = " max( " + srcLocalVar + ", " + dstLocalVar + " )"; - } - break; - case BlendOps.LinearBurn: - { - result = "( " + srcLocalVar + " + " + dstLocalVar + " - 1.0 )"; - } - break; - case BlendOps.LinearDodge: - { - result = "( " + srcLocalVar + " + " + dstLocalVar + " )"; - } - break; - case BlendOps.LinearLight: - { - result = "(( " + srcLocalVar + " > 0.5 )? ( " + dstLocalVar + " + 2.0 * " + srcLocalVar + " - 1.0 ) : ( " + dstLocalVar + " + 2.0 * ( " + srcLocalVar + " - 0.5 ) ) )"; - //dataCollector.AddFunction( ASELinearLightCall, UIUtils.ShaderIndentTabs + ASELinearLightFunc ); - //result = CreateMultiChannel( ref dataCollector, ASELinearLightCall, srcLocalVar, dstLocalVar, "linearLightBlend" ); - } - break; - case BlendOps.Multiply: - { - result = "( " + srcLocalVar + " * " + dstLocalVar + " )"; - } - break; - case BlendOps.Overlay: - { - //result = "(( " + dstLocalVar + " > 0.5 ) ? ( 1.0 - ( 1.0 - 2.0 * ( " + dstLocalVar + " - 0.5 ) ) * ( 1.0 - " + srcLocalVar + " ) ) : ( 2.0 * " + dstLocalVar + " * " + srcLocalVar + " ) )"; - result = "(( " + dstLocalVar + " > 0.5 ) ? ( 1.0 - 2.0 * ( 1.0 - " + dstLocalVar + " ) * ( 1.0 - " + srcLocalVar + " ) ) : ( 2.0 * " + dstLocalVar + " * " + srcLocalVar + " ) )"; - //dataCollector.AddFunction( ASEOverlayCall, UIUtils.ShaderIndentTabs + ASEOverlayFunc ); - //result = CreateMultiChannel( ref dataCollector, ASEOverlayCall, srcLocalVar, dstLocalVar, "overlayBlend" ); - } - break; - case BlendOps.PinLight: - { - result = "(( " + srcLocalVar + " > 0.5 ) ? max( " + dstLocalVar + ", 2.0 * ( " + srcLocalVar + " - 0.5 ) ) : min( " + dstLocalVar + ", 2.0 * " + srcLocalVar + " ) )"; - //dataCollector.AddFunction( ASEPinLightCall, UIUtils.ShaderIndentTabs + ASEPinLightFunc ); - //result = CreateMultiChannel( ref dataCollector, ASEPinLightCall, srcLocalVar, dstLocalVar, "pinLightBlend" ); - } - break; - case BlendOps.Subtract: - { - result = "( " + dstLocalVar + " - " + srcLocalVar + " )"; - } - break; - case BlendOps.Screen: - { - result = "( 1.0 - ( 1.0 - " + srcLocalVar + " ) * ( 1.0 - " + dstLocalVar + " ) )"; - } - break; - case BlendOps.VividLight: - { - result = string.Format( "(( {0} > 0.5 ) ? ( {1} / max( ( 1.0 - {0} ) * 2.0 ,0.00001) ) : ( 1.0 - ( ( ( 1.0 - {1} ) * 0.5 ) / max( {0},0.00001) ) ) )", srcLocalVar, dstLocalVar); - //dataCollector.AddFunction( ASEVividLightCall, UIUtils.ShaderIndentTabs + ASEVividLightFunc ); - //result = CreateMultiChannel( ref dataCollector, ASEVividLightCall, srcLocalVar, dstLocalVar, "vividLightBlend" ); - } - break; - } - - UIUtils.ShaderIndentLevel = currIndent; - if( m_inputPorts[ 2 ].IsConnected || m_inputPorts[ 2 ].FloatInternalData < 1.0 ) - { - string opacity = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string lerpVar = "lerpBlendMode" + OutputId; - string lerpResult = string.Format( "lerp({0},{1},{2})", dstLocalVar, result, opacity ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, lerpVar, lerpResult ); - result = lerpVar; - } - - if( m_saturate ) - result = "( saturate( " + result + " ))"; - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentBlendOp ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_saturate ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_currentBlendOp = (BlendOps)Enum.Parse( typeof( BlendOps ), GetCurrentParam( ref nodeParams ) ); - m_saturate = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_currentBlendOp ) ); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs.meta deleted file mode 100644 index 3a53cbc6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/BlendOpsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 09fb0867c2a616c488bad8929f4f7ad7 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs deleted file mode 100644 index 507c678d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -// http://stackoverflow.com/questions/9320953/what-algorithm-does-photoshop-use-to-desaturate-an-image -// https://www.shadertoy.com/view/lsdXDH - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Desaturate", "Image Effects", "Generic desaturation operation" )] - public sealed class DesaturateOpNode : ParentNode - { - private const string GenericDesaturateOp0 = "dot( {0}, float3( 0.299, 0.587, 0.114 ))"; - private const string GenericDesaturateOp1 = "lerp( {0}, {1}.xxx, {2} )"; - //private const string GenericDesaturateOp = "lerp( {0},dot({0},float3(0.299,0.587,0.114)).xxx,{1})"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "RGB" ); - AddInputPort( WirePortDataType.FLOAT, false, "Fraction" ); - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_previewShaderGUID = "faabe9efdf44b9648a523f1742abdfd3"; - } - - void UpdatePorts( int portId ) - { - if ( portId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, 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 initalColorValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string fraction = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string initialColorVarName = "desaturateInitialColor" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, initialColorVarName, initalColorValue ); - - string dotVarName = "desaturateDot" + OutputId; - string dotVarValue = string.Format( GenericDesaturateOp0, initialColorVarName ); - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, dotVarName, dotVarValue ); - RegisterLocalVariable( 0, string.Format( GenericDesaturateOp1, initialColorVarName, dotVarName,fraction ), ref dataCollector, "desaturateVar" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs.meta deleted file mode 100644 index c931cbd2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/DesaturateOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: eddae0a124877fc47b28ae8853286174 -timeCreated: 1489414268 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs deleted file mode 100644 index a30c69aa..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "HSV to RGB", "Image Effects", "Converts from HSV to RGB color space" )] - public sealed class HSVToRGBNode : ParentNode - { - public static readonly string HSVToRGBHeader = "HSVToRGB( {0}3({1},{2},{3}) )"; - public static readonly string[] HSVToRGBFunction = { "{0}3 HSVToRGB( {0}3 c )\n", - "{\n", - "\t{0}4 K = {0}4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );\n", - "\t{0}3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www );\n", - "\treturn c.z * lerp( K.xxx, saturate( p - K.xxx ), c.y );\n", - "}\n"}; - public static readonly bool[] HSVToRGBFlags = { true, - false, - true, - true, - false, - false}; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Hue" ); - AddInputPort( WirePortDataType.FLOAT, false, "Saturation" ); - AddInputPort( WirePortDataType.FLOAT, false, "Value" ); - AddOutputColorPorts( "RGB", false ); - m_previewShaderGUID = "fab445eb945d63047822a7a6b81b959d"; - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_customPrecision = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - DrawPrecisionProperty(); - } - - public static void AddHSVToRGBFunction( ref MasterNodeDataCollector dataCollector , string precisionString ) - { - if( !dataCollector.HasFunction( HSVToRGBHeader ) ) - { - //Hack to be used util indent is properly used - int currIndent = UIUtils.ShaderIndentLevel; - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - UIUtils.ShaderIndentLevel = 0; - } - else - { - UIUtils.ShaderIndentLevel = 1; - UIUtils.ShaderIndentLevel++; - } - - string finalFunction = string.Empty; - for( int i = 0; i < HSVToRGBFunction.Length; i++ ) - { - finalFunction += UIUtils.ShaderIndentTabs + ( HSVToRGBFlags[ i ] ? string.Format( HSVToRGBFunction[ i ], precisionString ) : HSVToRGBFunction[ i ] ); - } - - UIUtils.ShaderIndentLevel = currIndent; - - dataCollector.AddFunction( HSVToRGBHeader, finalFunction ); - } - } - - 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 ) ); - - string precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT ); - - AddHSVToRGBFunction( ref dataCollector , precisionString ); - - string hue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string saturation = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string value = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - RegisterLocalVariable( 0, string.Format( HSVToRGBHeader, precisionString, hue, saturation, value ), ref dataCollector, "hsvTorgb" + OutputId ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs.meta deleted file mode 100644 index 5d33d3ad..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/HSVToRGBNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3d992a68cff329a4a9bd1deb999fe691 -timeCreated: 1494857111 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs deleted file mode 100644 index 2582a59b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Luminance", "Image Effects", "Calculates Luminance value from input")] - public sealed class LuminanceNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "RGB" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_previewShaderGUID = "81e1d8ffeec8a4b4cabb1094bc981048"; - } - - 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 ); - string grayscale = "Luminance(" + value + ")"; - - RegisterLocalVariable( 0, grayscale, ref dataCollector, "luminance" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs.meta deleted file mode 100644 index 20c21f37..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/LuminanceNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c5f40d01acf184946b8660599f33109f -timeCreated: 1574935849 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs deleted file mode 100644 index c6805a41..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs +++ /dev/null @@ -1,466 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// Based on the work by https://github.com/keijiro/NoiseShader - -using System; -using UnityEditor; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - public enum NoiseGeneratorType - { - Simplex2D, - Simplex3D, - Gradient, - Simple - }; - - [Serializable] - [NodeAttributes( "Noise Generator", "Miscellaneous", "Collection of procedural noise generators", tags: "simplex gradient" )] - public sealed class NoiseGeneratorNode : ParentNode - { - private const string TypeLabelStr = "Type"; - private const string SetTo01RangeOpStr = "{0} = {0}*0.5 + 0.5;"; - private const string SetToMinus1To1RangeOpStr = "{0} = {0}*2 - 1;"; - private const string SetTo01RangeLabel = "0-1 Range"; - private const string SetTo01RangePreviewId = "_To01Range"; - private const string UseUnityVersionLabel = "Use Unity Version"; - - // Simple - private const string SimpleNoiseRandomValueFunc = "inline float noise_randomValue (float2 uv) { return frac(sin(dot(uv, float2(12.9898, 78.233)))*43758.5453); }"; - private const string SimpleNoiseInterpolateFunc = "inline float noise_interpolate (float a, float b, float t) { return (1.0-t)*a + (t*b); }"; - private const string SimpleValueNoiseHeader = "inline float valueNoise (float2 uv)"; - private readonly string[] SimpleValueNoiseBody = { "inline float valueNoise (float2 uv)\n", - "{\n", - "\tfloat2 i = floor(uv);\n", - "\tfloat2 f = frac( uv );\n", - "\tf = f* f * (3.0 - 2.0 * f);\n", - "\tuv = abs( frac(uv) - 0.5);\n", - "\tfloat2 c0 = i + float2( 0.0, 0.0 );\n", - "\tfloat2 c1 = i + float2( 1.0, 0.0 );\n", - "\tfloat2 c2 = i + float2( 0.0, 1.0 );\n", - "\tfloat2 c3 = i + float2( 1.0, 1.0 );\n", - "\tfloat r0 = noise_randomValue( c0 );\n", - "\tfloat r1 = noise_randomValue( c1 );\n", - "\tfloat r2 = noise_randomValue( c2 );\n", - "\tfloat r3 = noise_randomValue( c3 );\n", - "\tfloat bottomOfGrid = noise_interpolate( r0, r1, f.x );\n", - "\tfloat topOfGrid = noise_interpolate( r2, r3, f.x );\n", - "\tfloat t = noise_interpolate( bottomOfGrid, topOfGrid, f.y );\n", - "\treturn t;\n", - "}\n"}; - - private const string SimpleNoiseHeader = "float SimpleNoise(float2 UV, float Scale)"; - private const string SimpleNoiseFunc = "SimpleNoise( {0} )"; - private readonly string[] SimpleNoiseBody = { "float SimpleNoise(float2 UV)\n", - "{\n", - "\tfloat t = 0.0;\n", - "\tfloat freq = pow( 2.0, float( 0 ) );\n", - "\tfloat amp = pow( 0.5, float( 3 - 0 ) );\n", - "\tt += valueNoise( UV/freq )*amp;\n", - "\tfreq = pow(2.0, float(1));\n", - "\tamp = pow(0.5, float(3-1));\n", - "\tt += valueNoise( UV/freq )*amp;\n", - "\tfreq = pow(2.0, float(2));\n", - "\tamp = pow(0.5, float(3-2));\n", - "\tt += valueNoise( UV/freq )*amp;\n", - "\treturn t;\n", - "}\n"}; - - // Simplex 2D - private const string Simplex2DFloat3Mod289Func = "float3 mod2D289( float3 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }"; - private const string Simplex2DFloat2Mod289Func = "float2 mod2D289( float2 x ) { return x - floor( x * ( 1.0 / 289.0 ) ) * 289.0; }"; - private const string Simplex2DPermuteFunc = "float3 permute( float3 x ) { return mod2D289( ( ( x * 34.0 ) + 1.0 ) * x ); }"; - - private const string SimplexNoise2DHeader = "float snoise( float2 v )"; - private const string SimplexNoise2DFunc = "snoise( {0} )"; - private readonly string[] SimplexNoise2DBody = {"float snoise( float2 v )\n", - "{\n", - "\tconst float4 C = float4( 0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439 );\n", - "\tfloat2 i = floor( v + dot( v, C.yy ) );\n", - "\tfloat2 x0 = v - i + dot( i, C.xx );\n", - "\tfloat2 i1;\n", - "\ti1 = ( x0.x > x0.y ) ? float2( 1.0, 0.0 ) : float2( 0.0, 1.0 );\n", - "\tfloat4 x12 = x0.xyxy + C.xxzz;\n", - "\tx12.xy -= i1;\n", - "\ti = mod2D289( i );\n", - "\tfloat3 p = permute( permute( i.y + float3( 0.0, i1.y, 1.0 ) ) + i.x + float3( 0.0, i1.x, 1.0 ) );\n", - "\tfloat3 m = max( 0.5 - float3( dot( x0, x0 ), dot( x12.xy, x12.xy ), dot( x12.zw, x12.zw ) ), 0.0 );\n", - "\tm = m * m;\n", - "\tm = m * m;\n", - "\tfloat3 x = 2.0 * frac( p * C.www ) - 1.0;\n", - "\tfloat3 h = abs( x ) - 0.5;\n", - "\tfloat3 ox = floor( x + 0.5 );\n", - "\tfloat3 a0 = x - ox;\n", - "\tm *= 1.79284291400159 - 0.85373472095314 * ( a0 * a0 + h * h );\n", - "\tfloat3 g;\n", - "\tg.x = a0.x * x0.x + h.x * x0.y;\n", - "\tg.yz = a0.yz * x12.xz + h.yz * x12.yw;\n", - "\treturn 130.0 * dot( m, g );\n", - "}\n"}; - // Simplex 3D - - - - private const string Simplex3DFloat3Mod289 = "float3 mod3D289( float3 x ) { return x - floor( x / 289.0 ) * 289.0; }"; - private const string Simplex3DFloat4Mod289 = "float4 mod3D289( float4 x ) { return x - floor( x / 289.0 ) * 289.0; }"; - private const string Simplex3DFloat4Permute = "float4 permute( float4 x ) { return mod3D289( ( x * 34.0 + 1.0 ) * x ); }"; - private const string TaylorInvSqrtFunc = "float4 taylorInvSqrt( float4 r ) { return 1.79284291400159 - r * 0.85373472095314; }"; - - private const string SimplexNoise3DHeader = "float snoise( float3 v )"; - private const string SimplexNoise3DFunc = "snoise( {0} )"; - private readonly string[] SimplexNoise3DBody = - { - "float snoise( float3 v )\n", - "{\n", - "\tconst float2 C = float2( 1.0 / 6.0, 1.0 / 3.0 );\n", - "\tfloat3 i = floor( v + dot( v, C.yyy ) );\n", - "\tfloat3 x0 = v - i + dot( i, C.xxx );\n", - "\tfloat3 g = step( x0.yzx, x0.xyz );\n", - "\tfloat3 l = 1.0 - g;\n", - "\tfloat3 i1 = min( g.xyz, l.zxy );\n", - "\tfloat3 i2 = max( g.xyz, l.zxy );\n", - "\tfloat3 x1 = x0 - i1 + C.xxx;\n", - "\tfloat3 x2 = x0 - i2 + C.yyy;\n", - "\tfloat3 x3 = x0 - 0.5;\n", - "\ti = mod3D289( i);\n", - "\tfloat4 p = permute( permute( permute( i.z + float4( 0.0, i1.z, i2.z, 1.0 ) ) + i.y + float4( 0.0, i1.y, i2.y, 1.0 ) ) + i.x + float4( 0.0, i1.x, i2.x, 1.0 ) );\n", - "\tfloat4 j = p - 49.0 * floor( p / 49.0 ); // mod(p,7*7)\n", - "\tfloat4 x_ = floor( j / 7.0 );\n", - "\tfloat4 y_ = floor( j - 7.0 * x_ ); // mod(j,N)\n", - "\tfloat4 x = ( x_ * 2.0 + 0.5 ) / 7.0 - 1.0;\n", - "\tfloat4 y = ( y_ * 2.0 + 0.5 ) / 7.0 - 1.0;\n", - "\tfloat4 h = 1.0 - abs( x ) - abs( y );\n", - "\tfloat4 b0 = float4( x.xy, y.xy );\n", - "\tfloat4 b1 = float4( x.zw, y.zw );\n", - "\tfloat4 s0 = floor( b0 ) * 2.0 + 1.0;\n", - "\tfloat4 s1 = floor( b1 ) * 2.0 + 1.0;\n", - "\tfloat4 sh = -step( h, 0.0 );\n", - "\tfloat4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n", - "\tfloat4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n", - "\tfloat3 g0 = float3( a0.xy, h.x );\n", - "\tfloat3 g1 = float3( a0.zw, h.y );\n", - "\tfloat3 g2 = float3( a1.xy, h.z );\n", - "\tfloat3 g3 = float3( a1.zw, h.w );\n", - "\tfloat4 norm = taylorInvSqrt( float4( dot( g0, g0 ), dot( g1, g1 ), dot( g2, g2 ), dot( g3, g3 ) ) );\n", - "\tg0 *= norm.x;\n", - "\tg1 *= norm.y;\n", - "\tg2 *= norm.z;\n", - "\tg3 *= norm.w;\n", - "\tfloat4 m = max( 0.6 - float4( dot( x0, x0 ), dot( x1, x1 ), dot( x2, x2 ), dot( x3, x3 ) ), 0.0 );\n", - "\tm = m* m;\n", - "\tm = m* m;\n", - "\tfloat4 px = float4( dot( x0, g0 ), dot( x1, g1 ), dot( x2, g2 ), dot( x3, g3 ) );\n", - "\treturn 42.0 * dot( m, px);\n", - "}\n" - }; - - //Gradient Noise - private readonly string UnityGradientNoiseFunc = "UnityGradientNoise({0},{1})"; - private readonly string[] UnityGradientNoiseFunctionsBody = - { - "float2 UnityGradientNoiseDir( float2 p )\n", - "{\n", - "\tp = fmod(p , 289);\n", - "\tfloat x = fmod((34 * p.x + 1) * p.x , 289) + p.y;\n", - "\tx = fmod( (34 * x + 1) * x , 289);\n", - "\tx = frac( x / 41 ) * 2 - 1;\n", - "\treturn normalize( float2(x - floor(x + 0.5 ), abs( x ) - 0.5 ) );\n", - "}\n", - "\n", - "float UnityGradientNoise( float2 UV, float Scale )\n", - "{\n", - "\tfloat2 p = UV * Scale;\n", - "\tfloat2 ip = floor( p );\n", - "\tfloat2 fp = frac( p );\n", - "\tfloat d00 = dot( UnityGradientNoiseDir( ip ), fp );\n", - "\tfloat d01 = dot( UnityGradientNoiseDir( ip + float2( 0, 1 ) ), fp - float2( 0, 1 ) );\n", - "\tfloat d10 = dot( UnityGradientNoiseDir( ip + float2( 1, 0 ) ), fp - float2( 1, 0 ) );\n", - "\tfloat d11 = dot( UnityGradientNoiseDir( ip + float2( 1, 1 ) ), fp - float2( 1, 1 ) );\n", - "\tfp = fp * fp * fp * ( fp * ( fp * 6 - 15 ) + 10 );\n", - "\treturn lerp( lerp( d00, d01, fp.y ), lerp( d10, d11, fp.y ), fp.x ) + 0.5;\n", - "}\n" - }; - private readonly string GradientNoiseFunc = "GradientNoise({0},{1})"; - private readonly string[] GradientNoiseFunctionsBody = - { - "//https://www.shadertoy.com/view/XdXGW8\n", - "float2 GradientNoiseDir( float2 x )\n", - "{\n", - "\tconst float2 k = float2( 0.3183099, 0.3678794 );\n", - "\tx = x * k + k.yx;\n", - "\treturn -1.0 + 2.0 * frac( 16.0 * k * frac( x.x * x.y * ( x.x + x.y ) ) );\n", - "}\n", - "\n", - "float GradientNoise( float2 UV, float Scale )\n", - "{\n", - "\tfloat2 p = UV * Scale;\n", - "\tfloat2 i = floor( p );\n", - "\tfloat2 f = frac( p );\n", - "\tfloat2 u = f * f * ( 3.0 - 2.0 * f );\n", - "\treturn lerp( lerp( dot( GradientNoiseDir( i + float2( 0.0, 0.0 ) ), f - float2( 0.0, 0.0 ) ),\n", - "\t\t\tdot( GradientNoiseDir( i + float2( 1.0, 0.0 ) ), f - float2( 1.0, 0.0 ) ), u.x ),\n", - "\t\t\tlerp( dot( GradientNoiseDir( i + float2( 0.0, 1.0 ) ), f - float2( 0.0, 1.0 ) ),\n", - "\t\t\tdot( GradientNoiseDir( i + float2( 1.0, 1.0 ) ), f - float2( 1.0, 1.0 ) ), u.x ), u.y );\n", - "}\n" - }; - - [SerializeField] - private NoiseGeneratorType m_type = NoiseGeneratorType.Simplex2D; - - [SerializeField] - private bool m_setTo01Range = true; - - [SerializeField] - private bool m_unityVersion = false; - private int m_setTo01RangePreviewId; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - m_inputPorts[ 1 ].FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_type ) ); - m_previewShaderGUID = "cd2d37ef5da190b42a91a5a690ba2a7d"; - ConfigurePorts(); - } - - public override void OnEnable() - { - base.OnEnable(); - m_setTo01RangePreviewId = Shader.PropertyToID( SetTo01RangePreviewId ); - } - - 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 SetPreviewInputs() - { - base.SetPreviewInputs(); - float range01 = m_setTo01Range ? 1 : 0; - PreviewMaterial.SetFloat( m_setTo01RangePreviewId, range01 ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - m_upperLeftWidget.DrawWidget<NoiseGeneratorType>( ref m_type, this, OnWidgetUpdate ); - } - - private readonly Action<ParentNode> OnWidgetUpdate = ( x ) => - { - ( x as NoiseGeneratorNode ).ConfigurePorts(); - }; - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_type = (NoiseGeneratorType)EditorGUILayoutEnumPopup( TypeLabelStr, m_type ); - if( EditorGUI.EndChangeCheck() ) - { - ConfigurePorts(); - } - - m_setTo01Range = EditorGUILayoutToggle( SetTo01RangeLabel, m_setTo01Range ); - - if( m_type == NoiseGeneratorType.Gradient ) - { - EditorGUI.BeginChangeCheck(); - m_unityVersion = EditorGUILayoutToggle( UseUnityVersionLabel, m_unityVersion ); - if( EditorGUI.EndChangeCheck() ) - { - ConfigurePorts(); - } - } - //EditorGUILayout.HelpBox( "Node still under construction. Use with caution", MessageType.Info ); - } - - private void ConfigurePorts() - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_type ) ); - - switch( m_type ) - { - case NoiseGeneratorType.Simplex2D: - { - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_previewMaterialPassId = 0; - } - break; - - case NoiseGeneratorType.Simplex3D: - { - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_previewMaterialPassId = 1; - } - break; - case NoiseGeneratorType.Gradient: - { - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_previewMaterialPassId = m_unityVersion ? 3 : 2; - } - break; - case NoiseGeneratorType.Simple: - { - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_previewMaterialPassId = 4; - } - break; - } - PreviewIsDirty = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - string size = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string scale = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - switch( m_type ) - { - case NoiseGeneratorType.Simplex2D: - { - - string float3Mod289Func = ( dataCollector.IsTemplate ) ? Simplex2DFloat3Mod289Func : "\t\t" + Simplex2DFloat3Mod289Func; - dataCollector.AddFunction( Simplex2DFloat3Mod289Func, float3Mod289Func ); - - string float2Mod289Func = ( dataCollector.IsTemplate ) ? Simplex2DFloat2Mod289Func : "\t\t" + Simplex2DFloat2Mod289Func; - dataCollector.AddFunction( Simplex2DFloat2Mod289Func, float2Mod289Func ); - - string permuteFunc = ( dataCollector.IsTemplate ) ? Simplex2DPermuteFunc : "\t\t" + Simplex2DPermuteFunc; - dataCollector.AddFunction( Simplex2DPermuteFunc, permuteFunc ); - - dataCollector.AddFunction( SimplexNoise2DHeader, SimplexNoise2DBody, false ); - - - if( m_inputPorts[ 1 ].IsConnected || m_inputPorts[ 1 ].FloatInternalData != 1.0f ) - { - size = string.Format( "{0}*{1}", size, scale ); - } - - RegisterLocalVariable( 0, string.Format( SimplexNoise2DFunc, size ), ref dataCollector, ( "simplePerlin2D" + OutputId ) ); - } - break; - case NoiseGeneratorType.Simplex3D: - { - - string float3Mod289Func = ( dataCollector.IsTemplate ) ? Simplex3DFloat3Mod289 : "\t\t" + Simplex3DFloat3Mod289; - dataCollector.AddFunction( Simplex3DFloat3Mod289, float3Mod289Func ); - - string float4Mod289Func = ( dataCollector.IsTemplate ) ? Simplex3DFloat4Mod289 : "\t\t" + Simplex3DFloat4Mod289; - dataCollector.AddFunction( Simplex3DFloat4Mod289, float4Mod289Func ); - - string permuteFunc = ( dataCollector.IsTemplate ) ? Simplex3DFloat4Permute : "\t\t" + Simplex3DFloat4Permute; - dataCollector.AddFunction( Simplex3DFloat4Permute, permuteFunc ); - - string taylorInvSqrtFunc = ( dataCollector.IsTemplate ) ? TaylorInvSqrtFunc : "\t\t" + TaylorInvSqrtFunc; - dataCollector.AddFunction( TaylorInvSqrtFunc, taylorInvSqrtFunc ); - - dataCollector.AddFunction( SimplexNoise3DHeader, SimplexNoise3DBody, false ); - - if( m_inputPorts[ 1 ].IsConnected || m_inputPorts[ 1 ].FloatInternalData != 1.0f ) - { - size = string.Format( "{0}*{1}", size, scale ); - } - - RegisterLocalVariable( 0, string.Format( SimplexNoise3DFunc, size ), ref dataCollector, ( "simplePerlin3D" + OutputId ) ); - } - break; - - case NoiseGeneratorType.Gradient: - { - string[] body = m_unityVersion ? UnityGradientNoiseFunctionsBody : GradientNoiseFunctionsBody; - string func = m_unityVersion ? UnityGradientNoiseFunc : GradientNoiseFunc; - - dataCollector.AddFunction( body[ 0 ], body, false); - RegisterLocalVariable( 0, string.Format( func, size, scale ), ref dataCollector, ( "gradientNoise" + OutputId ) ); - } - break; - - case NoiseGeneratorType.Simple: - { - string randomValue = ( dataCollector.IsTemplate ) ? SimpleNoiseRandomValueFunc : "\t\t" + SimpleNoiseRandomValueFunc; - dataCollector.AddFunction( SimpleNoiseRandomValueFunc, randomValue ); - - string interpolate = ( dataCollector.IsTemplate ) ? SimpleNoiseInterpolateFunc : "\t\t" + SimpleNoiseInterpolateFunc; - dataCollector.AddFunction( SimpleNoiseInterpolateFunc, interpolate ); - - dataCollector.AddFunction( SimpleValueNoiseHeader, SimpleValueNoiseBody, false ); - - dataCollector.AddFunction( SimpleNoiseHeader, SimpleNoiseBody, false ); - - if( m_inputPorts[ 1 ].IsConnected || m_inputPorts[ 1 ].FloatInternalData != 1.0f ) - { - size = string.Format( "{0}*{1}", size, scale ); - } - RegisterLocalVariable( 0, string.Format( SimpleNoiseFunc, size ), ref dataCollector, ( "simpleNoise" + OutputId ) ); - } - break; - } - - if( m_type == NoiseGeneratorType.Simple && !m_setTo01Range ) - { - dataCollector.AddLocalVariable( outputId, string.Format( SetToMinus1To1RangeOpStr, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ) ); - } - - if( m_setTo01Range && m_type != NoiseGeneratorType.Simple ) - { - dataCollector.AddLocalVariable( outputId, string.Format( SetTo01RangeOpStr, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ) ); - } - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_type = (NoiseGeneratorType)Enum.Parse( typeof( NoiseGeneratorType ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() < 16903 ) - { - m_setTo01Range = false; - } - else - { - m_setTo01Range = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_unityVersion = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - ConfigurePorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_type ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_setTo01Range ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_unityVersion ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs.meta deleted file mode 100644 index cb3c00c4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/NoiseGeneratorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6b82a8d1dffe4204fa03a09e2fe783b3 -timeCreated: 1485355115 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs deleted file mode 100644 index 9518f64e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -//https://www.shadertoy.com/view/ldX3D4 -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Posterize", "Image Effects", "Converts a continuous gradation of tones to multiple regions of fewer tones" )] - public sealed class PosterizeNode : ParentNode - { - private const string PosterizationPowerStr = "Power"; - [SerializeField] - private int m_posterizationPower = 1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.COLOR, false, "RGBA", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.INT, false, "Power", -1, MasterNodePortCategory.Fragment, 0 ); - m_inputPorts[ 1 ].AutoDrawInternalData = true; - AddOutputPort( WirePortDataType.COLOR, Constants.EmptyPortValue ); - m_textLabelWidth = 60; - m_autoWrapProperties = true; - m_previewShaderGUID = "ecb3048ef0eec1645bad1d72a98d8279"; - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( !m_inputPorts[ 1 ].IsConnected ) - { - EditorGUILayout.BeginVertical(); - { - EditorGUI.BeginChangeCheck(); - m_posterizationPower = EditorGUILayoutIntSlider( PosterizationPowerStr, m_posterizationPower, 1, 256 ); - if( EditorGUI.EndChangeCheck() ) - { - GetInputPortByUniqueId( 0 ).IntInternalData = m_posterizationPower; - } - } - EditorGUILayout.EndVertical(); - } - else - { - EditorGUILayout.Space(); - } - } - - 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 posterizationPower = "1"; - if( m_inputPorts[ 1 ].IsConnected ) - { - posterizationPower = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - } - else - { - posterizationPower = m_posterizationPower.ToString(); - } - - string colorTarget = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - string divVar = "div" + OutputId; - dataCollector.AddLocalVariable( UniqueId, "float " + divVar + "=256.0/float(" + posterizationPower + ");" ); - string result = "( floor( " + colorTarget + " * " + divVar + " ) / " + divVar + " )"; - - RegisterLocalVariable( 0, result, ref dataCollector, "posterize" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.COLOR, false ); - m_inputPorts[ 1 ].ChangeType( WirePortDataType.INT, false ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_posterizationPower ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_posterizationPower = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs.meta deleted file mode 100644 index edceea37..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/PosterizeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7dc4667cd643835489312daa244a03b9 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs deleted file mode 100644 index 1fa7c92e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "RGB to HSV", "Image Effects", "Converts from RGB to HSV color space" )] - public sealed class RGBToHSVNode : ParentNode - { - public static readonly string RGBToHSVHeader = "RGBToHSV( {0} )"; - public static readonly string[] RGBToHSVFunction = { "{0}3 RGBToHSV({0}3 c)\n", - "{\n", - "\t{0}4 K = {0}4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n", - "\t{0}4 p = lerp( {0}4( c.bg, K.wz ), {0}4( c.gb, K.xy ), step( c.b, c.g ) );\n", - "\t{0}4 q = lerp( {0}4( p.xyw, c.r ), {0}4( c.r, p.yzx ), step( p.x, c.r ) );\n", - "\t{0} d = q.x - min( q.w, q.y );\n", - "\t{0} e = 1.0e-10;\n", - "\treturn {0}3( abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n", - "}" - }; - - public static readonly bool[] RGBToHSVFlags = { true, - false, - true, - true, - true, - true, - true, - true, - false}; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "RGB" ); - AddOutputPort( WirePortDataType.FLOAT3, "HSV" ); - AddOutputPort( WirePortDataType.FLOAT, "Hue" ); - AddOutputPort( WirePortDataType.FLOAT, "Saturation" ); - AddOutputPort( WirePortDataType.FLOAT, "Value" ); - m_previewShaderGUID = "0f2f09b49bf4954428aafa2dfe1a9a09"; - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_customPrecision = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - DrawPrecisionProperty(); - } - - public void AddRGBToHSVFunction( ref MasterNodeDataCollector dataCollector, string precisionString ) - { - if( !dataCollector.HasFunction( RGBToHSVHeader ) ) - { - //Hack to be used util indent is properly used - int currIndent = UIUtils.ShaderIndentLevel; - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - UIUtils.ShaderIndentLevel = 0; - } - else - { - UIUtils.ShaderIndentLevel = 1; - UIUtils.ShaderIndentLevel++; - } - - string finalFunction = string.Empty; - for( int i = 0; i < RGBToHSVFunction.Length; i++ ) - { - finalFunction += UIUtils.ShaderIndentTabs + ( RGBToHSVFlags[ i ] ? string.Format( RGBToHSVFunction[ i ], precisionString ) : RGBToHSVFunction[ i ] ); - } - UIUtils.ShaderIndentLevel--; - UIUtils.ShaderIndentLevel = currIndent; - - dataCollector.AddFunction( RGBToHSVHeader, finalFunction ); - } - } - - 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 ) ); - - string precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT ); - AddRGBToHSVFunction( ref dataCollector, precisionString ); - - string rgbValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - RegisterLocalVariable( 0, string.Format( RGBToHSVHeader, rgbValue ), ref dataCollector, "hsvTorgb" + OutputId ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs.meta deleted file mode 100644 index b5abf86a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/RGBToHSVNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4d24b838adbc80d4cb63e3fc4f5a1c79 -timeCreated: 1494863846 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs deleted file mode 100644 index 01310922..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Simple Contrast", "Image Effects", "Simple contrast matrix multiplication" )] - public sealed class SimpleContrastOpNode : ParentNode - { - private const string InputTypeStr = "Contrast"; - private const string FunctionHeader = "CalculateContrast({0},{1})"; - private readonly string[] m_functionBody = { "float4 CalculateContrast( float contrastValue, float4 colorTarget )\n", - "{\n", - "\tfloat t = 0.5 * ( 1.0 - contrastValue );\n", - "\treturn mul( float4x4( contrastValue,0,0,t, 0,contrastValue,0,t, 0,0,contrastValue,t, 0,0,0,1 ), colorTarget );\n", - "}"}; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddPorts(); - m_textLabelWidth = 70; - m_useInternalPortData = true; - m_previewShaderGUID = "8d76799413f9f0547ac9b1de7ba798f1"; - } - - void AddPorts() - { - AddInputPort( WirePortDataType.COLOR, false, "RGBA", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "Value", -1, MasterNodePortCategory.Fragment, 0 ); - AddOutputPort( WirePortDataType.COLOR, Constants.EmptyPortValue ); - } - - 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 contrastValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string colorTarget = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string result = dataCollector.AddFunctions( FunctionHeader, m_functionBody, false, contrastValue, colorTarget ); - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 5004 ) - { - m_inputPorts[ 1 ].FloatInternalData = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs.meta deleted file mode 100644 index a860f21a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimpleContrastOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3f49defa61805f948a04775d391e507a -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs deleted file mode 100644 index ec946236..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -//https://www.shadertoy.com/view/XsX3zB -using System; -using UnityEngine; -using UnityEditor; - - -namespace AmplifyShaderEditor -{ - public enum NoiseType - { - Simplex3D, - Simplex3DFractal - } - - [Serializable] - [NodeAttributes( "[Deprecated] Simplex Noise", "Image Effects", "Noise generated via the Simplex algorithm",null,KeyCode.None,false,true)] - public sealed class SimplexNoiseNode : ParentNode - { - private string m_randomFuncBody; - private string m_simplex3dFuncBody; - private string m_simplex3dFractalFuncBody; - - private const string RandomfunctionHeader = "Random3({0})"; - private const string Simplex3dfunctionHeader = "Simplex3d({0})"; - private const string Simplex3dFractalfunctionHeader = "Simplex3dFractal( {0})"; - - private const string NoiseTypeStr = "Type"; - - [SerializeField] - private NoiseType m_type = NoiseType.Simplex3D; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - - IOUtils.AddFunctionHeader( ref m_randomFuncBody, "float3 Random3 ( float3 c )" ); - IOUtils.AddFunctionLine( ref m_randomFuncBody, "float fracMul = 512.0;float j = 4096.0*sin ( dot ( c, float3 ( 17.0, 59.4, 15.0 ) ) );float3 r;r.z = frac ( fracMul*j );j *= .125;r.x = frac ( fracMul*j );j *= .125;r.y = frac ( fracMul*j );return r - 0.5;" ); - IOUtils.CloseFunctionBody( ref m_randomFuncBody ); - - IOUtils.AddFunctionHeader( ref m_simplex3dFuncBody, "float3 Simplex3d ( float3 p )" ); - IOUtils.AddFunctionLine( ref m_simplex3dFuncBody, "float F3 = 0.3333333;float G3 = 0.1666667;float3 s = floor ( p + dot ( p, F3.xxx ) );float3 x = p - s + dot ( s, G3.xxx );float3 e = step ( ( 0.0 ).xxx, x - x.yzx );float3 i1 = e*( 1.0 - e.zxy );float3 i2 = 1.0 - e.zxy*( 1.0 - e );float3 x1 = x - i1 + G3;float3 x2 = x - i2 + 2.0*G3;float3 x3 = x - 1.0 + 3.0*G3;float4 w, d;w.x = dot ( x, x );w.y = dot ( x1, x1 );w.z = dot ( x2, x2 );w.w = dot ( x3, x3 );w = max ( 0.6 - w, 0.0 );d.x = dot ( Random3 ( s ), x );d.y = dot ( Random3 ( s + i1 ), x1 );d.z = dot ( Random3 ( s + i2 ), x2 );d.w = dot ( Random3 ( s + 1.0 ), x3 );w *= w;w *= w;d *= w;return dot ( d, ( 52.0 ).xxx ).xxx;" ); - IOUtils.CloseFunctionBody( ref m_simplex3dFuncBody ); - - IOUtils.AddFunctionHeader( ref m_simplex3dFractalFuncBody, "float3 Simplex3dFractal ( float3 m )" ); - IOUtils.AddFunctionLine( ref m_simplex3dFractalFuncBody, "return (0.5333333*Simplex3d ( m ) + 0.2666667*Simplex3d ( 2.0*m ) + 0.1333333*Simplex3d ( 4.0*m ) + 0.0666667*Simplex3d ( 8.0*m )).xxx;" ); - IOUtils.CloseFunctionBody( ref m_simplex3dFractalFuncBody ); - - AddInputPort( WirePortDataType.FLOAT3, false, "Position" ); - AddInputPort( WirePortDataType.FLOAT, false, "Width" ); - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - m_textLabelWidth = 50; - m_useInternalPortData = true; - m_autoWrapProperties = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_type = ( NoiseType ) EditorGUILayoutEnumPopup( NoiseTypeStr, m_type ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - - - string posValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string widthValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddFunctions( RandomfunctionHeader, m_randomFuncBody, "0" ); - string result = string.Empty; - switch ( m_type ) - { - case NoiseType.Simplex3D: - { - string finalValue = dataCollector.AddFunctions( Simplex3dfunctionHeader, m_simplex3dFuncBody, posValue + "*" + widthValue ); - result = finalValue + "* 0.5 + 0.5"; - }break; - - case NoiseType.Simplex3DFractal: - { - dataCollector.AddFunctions( Simplex3dfunctionHeader, m_simplex3dFuncBody, posValue + "*" + widthValue ); - string finalValue = dataCollector.AddFunctions( Simplex3dFractalfunctionHeader, m_simplex3dFractalFuncBody, posValue + "*" + widthValue + "+" + widthValue ); - result = finalValue + "* 0.5 + 0.5"; - }break; - } - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_type = ( NoiseType ) Enum.Parse( typeof( NoiseType ), GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_type ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs.meta deleted file mode 100644 index 477f0e33..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/SimplexNoiseNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3f888e3dadb5df94199547ab13cb74d2 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs deleted file mode 100644 index 5620173c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Grayscale -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Grayscale", "Image Effects", "Convert image colors to grayscale", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat", tags:"luminance" )] - public sealed class TFHCGrayscale : ParentNode - { - private const string GrayscaleStyleStr = "Grayscale Style"; - - [SerializeField] - private int m_grayscaleStyle; - - [SerializeField] - private readonly string[] m_GrayscaleStyleValues = { "Luminance", "Natural Classic", "Old School" }; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "RGB" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 120; - m_useInternalPortData = true; - m_hasLeftDropdown = true; - m_autoWrapProperties = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_GrayscaleStyleValues[ m_grayscaleStyle ] ) ); - m_previewShaderGUID = "56781cd022be9124597f0f396a46a35f"; - } - - 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; - } - - void UpdateFromSelected() - { - m_previewMaterialPassId = m_grayscaleStyle; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_GrayscaleStyleValues[ m_grayscaleStyle ] ) ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_grayscaleStyle = m_upperLeftWidget.DrawWidget( this, m_grayscaleStyle, m_GrayscaleStyleValues ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromSelected(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_grayscaleStyle = EditorGUILayoutPopup( GrayscaleStyleStr, m_grayscaleStyle, m_GrayscaleStyleValues ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromSelected(); - } - EditorGUILayout.HelpBox( "Grayscale Old:\n\n - In: Image to convert.\n - Grayscale Style: Select the grayscale style.\n\n - Out: Grayscale version of the image.", MessageType.None ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_grayscaleStyle = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdateFromSelected(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_grayscaleStyle ); - } - - 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 i = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string grayscale = string.Empty; - switch( m_grayscaleStyle ) - { - case 1: { grayscale = "dot(" + i + ", float3(0.299,0.587,0.114))"; } break; - case 2: { grayscale = "(" + i + ".r + " + i + ".g + " + i + ".b) / 3"; } break; - default: { grayscale = "Luminance(" + i + ")"; } break; - } - RegisterLocalVariable( 0, grayscale, ref dataCollector, "grayscale" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs.meta deleted file mode 100644 index 07f01e0a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/TFHCGrayscale.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 32d7b01a9f453d448abf3685a35c4a19 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs deleted file mode 100644 index 552f5653..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs +++ /dev/null @@ -1,555 +0,0 @@ -// Amplify Texture Editor - Visual Texture Editing Tool -// Amplify Texture Editor - Visual Texture Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEditor; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Voronoi", "Miscellaneous", "Voronoi", Tags = "noise" )] - public sealed class VoronoiNode : ParentNode - { - // Unity Voronoi - private readonly string UnityVoronoiNoiseFunc = "UnityVoronoi({0},{1},{2})"; - private readonly string[] UnityVoroniNoiseFunctionsBody = - { - "inline float2 UnityVoronoiRandomVector( float2 UV, float offset )\n", - "{\n", - "\tfloat2x2 m = float2x2( 15.27, 47.63, 99.41, 89.98 );\n", - "\tUV = frac( sin(mul(UV, m) ) * 46839.32 );\n", - "\treturn float2( sin(UV.y* +offset ) * 0.5 + 0.5, cos( UV.x* offset ) * 0.5 + 0.5 );\n", - "}\n", - "\n", - "//x - Out y - Cells\n", - "float3 UnityVoronoi( float2 UV, float AngleOffset, float CellDensity )\n", - "{\n", - "\tfloat2 g = floor( UV * CellDensity );\n", - "\tfloat2 f = frac( UV * CellDensity );\n", - "\tfloat t = 8.0;\n", - "\tfloat3 res = float3( 8.0, 0.0, 0.0 );\n", - "\n", - "\tfor( int y = -1; y <= 1; y++ )\n", - "\t{\n", - "\t for( int x = -1; x <= 1; x++ )\n", - "\t {\n", - "\t\t\tfloat2 lattice = float2( x, y );\n", - "\t\t\tfloat2 offset = UnityVoronoiRandomVector( lattice + g, AngleOffset );\n", - "\t\t\tfloat d = distance( lattice + offset, f );\n", - "\n", - "\t\t\tif( d < res.x )\n", - "\t\t\t{\n", - "\t\t\t\tres = float3( d, offset.x, offset.y );\n", - "\t\t\t}\n", - "\t }\n", - "\t}\n", - "\treturn res;\n", - "}\n", - }; - - //////////// - - private const string VoronoiHashHeader = "float2 voronoihash{0}( float2 p )"; - private readonly string[] VoronoiHashBody = { "p = p - 2 * floor( p / 2 );", - "p = float2( dot( p, float2( 127.1, 311.7 ) ), dot( p, float2( 269.5, 183.3 ) ) );", - "return frac( sin( p ) *43758.5453);" }; - - - private const string VoronoiHeader = "float voronoi{0}( float2 v, float time, inout float2 id, float smoothness )"; - private const string VoronoiFunc = "voronoi{0}( {1}, {2},{3}, {4} )"; - private string[] VoronoiBody = - { - "float2 n = floor( v );", - "float2 f = frac( v );", - "float F1 = 8.0;", - "float F2 = 8.0; float2 mr = 0; float2 mg = 0;", - "for ( int j = -1; j <= 1; j++ )", - "{", - " \tfor ( int i = -1; i <= 1; i++ )", - " \t{", - " \t\tfloat2 g = float2( i, j );", - " \t\tfloat2 o = voronoihash{0}( n + g );", - " \t\tfloat2 r = g - f + (sin(0 + o * 6.2831)*0.5 + 0.5);", - " \t\tfloat d = dot( r, r );", - " \t\tif( d<F1 ) {",//12 - " \t\t\tF2 = F1;",//13 - " \t\t\tF1 = d; mg = g; mr = r; id = o;",//14 - " \t\t} else if( d<F2 ) {",//15 - " \t\t\tF2 = d;",//16 - " \t\t}",//17 - " \t}", - "}", - "return F1;" - }; - - private string VoronoiDistanceBody = - "\nF1 = 8.0;" + - "\nfor ( int j = -2; j <= 2; j++ )" + - "\n{{" + - "\nfor ( int i = -2; i <= 2; i++ )" + - "\n{{" + - "\nfloat2 g = mg + float2( i, j );" + - "\nfloat2 o = voronoihash{1}( n + g );" + - "\n{0}" + - "\nfloat d = dot( 0.5 * ( mr + r ), normalize( r - mr ) );" + - "\nF1 = min( F1, d );" + - "\n}}" + - "\n}}" + - "\nreturn F1;"; - - [SerializeField] - private int m_distanceFunction = 0; - - [SerializeField] - private float m_minkowskiPower = 1; - - [SerializeField] - private int m_functionType = 0; - - [SerializeField] - private int m_octaves = 1; - - [SerializeField] - private bool m_tileable = false; - - [SerializeField] - private int m_tileScale = 1; - - [SerializeField] - private bool m_useUnity = false; - - [SerializeField] - private bool m_calculateSmoothValue = false; - - private const string FunctionTypeStr = "Method";//"Function Type"; - private readonly string[] m_functionTypeStr = { "Cells", "Crystal", "Glass", "Caustic", "Distance" }; - - private const string DistanceFunctionLabelStr = "Distance Function"; - private readonly string[] m_distanceFunctionStr = { "Euclidean\u00B2", "Euclidean", "Manhattan", "Chebyshev", "Minkowski" }; - - [SerializeField] - private int m_searchQuality = 0; - private const string SearchQualityLabelStr = "Search Quality"; - private readonly string[] m_searchQualityStr = { "9 Cells", "25 Cells", "49 Cells" }; - - - private const string UseTileScaleStr = "_UseTileScale"; - private const string TileScaleStr = "_TileScale"; - private const string MinkowskiPowerStr = "_MinkowskiPower"; - private const string DistFuncStr = "_DistFunc"; - private const string MethodTypeStr = "_MethodType"; - private const string SearchQualityStr = "_SearchQuality"; - private const string OctavesStr = "_Octaves"; - private const string UseSmoothnessStr = "_UseSmoothness"; - - private int m_UseTileScaleId; - private int m_TileScaleId; - private int m_MinkowskiPowerId; - private int m_DistFuncId; - private int m_MethodTypeId; - private int m_SearchQualityId; - private int m_OctavesId; - private int m_UseSmoothnessId; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Angle" ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - AddInputPort( WirePortDataType.FLOAT, false, "Smoothness" ); - - m_inputPorts[ 2 ].FloatInternalData = 1; - - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - AddOutputPort( WirePortDataType.FLOAT2, "ID" ); - m_textLabelWidth = 120; - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "bc1498ccdade442479038b24982fc946"; - ChangePorts(); - ChechSmoothPorts(); - } - - void ChechSmoothPorts() - { - m_inputPorts[ 3 ].Visible = !m_useUnity && m_calculateSmoothValue && (m_functionType == 0) ; - m_sizeIsDirty = true; - } - - void ChangePorts() - { - m_previewMaterialPassId = 0; - } - - public override void OnEnable() - { - base.OnEnable(); - m_UseTileScaleId = Shader.PropertyToID( UseTileScaleStr ); - m_TileScaleId = Shader.PropertyToID( TileScaleStr ); - m_MinkowskiPowerId = Shader.PropertyToID( MinkowskiPowerStr ); - m_DistFuncId = Shader.PropertyToID( DistFuncStr ); - m_MethodTypeId = Shader.PropertyToID( MethodTypeStr ); - m_SearchQualityId = Shader.PropertyToID( SearchQualityStr ); - m_OctavesId = Shader.PropertyToID( OctavesStr ); - m_UseSmoothnessId = Shader.PropertyToID( UseSmoothnessStr ); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - m_previewMaterialPassId = m_useUnity ? 0 : 1; - if( !m_useUnity ) - { - PreviewMaterial.SetInt( m_SearchQualityId, m_searchQuality + 1 ); - - if( m_functionType == 4) - { - PreviewMaterial.SetInt( m_DistFuncId, 0 ); - } else - { - PreviewMaterial.SetInt( m_DistFuncId, m_distanceFunction ); - } - - if( m_distanceFunction == 4 ) - { - PreviewMaterial.SetFloat( m_MinkowskiPowerId, m_minkowskiPower ); - } - - PreviewMaterial.SetInt( m_MethodTypeId, m_functionType ); - int smoothnessValue = m_calculateSmoothValue ? 1 : 0; - PreviewMaterial.SetInt( m_UseSmoothnessId, smoothnessValue ); - - PreviewMaterial.SetFloat( m_UseTileScaleId, m_tileable ? 1.0f : 0.0f ); - - if( m_tileable ) - PreviewMaterial.SetInt( m_TileScaleId, m_tileScale ); - - PreviewMaterial.SetInt( m_OctavesId, m_octaves ); - } - } - - public override void RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - SetPreviewInputs(); - - RenderTexture temp = RenderTexture.active; - - RenderTexture.active = m_outputPorts[ 0 ].OutputPreviewTexture; - PreviewMaterial.SetInt( "_PreviewID", 0 ); - Graphics.Blit( null, m_outputPorts[ 0 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId ); - - RenderTexture.active = m_outputPorts[ 1 ].OutputPreviewTexture; - PreviewMaterial.SetInt( "_PreviewID", 1 ); - Graphics.Blit( null, m_outputPorts[ 1 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId ); - RenderTexture.active = temp; - - PreviewIsDirty = m_continuousPreviewRefresh; - - FinishPreviewRender = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - { - EditorGUI.BeginDisabledGroup( m_useUnity ); - { - EditorGUI.BeginChangeCheck(); - m_functionType = EditorGUILayoutPopup( FunctionTypeStr, m_functionType, m_functionTypeStr ); - if( EditorGUI.EndChangeCheck() ) - { - ChechSmoothPorts(); - } - - EditorGUI.BeginDisabledGroup( m_functionType == 4 ); - m_distanceFunction = EditorGUILayoutPopup( DistanceFunctionLabelStr, m_distanceFunction, m_distanceFunctionStr ); - if( m_distanceFunction == 4 ) - { - m_minkowskiPower = EditorGUILayoutSlider( "Minkowski Power", m_minkowskiPower, 1, 5 ); - } - EditorGUI.EndDisabledGroup(); - - m_searchQuality = EditorGUILayoutPopup( SearchQualityLabelStr, m_searchQuality, m_searchQualityStr ); - m_octaves = EditorGUILayoutIntSlider( "Octaves", m_octaves, 1, 8 ); - m_tileable = EditorGUILayoutToggle( "Tileable", m_tileable ); - EditorGUI.BeginDisabledGroup( !m_tileable ); - m_tileScale = EditorGUILayoutIntField( "Tile Scale", m_tileScale ); - EditorGUI.EndDisabledGroup(); - - //Only smoothing cells type for now - if( m_functionType == 0 ) - { - EditorGUI.BeginChangeCheck(); - m_calculateSmoothValue = EditorGUILayoutToggle( "Smooth", m_calculateSmoothValue ); - if( EditorGUI.EndChangeCheck() ) - { - ChechSmoothPorts(); - } - } - } - EditorGUI.EndDisabledGroup(); - - EditorGUI.BeginChangeCheck(); - m_useUnity = EditorGUILayoutToggle( "Unity's Voronoi", m_useUnity ); - if( EditorGUI.EndChangeCheck() ) - { - ChangePorts(); - ChechSmoothPorts(); - } - } - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - } - - } - - void ChangeFunction( string scale ) - { - VoronoiBody[ 10 ] = "\t\to = ( sin( time + o * 6.2831 ) * 0.5 + 0.5 ); float2 r = g - f + o;"; - int q = m_searchQuality + 1; - VoronoiBody[ 4 ] = "for ( int j = -" + q + "; j <= " + q + "; j++ )"; - VoronoiBody[ 6 ] = "\tfor ( int i = -" + q + "; i <= " + q + "; i++ )"; - int dFunction = m_distanceFunction; - if( m_functionType == 4 ) - dFunction = 0; - switch( dFunction ) - { - default: - case 0: - VoronoiBody[ 11 ] = "\t\tfloat d = 0.5 * dot( r, r );"; - break; - case 1: - VoronoiBody[ 11 ] = "\t\tfloat d = 0.707 * sqrt(dot( r, r ));"; - break; - case 2: - VoronoiBody[ 11 ] = "\t\tfloat d = 0.5 * ( abs(r.x) + abs(r.y) );"; - break; - case 3: - VoronoiBody[ 11 ] = "\t\tfloat d = max(abs(r.x), abs(r.y));"; - break; - case 4: - VoronoiBody[ 11 ] = "\t\tfloat d = " + ( 1 / Mathf.Pow( 2, 1 / m_minkowskiPower ) ).ToString( "n3" ) + " * pow( ( pow( abs( r.x ), " + m_minkowskiPower + " ) + pow( abs( r.y ), " + m_minkowskiPower + " ) ), " + ( 1 / m_minkowskiPower ).ToString( "n3" ) + " );"; - break; - } - - if( m_functionType == 0 ) - { - if( m_calculateSmoothValue ) - { - VoronoiBody[ 12 ] = " //\t\tif( d<F1 ) {"; - VoronoiBody[ 13 ] = " //\t\t\tF2 = F1;"; - VoronoiBody[ 14 ] = " \t\t\tfloat h = smoothstep(0.0, 1.0, 0.5 + 0.5 * (F1 - d) / smoothness); F1 = lerp(F1, d, h) - smoothness * h * (1.0 - h);mg = g; mr = r; id = o;"; - VoronoiBody[ 15 ] = " //\t\t} else if( d<F2 ) {"; - VoronoiBody[ 16 ] = " //\t\t\tF2 = d;"; - VoronoiBody[ 17 ] = " //\t\t}"; - } - else - { - VoronoiBody[ 12 ] = " \t\tif( d<F1 ) {"; - VoronoiBody[ 13 ] = " \t\t\tF2 = F1;"; - VoronoiBody[ 14 ] = " \t\t\tF1 = d; mg = g; mr = r; id = o;"; - VoronoiBody[ 15 ] = " \t\t} else if( d<F2 ) {"; - VoronoiBody[ 16 ] = " \t\t\tF2 = d;"; - VoronoiBody[ 17 ] = " \t\t}"; - } - - - } - else - { - VoronoiBody[ 12 ] = " \t\tif( d<F1 ) {"; - VoronoiBody[ 13 ] = " \t\t\tF2 = F1;"; - VoronoiBody[ 14 ] = " \t\t\tF1 = d; mg = g; mr = r; id = o;"; - VoronoiBody[ 15 ] = " \t\t} else if( d<F2 ) {"; - VoronoiBody[ 16 ] = " \t\t\tF2 = d;"; - VoronoiBody[ 17 ] = " \t\t}"; - } - - switch( m_functionType ) - { - default: - case 0: - VoronoiBody[ 20 ] = "return F1;"; - break; - case 1: - VoronoiBody[ 20 ] = "return F2;"; - break; - case 2: - VoronoiBody[ 20 ] = "return F2 - F1;"; - break; - case 3: - VoronoiBody[ 20 ] = "return (F2 + F1) * 0.5;"; - break; - case 4: - VoronoiBody[ 20 ] = string.Format( VoronoiDistanceBody , VoronoiBody[ 10 ], OutputId ); - break; - } - - if( m_tileable ) - { - - VoronoiHashBody[ 0 ] = "p = p - " + m_tileScale + " * floor( p / " + m_tileScale + " );"; - } - else - { - VoronoiHashBody[ 0 ] = ""; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - if( m_useUnity ) - { - string uvValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string angleOffset = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string cellDensity = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddFunction( UnityVoroniNoiseFunctionsBody[ 0 ], UnityVoroniNoiseFunctionsBody, false ); - string varName = "unityVoronoy" + OutputId; - string varValue = string.Format( UnityVoronoiNoiseFunc, uvValue, angleOffset, cellDensity ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, varName, varValue ); - m_outputPorts[ 0 ].SetLocalValue( varName + ".x", dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( varName + ".yz", dataCollector.PortCategory ); - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - else - { - - string scaleValue = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - string timeVarValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string timeVarName = "time" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, timeVarName, timeVarValue ); - - ChangeFunction( scaleValue ); - - string voronoiHashFunc = string.Empty; - string VoronoiHashHeaderFormatted = string.Format( VoronoiHashHeader, OutputId ); - IOUtils.AddFunctionHeader( ref voronoiHashFunc, VoronoiHashHeaderFormatted ); - for( int i = 0; i < VoronoiHashBody.Length; i++ ) - { - IOUtils.AddFunctionLine( ref voronoiHashFunc, VoronoiHashBody[ i ] ); - } - IOUtils.CloseFunctionBody( ref voronoiHashFunc ); - dataCollector.AddFunction( VoronoiHashHeaderFormatted, voronoiHashFunc ); - - string smoothnessName = "0"; - if( m_calculateSmoothValue ) - { - smoothnessName = "voronoiSmooth" + outputId; - string smoothnessValue = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, smoothnessName, smoothnessValue ); - } - - string voronoiFunc = string.Empty; - IOUtils.AddFunctionHeader( ref voronoiFunc, string.Format( VoronoiHeader, OutputId ) ); - for( int i = 0; i < VoronoiBody.Length; i++ ) - { - if( i == 9 ) - { - IOUtils.AddFunctionLine( ref voronoiFunc, string.Format( VoronoiBody[ i ],OutputId ) ); - } - else - { - IOUtils.AddFunctionLine( ref voronoiFunc, VoronoiBody[ i ] ); - } - } - IOUtils.CloseFunctionBody( ref voronoiFunc ); - dataCollector.AddFunction( string.Format( VoronoiHeader, OutputId ), voronoiFunc ); - - string uvs = string.Empty; - if( m_inputPorts[ 0 ].IsConnected ) - uvs = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - else - { - if( dataCollector.IsTemplate ) - { - uvs = dataCollector.TemplateDataCollectorInstance.GenerateAutoUVs( 0 ); - } - else - { - uvs = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, 0 ); - } - } - - dataCollector.AddLocalVariable( UniqueId, string.Format( "float2 coords{0} = {1} * {2};", OutputId, uvs, scaleValue ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "float2 id{0} = 0;", OutputId ) ); - - if( m_octaves == 1 ) - { - dataCollector.AddLocalVariable( UniqueId, string.Format( "float voroi{0} = {1};", OutputId, string.Format( VoronoiFunc, OutputId, "coords" + OutputId,timeVarName, "id"+ OutputId,smoothnessName ) ) ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, string.Format( "float fade{0} = 0.5;", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "float voroi{0} = 0;", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "float rest{0} = 0;", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "for( int it{0} = 0; it{0} <" + m_octaves + "; it{0}++ ){{", OutputId) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "voroi{0} += fade{0} * voronoi{0}( coords{0}, time{0}, id{0},{1} );", OutputId, smoothnessName ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "rest{0} += fade{0};", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "coords{0} *= 2;", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "fade{0} *= 0.5;", OutputId ) ); - dataCollector.AddLocalVariable( UniqueId, "}" + "//Voronoi" + OutputId ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "voroi{0} /= rest{0};", OutputId ) ); - } - m_outputPorts[ 0 ].SetLocalValue( "voroi" + OutputId, dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( "id" + OutputId, dataCollector.PortCategory ); - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_searchQuality = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_distanceFunction = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_minkowskiPower = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_functionType = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_octaves = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_tileable = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_tileScale = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_useUnity = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 17402 ) - { - m_calculateSmoothValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - ChangePorts(); - ChechSmoothPorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_searchQuality ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_distanceFunction ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_minkowskiPower ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_functionType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_octaves ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tileable.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tileScale ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_useUnity ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_calculateSmoothValue ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs.meta deleted file mode 100644 index fb9562a3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ImageEffects/VoronoiNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a3f99c25e876b164789b7612a63ec748 -timeCreated: 1566897514 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators.meta deleted file mode 100644 index 5a304e67..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2123282111ea51445b360151bd090f3a -folderAsset: yes -timeCreated: 1481126945 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs deleted file mode 100644 index dab5a159..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs +++ /dev/null @@ -1,293 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.CodeDom; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Compare", "Logical Operators", "Compare A to B given the selected operator. If comparison is true return value of True else return value of False", tags: "If Ternary Compare Less Equal Not Greater" )] - public sealed class Compare : ParentNode - { - private static readonly string[] LabelsSTR = { "Equal", "Not Equal", "Greater", "Greater Or Equal", "Less", "Less Or Equal" }; - - enum Comparision - { - Equal, - NotEqual, - Greater, - GreaterOrEqual, - Less, - LessOrEqual, - } - - private WirePortDataType m_mainInputType = WirePortDataType.FLOAT; - private WirePortDataType m_mainOutputType = WirePortDataType.FLOAT; - - private int m_cachedOperatorId = -1; - - [SerializeField] - private Comparision m_comparision = Comparision.Equal; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "A" ); - AddInputPort( WirePortDataType.FLOAT, false, "B" ); - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].AutoDrawInternalData = true; - m_inputPorts[ 1 ].AutoDrawInternalData = true; - m_inputPorts[ 2 ].AutoDrawInternalData = true; - m_inputPorts[ 3 ].AutoDrawInternalData = true; - m_textLabelWidth = 100; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "381937898f0c15747af1da09a751890c"; - UpdateTitle(); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_comparision = (Comparision)m_upperLeftWidget.DrawWidget( this, (int)m_comparision, LabelsSTR ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateTitle(); - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedOperatorId == -1 ) - m_cachedOperatorId = Shader.PropertyToID( "_Operator" ); - - PreviewMaterial.SetInt( m_cachedOperatorId, (int)m_comparision ); - } - - void UpdateTitle() - { - switch( m_comparision ) - { - default: - case Comparision.Equal: - m_additionalContent.text = "( A = B )"; - break; - case Comparision.NotEqual: - m_additionalContent.text = "( A \u2260 B )"; - break; - case Comparision.Greater: - m_additionalContent.text = "( A > B )"; - break; - case Comparision.GreaterOrEqual: - m_additionalContent.text = "( A \u2265 B )"; - break; - case Comparision.Less: - m_additionalContent.text = "( A < B )"; - break; - case Comparision.LessOrEqual: - m_additionalContent.text = "( A \u2264 B )"; - break; - } - m_sizeIsDirty = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_comparision = (Comparision)EditorGUILayoutEnumPopup( "", m_comparision ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateTitle(); - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].ValidInternalData && !m_inputPorts[ i ].IsConnected && m_inputPorts[ i ].Visible ) - { - m_inputPorts[ i ].ShowInternalData( this ); - } - } - } - - 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 OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - - int otherPortId = 0; - if( portId < 2 ) - { - otherPortId = ( portId == 0 ) ? 1 : 0; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainInputType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainInputType, false ); - } - } - else - { - otherPortId = ( portId == 2 ) ? 3 : 2; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainOutputType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainOutputType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - } - } - } - - public void UpdateConnection( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = 0; - WirePortDataType otherPortType = WirePortDataType.FLOAT; - if( portId < 2 ) - { - otherPortId = ( portId == 0 ) ? 1 : 0; - otherPortType = m_inputPorts[ otherPortId ].IsConnected ? m_inputPorts[ otherPortId ].DataType : WirePortDataType.FLOAT; - m_mainInputType = UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( otherPortType ) ? m_inputPorts[ portId ].DataType : otherPortType; - if( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_mainInputType, false ); - } - } - else - { - otherPortId = ( portId == 2 ) ? 3 : 2; - otherPortType = m_inputPorts[ otherPortId ].IsConnected ? m_inputPorts[ otherPortId ].DataType : WirePortDataType.FLOAT; - m_mainOutputType = UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( otherPortType ) ? m_inputPorts[ portId ].DataType : otherPortType; - - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - - if( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_mainOutputType, false ); - } - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - //Conditional Operator ?: has some shenanigans - //If the first operand is of type bool, one of the following must hold for the second and third operands: - //Both operands have compatible structure types. - //Both operands are scalars with numeric or bool type. - //Both operands are vectors with numeric or bool type, where the two vectors are of the same size, which is less than or equal to four. - //If the first operand is a packed vector of bool, then the conditional selection is performed on an elementwise basis.Both the second and third operands must be numeric vectors of the same size as the first operand. - WirePortDataType compatibleInputType = m_mainInputType; - if( m_mainInputType != WirePortDataType.FLOAT && m_mainInputType != WirePortDataType.INT && m_mainInputType != m_mainOutputType ) - { - compatibleInputType = m_mainOutputType; - } - - string a = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - string b = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - string op = string.Empty; - switch( m_comparision ) - { - default: - case Comparision.Equal: - op = "=="; - break; - case Comparision.NotEqual: - op = "!="; - break; - case Comparision.Greater: - op = ">"; - break; - case Comparision.GreaterOrEqual: - op = ">="; - break; - case Comparision.Less: - op = "<"; - break; - case Comparision.LessOrEqual: - op = "<="; - break; - } - string T = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - string F = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - return CreateOutputLocalVariable( 0, string.Format( "( {0} {2} {1} ? {3} : {4} )", a, b, op, T, F ), ref dataCollector ); - } - - public override void ReadFromDeprecated( ref string[] nodeParams, Type oldType = null ) - { - base.ReadFromDeprecated( ref nodeParams, oldType ); - - if( oldType == typeof( TFHCCompareEqual ) ) - { - m_comparision = Comparision.Equal; - } - else - if( oldType == typeof( TFHCCompareNotEqual ) ) - { - m_comparision = Comparision.NotEqual; - } - else - if( oldType == typeof( TFHCCompareGreater ) ) - { - m_comparision = Comparision.Greater; - } - else - if( oldType == typeof( TFHCCompareGreaterEqual ) ) - { - m_comparision = Comparision.GreaterOrEqual; - } - else - if( oldType == typeof( TFHCCompareLower ) ) - { - m_comparision = Comparision.Less; - } - else - if( oldType == typeof( TFHCCompareLowerEqual ) ) - { - m_comparision = Comparision.LessOrEqual; - } - - UpdateTitle(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - - m_comparision = (Comparision)Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - UpdateTitle(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - - IOUtils.AddFieldValueToString( ref nodeInfo, (int)m_comparision ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs.meta deleted file mode 100644 index b8307fa4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/Compare.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ab308ada4f120144b8d44aef5c834fe6 -timeCreated: 1588859716 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs deleted file mode 100644 index d42d9708..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs +++ /dev/null @@ -1,297 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; -//using System.Collections.Generic; -//using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "If", "Logical Operators", "Conditional comparison between A with B." )] - public sealed class ConditionalIfNode : ParentNode - { - private const string UseUnityBranchesStr = "Dynamic Branching"; - private const string UnityBranchStr = "UNITY_BRANCH "; - - private readonly string[] IfOps = { "if( {0} > {1} )", - "if( {0} == {1} )", - "if( {0} < {1} )", - "if( {0} >= {1} )", - "if( {0} <= {1} )", - "if( {0} != {1} )" }; - - //private WirePortDataType m_inputMainDataType = WirePortDataType.FLOAT; - private WirePortDataType m_outputMainDataType = WirePortDataType.FLOAT; - private string[] m_results = { string.Empty, string.Empty, string.Empty }; - - [SerializeField] - private bool m_useUnityBranch = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "A" ); - AddInputPort( WirePortDataType.FLOAT, false, "B" ); - m_inputPorts[ 0 ].AddPortRestrictions( WirePortDataType.FLOAT, WirePortDataType.INT ); - m_inputPorts[ 1 ].AddPortRestrictions( WirePortDataType.FLOAT, WirePortDataType.INT ); - - AddInputPort( WirePortDataType.FLOAT, false, "A > B" ); - AddInputPort( WirePortDataType.FLOAT, false, "A == B" ); - AddInputPort( WirePortDataType.FLOAT, false, "A < B" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].AutoDrawInternalData = true; - m_inputPorts[ 1 ].AutoDrawInternalData = true; - m_textLabelWidth = 131; - //m_useInternalPortData = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "f6fb4d46bddf29e45a8a3ddfed75d0c0"; - } - - 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 OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( !m_inputPorts[ 0 ].IsConnected ) - m_inputPorts[ 0 ].FloatInternalData = EditorGUILayoutFloatField( m_inputPorts[ 0 ].Name, m_inputPorts[ 0 ].FloatInternalData ); - if( !m_inputPorts[ 1 ].IsConnected ) - m_inputPorts[ 1 ].FloatInternalData = EditorGUILayoutFloatField( m_inputPorts[ 1 ].Name, m_inputPorts[ 1 ].FloatInternalData ); - m_useUnityBranch = EditorGUILayoutToggle( UseUnityBranchesStr, m_useUnityBranch ); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateConnection( portId ); - } - - //void TestMainInputDataType() - //{ - // WirePortDataType newType = WirePortDataType.FLOAT; - // if ( m_inputPorts[ 0 ].IsConnected && UIUtils.GetPriority( m_inputPorts[ 0 ].DataType ) > UIUtils.GetPriority( newType ) ) - // { - // newType = m_inputPorts[ 0 ].DataType; - // } - - // if ( m_inputPorts[ 1 ].IsConnected && ( UIUtils.GetPriority( m_inputPorts[ 1 ].DataType ) > UIUtils.GetPriority( newType ) ) ) - // { - // newType = m_inputPorts[ 1 ].DataType; - // } - - // m_inputMainDataType = newType; - //} - - void TestMainOutputDataType() - { - WirePortDataType newType = WirePortDataType.FLOAT; - for( int i = 2; i < 5; i++ ) - { - if( m_inputPorts[ i ].IsConnected && ( UIUtils.GetPriority( m_inputPorts[ i ].DataType ) > UIUtils.GetPriority( newType ) ) ) - { - newType = m_inputPorts[ i ].DataType; - } - } - - if( newType != m_outputMainDataType ) - { - m_outputMainDataType = newType; - } - m_outputPorts[ 0 ].ChangeType( m_outputMainDataType, false ); - } - - public void UpdateConnection( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - switch( portId ) - { - //case 0: - //case 1: - //{ - // TestMainInputDataType(); - //} - //break; - case 2: - case 3: - case 4: - { - TestMainOutputDataType(); - } - break; - } - } - - 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 AValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector); - string BValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - m_results[ 0 ] = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - m_results[ 1 ] = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - m_results[ 2 ] = m_inputPorts[ 4 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - - string localVarName = "ifLocalVar" + OutputId; - string localVarDec = string.Format( "{0} {1} = 0;", UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ), localVarName ); - - bool lequal = false; - bool greater = false; - bool lesser = false; - bool gequal = false; - bool equal = false; - bool nequal = false; - bool welse = false; - bool midCon = false; - - if( m_inputPorts[ 2 ].IsConnected ) - { - greater = true; - } - - if( m_inputPorts[ 4 ].IsConnected ) - { - lesser = true; - } - - if( greater && m_inputPorts[ 2 ].GetOutputConnection() == m_inputPorts[ 3 ].GetOutputConnection() ) - { - gequal = true; - } - - if( lesser && m_inputPorts[ 4 ].GetOutputConnection() == m_inputPorts[ 3 ].GetOutputConnection() ) - { - lequal = true; - } - - if( m_inputPorts[ 2 ].GetOutputConnection() == m_inputPorts[ 4 ].GetOutputConnection() ) - { - if( m_inputPorts[ 3 ].IsConnected ) - equal = true; - else if( m_inputPorts[ 2 ].IsConnected ) - nequal = true; - } - - if( m_inputPorts[ 3 ].IsConnected ) - { - midCon = true; - - if( greater && lesser ) - welse = true; - } - - dataCollector.AddLocalVariable( UniqueId, localVarDec, true ); - if ( m_useUnityBranch && !( lequal && gequal ) && !( !greater && !midCon && !lesser ) ) - dataCollector.AddLocalVariable( UniqueId, UnityBranchStr, true ); - - if( lequal && gequal ) // all equal - { - dataCollector.AddLocalVariable( UniqueId, string.Format( "{0} = {1};", localVarName, m_results[ 1 ] ), true ); - } - else if( !lequal && gequal ) // greater or equal - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 3 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - - if( welse ) - { - dataCollector.AddLocalVariable( UniqueId, "else", true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 2 ] ), true ); - } - } - else if( lequal && !gequal )// lesser or equal - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 4 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 2 ] ), true ); - - if( welse ) - { - dataCollector.AddLocalVariable( UniqueId, "else", true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - } - } - else if( nequal )// not equal - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 5 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - } - else if( equal )// equal - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 1 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 1 ] ), true ); - - if( welse ) - { - dataCollector.AddLocalVariable( UniqueId, "else", true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - } - } - else if( lesser && !midCon && !greater ) // lesser - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 2 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 2 ] ), true ); - } - else if( greater && !midCon && !lesser ) // greater - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 0 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - } - else if( !greater && !midCon && !lesser ) // none - { - //dataCollector.AddLocalVariable( UniqueId, localVarDec ); - } - else // all different - { - bool ifStarted = false; - if( greater ) - { - dataCollector.AddLocalVariable( UniqueId, string.Format( IfOps[ 0 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 0 ] ), true ); - ifStarted = true; - } - - if( midCon ) - { - dataCollector.AddLocalVariable( UniqueId, ( ifStarted ? "else " : string.Empty ) +string.Format( IfOps[ 1 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 1 ] ), true ); - ifStarted = true; - } - - if( lesser ) - { - dataCollector.AddLocalVariable( UniqueId, "else " + string.Format( IfOps[ 2 ], AValue, BValue ), true ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "\t{0} = {1};", localVarName, m_results[ 2 ] ), true ); - } - } - - m_outputPorts[ 0 ].SetLocalValue( localVarName, dataCollector.PortCategory ); - return localVarName; - } - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 4103 ) - { - m_useUnityBranch = 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_useUnityBranch ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs.meta deleted file mode 100644 index 930b353a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/ConditionalIfNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3deb719c04d269e49bcd2a2c365da6fb -timeCreated: 1486405023 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs deleted file mode 100644 index 23650365..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs +++ /dev/null @@ -1,133 +0,0 @@ -// 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( "Keyword Switch", "Logical Operators", "Attributes a value according to the existance of a selected keyword", Deprecated = true, DeprecatedAlternativeType = typeof(StaticSwitch), DeprecatedAlternative = "Static Switch" )] - public sealed class KeywordSwitchNode : ParentNode - { - private const string KeywordStr = "Keyword"; - private const string CustomStr = "Custom"; - - [SerializeField] - private string m_currentKeyword = string.Empty; - - [SerializeField] - private int m_currentKeywordId = 0; - - [SerializeField] - private WirePortDataType m_mainPortType = WirePortDataType.FLOAT; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 65; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_currentKeywordId = EditorGUILayoutPopup( KeywordStr, m_currentKeywordId, UIUtils.AvailableKeywords ); - if ( EditorGUI.EndChangeCheck() ) - { - if ( m_currentKeywordId != 0 ) - { - m_currentKeyword = UIUtils.AvailableKeywords[ m_currentKeywordId ]; - } - } - if ( m_currentKeywordId == 0 ) - { - m_currentKeyword = EditorGUILayoutTextField( CustomStr, m_currentKeyword ); - } - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnected( portId ); - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - UpdateConnected( portId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateDisconnected( portId ); - } - - void UpdateConnected( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = ( portId + 1 ) % 2; - if ( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainPortType = ( UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( m_inputPorts[ otherPortId ].DataType ) ) ? - m_inputPorts[ portId ].DataType : - m_inputPorts[ otherPortId ].DataType; - } - else - { - m_mainPortType = m_inputPorts[ portId ].DataType; - m_inputPorts[ otherPortId ].ChangeType( m_mainPortType, false ); - } - m_outputPorts[ 0 ].ChangeType( m_mainPortType, 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 trueCode = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string falseCode = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string localVarName = "simpleKeywordVar"+OutputId; - string outType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - dataCollector.AddLocalVariable( UniqueId, "#ifdef " + m_currentKeyword, true ); - dataCollector.AddLocalVariable( UniqueId, outType + " " + localVarName + " = " + trueCode + ";", true ); - dataCollector.AddLocalVariable( UniqueId, "#else", true ); - dataCollector.AddLocalVariable( UniqueId, outType + " " + localVarName + " = " + falseCode + ";", true ); - dataCollector.AddLocalVariable( UniqueId, "#endif", true ); - m_outputPorts[ 0 ].SetLocalValue( localVarName, dataCollector.PortCategory ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - void UpdateDisconnected( int portId ) - { - int otherPortId = ( portId + 1 ) % 2; - if ( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainPortType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainPortType, false ); - } - m_outputPorts[ 0 ].ChangeType( m_mainPortType, false ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_currentKeyword = GetCurrentParam( ref nodeParams ); - m_currentKeywordId = UIUtils.GetKeywordId( m_currentKeyword ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentKeyword ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs.meta deleted file mode 100644 index 7549755e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/KeywordSwitchNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 04eb50f45d1416e4bb61902a49f06d58 -timeCreated: 1500648134 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs deleted file mode 100644 index dea9b145..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A == B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Compare (A = B)", "Logical Operators", "Check if A is equal to B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof( Compare ), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareEqual : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "6904de6cf8c08e7439672390b425ab50"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " == " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs.meta deleted file mode 100644 index d8255b8d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareEqual.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d6d04219b3c5c5a4282aa9a763b9ad3c -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs deleted file mode 100644 index 3d6db6a0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A > B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes("Compare (A > B)", "Logical Operators", "Check if A is greater than B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof( Compare ), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareGreater : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "363192dbd019ad2478f2fe6c277b7e48"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " > " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - //Debug.Log(strout); - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs.meta deleted file mode 100644 index 7d1c5723..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreater.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ff04934859005cd41ac644f2a9349e8b -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs deleted file mode 100644 index 5dc0fe6f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A >= B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes("Compare (A \u2265 B)", "Logical Operators", "Check if A is greater than or equal to B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof(Compare), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareGreaterEqual : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "f4ff76282a117c2429a1bcd8ba3a9112"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " >= " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - //Debug.Log(strout); - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs.meta deleted file mode 100644 index d8713713..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareGreaterEqual.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b2792c240940c3349bdef401f5683f70 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs deleted file mode 100644 index 8f989472..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A < B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes("Compare (A < B)", "Logical Operators", "Check if A is lower than B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof( Compare ), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareLower : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "8024509244392ed44b37c28473e66a8a"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " < " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs.meta deleted file mode 100644 index e5abcf64..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLower.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1a70dcf76fe65a64ca70400d6d08563d -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs deleted file mode 100644 index d9bcafde..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A <= B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes("Compare (A \u2264 B)", "Logical Operators", "Check if A is lower than or equal to B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof( Compare ), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareLowerEqual : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "9a3e17508793b9d42b1efaaf5bcd2554"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " <= " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs.meta deleted file mode 100644 index 4fd5beef..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareLowerEqual.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e1e66ddf48770134b806dd1f397e4ac3 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs deleted file mode 100644 index 98ec281b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare (A != B) -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes("Compare (A \u2260 B)", "Logical Operators", "Check if A is not equal to B. If true return value of True else return value of False", null, KeyCode.None, true, true, "Compare", typeof( Compare ), "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareNotEqual : TFHCStub - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "A"; - m_inputPorts[ 1 ].Name = "B"; - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "75f433376eef1ad4a881d99124e08008"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - GetInputData( ref dataCollector, ignoreLocalvar ); - string strout = "(( " + m_inputDataPort0 + " != " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " : " + m_inputDataPort3 + " )"; - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs.meta deleted file mode 100644 index 77f259df..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareNotEqual.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 48f885e2f5fa775409b9f50be6aaf80a -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs deleted file mode 100644 index efd0d409..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Compare With Range -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Compare With Range", "Logical Operators", "Check if A is in the range between Range Min and Range Max. If true return value of True else return value of False", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCCompareWithRange : DynamicTypeNode - { - private WirePortDataType m_mainInputType = WirePortDataType.FLOAT; - private WirePortDataType m_mainOutputType = WirePortDataType.FLOAT; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = "Value"; - m_inputPorts[ 1 ].Name = "Range Min"; - AddInputPort( WirePortDataType.FLOAT, false, "Range Max" ); - AddInputPort( WirePortDataType.FLOAT, false, "True" ); - AddInputPort( WirePortDataType.FLOAT, false, "False" ); - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "127d114eed178d7409f900134a6c00d1"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - UpdateConnections( portId ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - UpdateConnections( outputPortId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - if ( portId < 3 ) - { - if ( portId > 0 ) - { - m_inputPorts[ portId ].ChangeType( m_mainInputType, false ); - } - } - else - { - int otherPortId = ( portId == 3 ) ? 4 : 3; - if ( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainOutputType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainOutputType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - } - } - } - - void UpdateConnections( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = 0; - WirePortDataType otherPortType = WirePortDataType.FLOAT; - if ( portId < 3 ) - { - if ( portId == 0 ) - { - m_mainInputType = m_inputPorts[ 0 ].DataType; - for ( int i = 1; i < 3; i++ ) - { - if ( !m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].ChangeType( m_mainInputType, false ); - } - } - } - } - else - { - otherPortId = ( portId == 3 ) ? 4 : 3; - otherPortType = m_inputPorts[ otherPortId ].IsConnected ? m_inputPorts[ otherPortId ].DataType : WirePortDataType.FLOAT; - m_mainOutputType = UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( otherPortType ) ? m_inputPorts[ portId ].DataType : otherPortType; - - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - - if ( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_mainOutputType, false ); - } - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - //Conditional Operator ?: has some shenanigans - //If the first operand is of type bool, one of the following must hold for the second and third operands: - //Both operands have compatible structure types. - //Both operands are scalars with numeric or bool type. - //Both operands are vectors with numeric or bool type, where the two vectors are of the same size, which is less than or equal to four. - //If the first operand is a packed vector of bool, then the conditional selection is performed on an elementwise basis.Both the second and third operands must be numeric vectors of the same size as the first operand. - WirePortDataType compatibleInputType = m_mainInputType; - if ( m_mainInputType != WirePortDataType.FLOAT && m_mainInputType != WirePortDataType.INT && m_mainInputType != m_mainOutputType ) - { - compatibleInputType = m_mainOutputType; - } - - //Check if VALUE is in range between MIN and MAX. If true return VALUE IF TRUE else VALUE IF FALSE" - string a = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - string b = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - string c = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - string d = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - string e = m_inputPorts[ 4 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - string strout = "(( " + a + " >= " + b + " && " + a + " <= " + c + " ) ? " + d + " : " + e + " )"; - //Debug.Log(strout); - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs.meta deleted file mode 100644 index 9cef3a3f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCCompareWithRange.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e7d30ad11b781804ebd54834781a32d9 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs deleted file mode 100644 index 7ed72724..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node If -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "If [Community]", "Logical Operators", "Compare A with B. If A is greater than B output the value of A > B port. If A is equal to B output the value of A == B port. If A is lower than B output the value of A < B port. Equal Threshold parameter will be used to check A == B adding and subtracting this value to A.", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCIf : ParentNode - { - private WirePortDataType m_inputMainDataType = WirePortDataType.FLOAT; - private WirePortDataType m_outputMainDataType = WirePortDataType.FLOAT; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "A" ); - AddInputPort( WirePortDataType.FLOAT, false, "B" ); - AddInputPort( WirePortDataType.FLOAT, false, "A > B" ); - AddInputPort( WirePortDataType.FLOAT, false, "A == B" ); - AddInputPort( WirePortDataType.FLOAT, false, "A < B" ); - AddInputPort( WirePortDataType.FLOAT, false, "Equal Threshold" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 110; - m_useInternalPortData = true; - m_previewShaderGUID = "5c7bc7e3cab81da499e4864ace0d86c5"; - } - - 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 OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - UpdateConnection( portId ); - } - - void TestMainInputDataType() - { - WirePortDataType newType = WirePortDataType.FLOAT; - if( m_inputPorts[ 0 ].IsConnected && UIUtils.GetPriority( m_inputPorts[ 0 ].DataType ) > UIUtils.GetPriority( newType ) ) - { - newType = m_inputPorts[ 0 ].DataType; - } - - if( m_inputPorts[ 1 ].IsConnected && ( UIUtils.GetPriority( m_inputPorts[ 1 ].DataType ) > UIUtils.GetPriority( newType ) ) ) - { - newType = m_inputPorts[ 1 ].DataType; - } - - if( m_inputPorts[ 5 ].IsConnected && ( UIUtils.GetPriority( m_inputPorts[ 5 ].DataType ) > UIUtils.GetPriority( newType ) ) ) - { - newType = m_inputPorts[ 5 ].DataType; - } - - m_inputMainDataType = newType; - } - - void TestMainOutputDataType() - { - WirePortDataType newType = WirePortDataType.FLOAT; - for( int i = 2; i < 5; i++ ) - { - if( m_inputPorts[ i ].IsConnected && ( UIUtils.GetPriority( m_inputPorts[ i ].DataType ) > UIUtils.GetPriority( newType ) ) ) - { - newType = m_inputPorts[ i ].DataType; - } - } - - if( newType != m_outputMainDataType ) - { - m_outputMainDataType = newType; - m_outputPorts[ 0 ].ChangeType( m_outputMainDataType, false ); - } - } - - public void UpdateConnection( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - switch( portId ) - { - case 0: - case 1: - case 5: - { - TestMainInputDataType(); - } - break; - case 2: - case 3: - case 4: - { - TestMainOutputDataType(); - } - break; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string a = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputMainDataType, ignoreLocalvar, true ); - string b = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_inputMainDataType, ignoreLocalvar, true ); - string r1 = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - string r2 = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - string r3 = m_inputPorts[ 4 ].GenerateShaderForOutput( ref dataCollector, m_outputMainDataType, ignoreLocalvar, true ); - string tr = m_inputPorts[ 5 ].GenerateShaderForOutput( ref dataCollector, m_inputMainDataType, ignoreLocalvar, true ); - - // No Equal Threshold parameter - //(a > b ? r1 : a == b ? r2 : r3 ) - //string strout = " ( " + a + " > " + b + " ? " + r1 + " : " + a + " == " + b + " ? " + r2 + " : " + r3 + " ) "; - - // With Equal Threshold parameter - // ( a - tr > b ? r1 : a - tr <= b && a + tr >= b ? r2 : r3 ) - string strout = " ( " + a + " - " + tr + " > " + b + " ? " + r1 + " : " + a + " - " + tr + " <= " + b + " && " + a + " + " + tr + " >= " + b + " ? " + r2 + " : " + r3 + " ) "; - - //Debug.Log( strout ); - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs.meta deleted file mode 100644 index 8d6fe583..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCIf.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1a3d561a45c21114c99f52c5432b25e9 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs deleted file mode 100644 index 38dd4052..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - - -namespace AmplifyShaderEditor -{ - [System.Serializable] - public class TFHCStub : DynamicTypeNode - { - protected WirePortDataType m_mainInputType = WirePortDataType.FLOAT; - protected WirePortDataType m_mainOutputType = WirePortDataType.FLOAT; - protected string m_inputDataPort0 = string.Empty; - protected string m_inputDataPort1 = string.Empty; - protected string m_inputDataPort2 = string.Empty; - protected string m_inputDataPort3 = string.Empty; - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - UpdateConnections( portId ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - UpdateConnections( outputPortId ); - } - - public override void OnInputPortDisconnected( int portId ) - { - int otherPortId = 0; - if ( portId < 2 ) - { - otherPortId = ( portId == 0 ) ? 1 : 0; - if ( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainInputType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainInputType, false ); - } - } - else - { - otherPortId = ( portId == 2 ) ? 3 : 2; - if ( m_inputPorts[ otherPortId ].IsConnected ) - { - m_mainOutputType = m_inputPorts[ otherPortId ].DataType; - m_inputPorts[ portId ].ChangeType( m_mainOutputType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - } - } - } - - public void GetInputData( ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - //Conditional Operator ?: has some shenanigans - //If the first operand is of type bool, one of the following must hold for the second and third operands: - //Both operands have compatible structure types. - //Both operands are scalars with numeric or bool type. - //Both operands are vectors with numeric or bool type, where the two vectors are of the same size, which is less than or equal to four. - //If the first operand is a packed vector of bool, then the conditional selection is performed on an elementwise basis.Both the second and third operands must be numeric vectors of the same size as the first operand. - WirePortDataType compatibleInputType = m_mainInputType; - if ( m_mainInputType != WirePortDataType.FLOAT && m_mainInputType != WirePortDataType.INT && m_mainInputType != m_mainOutputType ) - { - compatibleInputType = m_mainOutputType; - } - - m_inputDataPort0 = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - m_inputDataPort1 = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, compatibleInputType, ignoreLocalvar, true ); - - - m_inputDataPort2 = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - m_inputDataPort3 = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_mainOutputType, ignoreLocalvar, true ); - } - - void UpdateConnections( int portId ) - { - m_inputPorts[ portId ].MatchPortToConnection(); - int otherPortId = 0; - WirePortDataType otherPortType = WirePortDataType.FLOAT; - if ( portId < 2 ) - { - otherPortId = ( portId == 0 ) ? 1 : 0; - otherPortType = m_inputPorts[ otherPortId ].IsConnected ? m_inputPorts[ otherPortId ].DataType : WirePortDataType.FLOAT; - m_mainInputType = UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( otherPortType ) ? m_inputPorts[ portId ].DataType : otherPortType; - if ( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_mainInputType, false ); - } - } - else - { - otherPortId = ( portId == 2 ) ? 3 : 2; - otherPortType = m_inputPorts[ otherPortId ].IsConnected ? m_inputPorts[ otherPortId ].DataType : WirePortDataType.FLOAT; - m_mainOutputType = UIUtils.GetPriority( m_inputPorts[ portId ].DataType ) > UIUtils.GetPriority( otherPortType ) ? m_inputPorts[ portId ].DataType : otherPortType; - - m_outputPorts[ 0 ].ChangeType( m_mainOutputType, false ); - - if ( !m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ otherPortId ].ChangeType( m_mainOutputType, false ); - } - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs.meta deleted file mode 100644 index ca618e77..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/LogicalOperators/TFHCStub.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 67238b98f61049c45b496af625863edf -timeCreated: 1481646118 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master.meta deleted file mode 100644 index e014e2d5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 7787d08c0679d324c99a7ca9a1a3e6a4 -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs deleted file mode 100644 index 7aa08d96..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class AdditionalDefinesHelper - { - private const string AdditionalDefinesStr = " Additional Defines"; - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<string> m_additionalDefines = new List<string>(); - public List<string> DefineList { get { return m_additionalDefines; } set { m_additionalDefines = value; } } - - [SerializeField] - private List<string> m_outsideDefines = new List<string>(); - public List<string> OutsideList { get { return m_outsideDefines; } set { m_outsideDefines = value; } } - - public void Draw( ParentNode owner ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDefines; - NodeUtils.DrawPropertyGroup( ref value, AdditionalDefinesStr, DrawMainBody, DrawButtons ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDefines = value; - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add keyword - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalDefines.Add( string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove keyword - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_additionalDefines.Count > 0 ) - { - m_additionalDefines.RemoveAt( m_additionalDefines.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - int itemCount = m_additionalDefines.Count; - int markedToDelete = -1; - for( int i = 0; i < itemCount; i++ ) - { - EditorGUILayout.BeginHorizontal(); - { - EditorGUI.BeginChangeCheck(); - m_additionalDefines[ i ] = EditorGUILayout.TextField( m_additionalDefines[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_additionalDefines[ i ] = UIUtils.RemoveShaderInvalidCharacters( m_additionalDefines[ i ] ); - } - - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalDefines.Insert( i + 1, string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - } - - if( markedToDelete > -1 ) - { - if( m_additionalDefines.Count > markedToDelete ) - { - m_additionalDefines.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - EditorGUILayout.HelpBox( "Please add your defines without the #define keywords", MessageType.Info ); - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_additionalDefines.Add( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDefines.Count ); - for( int i = 0; i < m_additionalDefines.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDefines[ i ] ); - } - } - - public void AddToDataCollector( ref MasterNodeDataCollector dataCollector ) - { - for( int i = 0; i < m_additionalDefines.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_additionalDefines[ i ] ) ) - dataCollector.AddToDefines( -1, m_additionalDefines[ i ] ); - } - - for( int i = 0; i < m_outsideDefines.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_outsideDefines[ i ] ) ) - dataCollector.AddToDefines( -1, m_outsideDefines[ i ] ); - } - } - - public void Destroy() - { - m_additionalDefines.Clear(); - m_additionalDefines = null; - m_currentOwner = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs.meta deleted file mode 100644 index 6839c0e6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalDefinesHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0801a5994efb46142ad8dcc0fe3c47f8 -timeCreated: 1513252939 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs deleted file mode 100644 index 542b586f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class AdditionalIncludesHelper - { - private const string AdditionalIncludesStr = " Additional Includes"; - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<string> m_additionalIncludes = new List<string>(); - public List<string> IncludeList { get { return m_additionalIncludes; } set { m_additionalIncludes = value; } } - - [SerializeField] - private List<string> m_outsideIncludes = new List<string>(); - public List<string> OutsideList { get { return m_outsideIncludes; } set { m_outsideIncludes = value; } } - - public void Draw( ParentNode owner ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalIncludes; - NodeUtils.DrawPropertyGroup( ref value, AdditionalIncludesStr, DrawMainBody, DrawButtons ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalIncludes = value; - - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add keyword - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalIncludes.Add( string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove keyword - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_additionalIncludes.Count > 0 ) - { - m_additionalIncludes.RemoveAt( m_additionalIncludes.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - //if( OutsideList != null && OutsideList.Count > 0 ) - //{ - // m_drawElements.Clear(); - // EditorGUI.BeginDisabledGroup( true ); - // int outsideCount = OutsideList.Count; - // for( int i = 0; i < outsideCount; i++ ) - // { - // if( !m_drawElements.Contains( OutsideList[ i ] ) ) - // { - // m_drawElements.Add( OutsideList[ i ] ); - // EditorGUILayout.TextField( OutsideList[ i ] ); - // } - // } - // EditorGUI.EndDisabledGroup(); - // EditorGUILayout.Separator(); - //} - int itemCount = m_additionalIncludes.Count; - int markedToDelete = -1; - for( int i = 0; i < itemCount; i++ ) - { - EditorGUILayout.BeginHorizontal(); - { - EditorGUI.BeginChangeCheck(); - m_additionalIncludes[ i ] = EditorGUILayout.TextField( m_additionalIncludes[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_additionalIncludes[ i ] = UIUtils.RemoveShaderInvalidCharacters( m_additionalIncludes[ i ] ); - } - - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalIncludes.Insert( i + 1, string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - } - - if( markedToDelete > -1 ) - { - if( m_additionalIncludes.Count > markedToDelete ) - { - m_additionalIncludes.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - EditorGUILayout.HelpBox( "Please add your includes without the #include \"\" keywords", MessageType.Info ); - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_additionalIncludes.Add( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalIncludes.Count ); - for( int i = 0; i < m_additionalIncludes.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalIncludes[ i ] ); - } - } - - public void AddToDataCollector( ref MasterNodeDataCollector dataCollector ) - { - for( int i = 0; i < m_additionalIncludes.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_additionalIncludes[ i ] ) ) - dataCollector.AddToIncludes( -1, m_additionalIncludes[ i ] ); - } - - for( int i = 0; i < m_outsideIncludes.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_outsideIncludes[ i ] ) ) - dataCollector.AddToIncludes( -1, m_outsideIncludes[ i ] ); - } - } - - public void Destroy() - { - m_additionalIncludes.Clear(); - m_additionalIncludes = null; - m_currentOwner = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs.meta deleted file mode 100644 index 0997164e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalIncludesHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 74ff3d342e013f64198aaf767e623962 -timeCreated: 1498123240 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs deleted file mode 100644 index a7e89707..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class AdditionalPragmasHelper - { - private const string AdditionalPragmasStr = " Additional Pragmas"; - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<string> m_additionalPragmas = new List<string>(); - public List<string> PragmaList { get { return m_additionalPragmas; } set { m_additionalPragmas = value; } } - - [SerializeField] - private List<string> m_outsidePragmas = new List<string>(); - public List<string> OutsideList { get { return m_outsidePragmas; } set { m_outsidePragmas = value; } } - - public void Draw( ParentNode owner ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalPragmas; - NodeUtils.DrawPropertyGroup( ref value, AdditionalPragmasStr, DrawMainBody, DrawButtons ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalPragmas = value; - - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add keyword - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalPragmas.Add( string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove keyword - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_additionalPragmas.Count > 0 ) - { - m_additionalPragmas.RemoveAt( m_additionalPragmas.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - int itemCount = m_additionalPragmas.Count; - int markedToDelete = -1; - for( int i = 0; i < itemCount; i++ ) - { - EditorGUILayout.BeginHorizontal(); - { - EditorGUI.BeginChangeCheck(); - m_additionalPragmas[ i ] = EditorGUILayout.TextField( m_additionalPragmas[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_additionalPragmas[ i ] = UIUtils.RemoveShaderInvalidCharacters( m_additionalPragmas[ i ] ); - } - - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_additionalPragmas.Insert( i + 1, string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - } - - if( markedToDelete > -1 ) - { - if( m_additionalPragmas.Count > markedToDelete ) - { - m_additionalPragmas.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - EditorGUILayout.HelpBox( "Please add your pragmas without the #pragma keywords", MessageType.Info ); - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_additionalPragmas.Add( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalPragmas.Count ); - for( int i = 0; i < m_additionalPragmas.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalPragmas[ i ] ); - } - } - - public void AddToDataCollector( ref MasterNodeDataCollector dataCollector ) - { - for( int i = 0; i < m_additionalPragmas.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_additionalPragmas[ i ] ) ) - dataCollector.AddToPragmas( -1, m_additionalPragmas[ i ] ); - } - - for( int i = 0; i < m_outsidePragmas.Count; i++ ) - { - if( !string.IsNullOrEmpty( m_outsidePragmas[ i ] ) ) - dataCollector.AddToPragmas( -1, m_outsidePragmas[ i ] ); - } - } - - public void Destroy() - { - m_additionalPragmas.Clear(); - m_additionalPragmas = null; - m_currentOwner = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs.meta deleted file mode 100644 index 3f245aaf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalPragmasHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3153b4d10effd174988d75b84b12d281 -timeCreated: 1504515475 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs deleted file mode 100644 index cd3efae7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - - [Serializable] - public class AdditionalSurfaceOptionsHelper - { - private const string AdditionalOptionsStr = " Additional Surface Options"; - - - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<string> m_availableOptions = new List<string>(); - - public void Draw( ParentNode owner ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalSurfaceOptions; - NodeUtils.DrawPropertyGroup( ref value, AdditionalOptionsStr, DrawMainBody, DrawButtons ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalSurfaceOptions = value; - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add tag - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableOptions.Add( string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove tag - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_availableOptions.Count > 0 ) - { - m_availableOptions.RemoveAt( m_availableOptions.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - int itemCount = m_availableOptions.Count; - - if( itemCount == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - - int markedToDelete = -1; - float originalLabelWidth = EditorGUIUtility.labelWidth; - for( int i = 0; i < itemCount; i++ ) - { - - EditorGUI.indentLevel += 1; - EditorGUIUtility.labelWidth = 62; - EditorGUILayout.BeginHorizontal(); - //Option - EditorGUI.BeginChangeCheck(); - m_availableOptions[ i ] = EditorGUILayout.TextField( "["+i+"] -", m_availableOptions[ i ] ); - if( EditorGUI.EndChangeCheck() ) - { - m_availableOptions[ i ] = UIUtils.RemoveShaderInvalidCharacters( m_availableOptions[ i ] ); - } - - EditorGUIUtility.labelWidth = originalLabelWidth; - - { - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableOptions.Insert( i + 1, string.Empty ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel -= 1; - } - - if( markedToDelete > -1 ) - { - if( m_availableOptions.Count > markedToDelete ) - { - m_availableOptions.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_availableOptions.Add( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - int optionsCount = m_availableOptions.Count; - IOUtils.AddFieldValueToString( ref nodeInfo, optionsCount ); - for( int i = 0; i < optionsCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_availableOptions[ i ].ToString() ); - } - } - - public void WriteToOptionalSurfaceOptions( ref string currentOptions ) - { - int tagsCount = m_availableOptions.Count; - if( tagsCount == 0 ) - return; - - string result = " "; - - for( int i = 0; i < tagsCount; i++ ) - { - result += m_availableOptions[ i ]; - if( i < tagsCount - 1 ) - { - result += " "; - } - } - currentOptions = currentOptions + result; - } - - public void Destroy() - { - m_availableOptions.Clear(); - m_availableOptions = null; - m_currentOwner = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs.meta deleted file mode 100644 index ccd630e4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/AdditionalSurfaceOptionsHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d830b2cc8bc5e174485077319135fc1e -timeCreated: 1528881842 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs deleted file mode 100644 index d1391d95..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs +++ /dev/null @@ -1,242 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -// Billboard based on: -// https://gist.github.com/renaudbedard/7a90ec4a5a7359712202 -using System; -using UnityEngine; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - public enum BillboardType - { - Cylindrical, - Spherical - } - - [Serializable] - public class BillboardOpHelper - { - public static readonly string BillboardTitleStr = " Billboard"; - public static readonly string BillboardTypeStr = "Type"; - public static readonly string BillboardRotIndStr = "Ignore Rotation"; - - public static readonly string[] BillboardCylindricalInstructions = { "//Calculate new billboard vertex position and normal", - "float3 upCamVec = float3( 0, 1, 0 )"}; - - public static readonly string[] BillboardSphericalInstructions = { "//Calculate new billboard vertex position and normal", - "float3 upCamVec = normalize ( UNITY_MATRIX_V._m10_m11_m12 )"}; - - - public static readonly string[] BillboardCommonInstructions = { "float3 forwardCamVec = -normalize ( UNITY_MATRIX_V._m20_m21_m22 )", - "float3 rightCamVec = normalize( UNITY_MATRIX_V._m00_m01_m02 )", - "float4x4 rotationCamMatrix = float4x4( rightCamVec, 0, upCamVec, 0, forwardCamVec, 0, 0, 0, 0, 1 )", - "{0} = normalize( mul( float4( {0} , 0 ), rotationCamMatrix )).xyz"}; - - public static readonly string[] BillboardRotDependent = { "//This unfortunately must be made to take non-uniform scaling into account", - "//Transform to world coords, apply rotation and transform back to local", - "{0} = mul( {1} , unity_ObjectToWorld ){2}", - "{0} = mul( {1} , rotationCamMatrix ){2}", - "{0} = mul( {1} , unity_WorldToObject ){2}"}; - - - public static readonly string[] BillboardRotIndependent = { "{0}.x *= length( unity_ObjectToWorld._m00_m10_m20 )", - "{0}.y *= length( unity_ObjectToWorld._m01_m11_m21 )", - "{0}.z *= length( unity_ObjectToWorld._m02_m12_m22 )", - "{0} = mul( {0}, rotationCamMatrix )", - "{0}.xyz += unity_ObjectToWorld._m03_m13_m23", - "//Need to nullify rotation inserted by generated surface shader", - "{0} = mul( unity_WorldToObject, {0} )"}; - - - - public static readonly string[] BillboardHDRotDependent = { "//This unfortunately must be made to take non-uniform scaling into account", - "//Transform to world coords, apply rotation and transform back to local", - "{0} = mul( {1} , GetObjectToWorldMatrix() ){2}", - "{0} = mul( {1} , rotationCamMatrix ){2}", - "{0} = mul( {1} , GetWorldToObjectMatrix() ){2}"}; - - - public static readonly string[] BillboardHDRotIndependent = { "{0}.x *= length( GetObjectToWorldMatrix()._m00_m10_m20 )", - "{0}.y *= length( GetObjectToWorldMatrix()._m01_m11_m21 )", - "{0}.z *= length( GetObjectToWorldMatrix()._m02_m12_m22 )", - "{0} = mul( {0}, rotationCamMatrix )", - "{0}.xyz += GetObjectToWorldMatrix()._m03_m13_m23", - "//Need to nullify rotation inserted by generated surface shader", - "{0} = mul( GetWorldToObjectMatrix(), {0} )"}; - - - [SerializeField] - private bool m_isBillboard = false; - - [SerializeField] - private BillboardType m_billboardType = BillboardType.Cylindrical; - - [SerializeField] - private bool m_rotationIndependent = false; - - public void Draw( ParentNode owner ) - { - bool visible = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedVertexOptions; - bool enabled = m_isBillboard; - NodeUtils.DrawPropertyGroup( owner, ref visible, ref m_isBillboard, BillboardTitleStr, () => - { - m_billboardType = (BillboardType)owner.EditorGUILayoutEnumPopup( BillboardTypeStr, m_billboardType ); - m_rotationIndependent = owner.EditorGUILayoutToggle( BillboardRotIndStr, m_rotationIndependent ); - } ); - - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedVertexOptions = visible; - if( m_isBillboard != enabled ) - { - UIUtils.RequestSave(); - } - } - public void FillDataCollectorWithInternalData( ref MasterNodeDataCollector dataCollector ) - { - if( m_isBillboard ) - { - FillDataCollector( ref dataCollector, m_billboardType, m_rotationIndependent, "v.vertex", "v.normal", false ); - } - } - // This should be called after the Vertex Offset and Vertex Normal ports are analised - public static void FillDataCollector( ref MasterNodeDataCollector dataCollector, BillboardType billboardType, bool rotationIndependent, string vertexPosValue, string vertexNormalValue, bool vertexIsFloat3 ) - { - switch( billboardType ) - { - case BillboardType.Cylindrical: - { - for( int i = 0; i < BillboardCylindricalInstructions.Length; i++ ) - { - dataCollector.AddVertexInstruction( BillboardCylindricalInstructions[ i ] + ( dataCollector.IsTemplate ? ";" : string.Empty ), -1, true ); - } - } - break; - - case BillboardType.Spherical: - { - for( int i = 0; i < BillboardCylindricalInstructions.Length; i++ ) - { - dataCollector.AddVertexInstruction( BillboardSphericalInstructions[ i ] + ( dataCollector.IsTemplate ? ";" : string.Empty ), -1, true ); - } - } - break; - } - - for( int i = 0; i < BillboardCommonInstructions.Length; i++ ) - { - string value = ( i == 3 ) ? string.Format( BillboardCommonInstructions[ i ], vertexNormalValue ) : BillboardCommonInstructions[ i ]; - dataCollector.AddVertexInstruction( value + ( dataCollector.IsTemplate ? ";" : string.Empty ), -1, true ); - } - - if( rotationIndependent ) - { - for( int i = 0; i < BillboardRotIndependent.Length; i++ ) - { - string value = string.Empty; - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.BuiltIn ) - { - value = ( i != 5 ) ? string.Format( BillboardHDRotIndependent[ i ], vertexPosValue ) : BillboardHDRotIndependent[ i ]; - } - else - { - value = ( i != 5 ) ? string.Format( BillboardRotIndependent[ i ], vertexPosValue ) : BillboardRotIndependent[ i ]; - } - dataCollector.AddVertexInstruction( value + ( dataCollector.IsTemplate ? ";" : string.Empty ), -1, true ); - } - } - else - { - string vertexPosConverted = vertexIsFloat3 ? string.Format( "float4({0},0)", vertexPosValue ) : vertexPosValue; - for( int i = 0; i < BillboardRotDependent.Length; i++ ) - { - string value = string.Empty; - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) - { - value = ( i > 1 ) ? string.Format( BillboardHDRotDependent[ i ], vertexPosValue, vertexPosConverted, ( vertexIsFloat3 ? ".xyz" : string.Empty ) ) : BillboardHDRotDependent[ i ]; - } - else - { - value = ( i > 1 ) ? string.Format( BillboardRotDependent[ i ], vertexPosValue, vertexPosConverted, ( vertexIsFloat3 ? ".xyz" : string.Empty ) ) : BillboardRotDependent[ i ]; - } - dataCollector.AddVertexInstruction( value + ( dataCollector.IsTemplate ? ";" : string.Empty ), -1, true ); - } - } - } - - public string[] GetInternalMultilineInstructions() - { - // This method is only used on Surface ... no HD variation is needed - return GetMultilineInstructions( m_billboardType, m_rotationIndependent, "v.vertex", "v.normal" ); - } - - public static string[] GetMultilineInstructions( BillboardType billboardType, bool rotationIndependent, string vertexPosValue, string vertexNormalValue ) - { - // This method is only used on Surface ... no HD variation is needed - List<string> body = new List<string>(); - switch( billboardType ) - { - case BillboardType.Cylindrical: - { - for( int i = 0; i < BillboardCylindricalInstructions.Length; i++ ) - { - body.Add( BillboardCylindricalInstructions[ i ] ); - } - } - break; - - case BillboardType.Spherical: - { - for( int i = 0; i < BillboardCylindricalInstructions.Length; i++ ) - { - body.Add( BillboardSphericalInstructions[ i ] ); - } - } - break; - } - - for( int i = 0; i < BillboardCommonInstructions.Length; i++ ) - { - string value = ( i == 3 ) ? string.Format( BillboardCommonInstructions[ i ], vertexNormalValue ) : BillboardCommonInstructions[ i ]; - body.Add( value ); - } - - if( rotationIndependent ) - { - for( int i = 0; i < BillboardRotIndependent.Length; i++ ) - { - string value = ( i != 5 ) ? string.Format( BillboardRotIndependent[ i ], vertexPosValue ) : BillboardRotIndependent[ i ]; - body.Add( value ); - } - } - else - { - for( int i = 0; i < BillboardRotDependent.Length; i++ ) - { - string value = ( i > 1 ) ? string.Format( BillboardRotDependent[ i ], vertexPosValue ) : BillboardRotDependent[ i ]; - body.Add( value ); - } - } - return body.ToArray(); - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_isBillboard = Convert.ToBoolean( nodeParams[ index++ ] ); - m_billboardType = (BillboardType)Enum.Parse( typeof( BillboardType ), nodeParams[ index++ ] ); - if( UIUtils.CurrentShaderVersion() > 11007 ) - { - m_rotationIndependent = Convert.ToBoolean( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_isBillboard ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_billboardType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_rotationIndependent ); - } - - public bool IsBillboard { get { return m_isBillboard; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs.meta deleted file mode 100644 index 812475f8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BillboardOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 837b906a268babc49ac733573c5b3394 -timeCreated: 1489159407 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs deleted file mode 100644 index 989ace5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs +++ /dev/null @@ -1,447 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - public enum AvailableBlendFactor - { - One = 1, - Zero = 0, - SrcColor = 3, - SrcAlpha = 5, - DstColor = 2, - DstAlpha = 7, - OneMinusSrcColor = 6, - OneMinusSrcAlpha = 10, - OneMinusDstColor = 4, - OneMinusDstAlpha = 8, - SrcAlphaSaturate = 9 - }; - - public enum AvailableBlendOps - { - OFF = 0, - Add, - Sub, - RevSub, - Min, - Max, - //Direct X11 only - LogicalClear, - LogicalSet, - LogicalCopy, - LogicalCopyInverted, - LogicalNoop, - LogicalInvert, - LogicalAnd, - LogicalNand, - LogicalOr, - LogicalNor, - LogicalXor, - LogicalEquiv, - LogicalAndReverse, - LogicalAndInverted, - LogicalOrReverse, - LogicalOrInverted - }; - - public class CommonBlendTypes - { - public string Name; - public AvailableBlendFactor SourceFactor; - public AvailableBlendFactor DestFactor; - public CommonBlendTypes( string name, AvailableBlendFactor sourceFactor, AvailableBlendFactor destFactor ) - { - Name = name; - SourceFactor = sourceFactor; - DestFactor = destFactor; - } - } - - [Serializable] - public class BlendOpsHelper - { - public static readonly string[] BlendOpsLabels = - { - "<OFF>", - "Add", - "Sub", - "RevSub", - "Min", - "Max", - "LogicalClear ( DX11.1 Only )", - "LogicalSet ( DX11.1 Only )", - "LogicalCopy ( DX11.1 Only )", - "LogicalCopyInverted ( DX11.1 Only )", - "LogicalNoop ( DX11.1 Only )", - "LogicalInvert ( DX11.1 Only )", - "LogicalAnd ( DX11.1 Only )", - "LogicalNand ( DX11.1 Only )", - "LogicalOr ( DX11.1 Only )", - "LogicalNor ( DX11.1 Only )", - "LogicalXor ( DX11.1 Only )", - "LogicalEquiv ( DX11.1 Only )", - "LogicalAndReverse ( DX11.1 Only )", - "LogicalAndInverted ( DX11.1 Only )", - "LogicalOrReverse ( DX11.1 Only )", - "LogicalOrInverted ( DX11.1 Only )" - }; - - private const string BlendModesRGBStr = "Blend RGB"; - private const string BlendModesAlphaStr = "Blend Alpha"; - - private const string BlendOpsRGBStr = "Blend Op RGB"; - private const string BlendOpsAlphaStr = "Blend Op Alpha"; - - private const string SourceFactorStr = "Src"; - private const string DstFactorStr = "Dst"; - - private const string SingleBlendFactorStr = "Blend {0} {1}"; - private const string SeparateBlendFactorStr = "Blend {0} {1} , {2} {3}"; - - private const string SingleBlendOpStr = "BlendOp {0}"; - private const string SeparateBlendOpStr = "BlendOp {0} , {1}"; - - private string[] m_commonBlendTypesArr; - private List<CommonBlendTypes> m_commonBlendTypes = new List<CommonBlendTypes> { new CommonBlendTypes("<OFF>", AvailableBlendFactor.Zero, AvailableBlendFactor.Zero ), - new CommonBlendTypes("Custom", AvailableBlendFactor.Zero, AvailableBlendFactor.Zero ) , - new CommonBlendTypes("Alpha Blend", AvailableBlendFactor.SrcAlpha, AvailableBlendFactor.OneMinusSrcAlpha ) , - new CommonBlendTypes("Premultiplied", AvailableBlendFactor.One, AvailableBlendFactor.OneMinusSrcAlpha ), - new CommonBlendTypes("Additive", AvailableBlendFactor.One, AvailableBlendFactor.One ), - new CommonBlendTypes("Soft Additive", AvailableBlendFactor.OneMinusDstColor, AvailableBlendFactor.One ), - new CommonBlendTypes("Multiplicative", AvailableBlendFactor.DstColor, AvailableBlendFactor.Zero ), - new CommonBlendTypes("2x Multiplicative", AvailableBlendFactor.DstColor, AvailableBlendFactor.SrcColor ), - new CommonBlendTypes("Particle Additive", AvailableBlendFactor.SrcAlpha, AvailableBlendFactor.One ),}; - - [SerializeField] - private bool m_enabled = false; - - // Blend Factor - // RGB - [SerializeField] - private int m_currentIndex = 0; - - - [SerializeField] - private InlineProperty m_sourceFactorRGB = new InlineProperty( 0 ); - - [SerializeField] - private InlineProperty m_destFactorRGB = new InlineProperty( 0 ); - - // Alpha - [SerializeField] - private int m_currentAlphaIndex = 0; - - [SerializeField] - private InlineProperty m_sourceFactorAlpha = new InlineProperty( 0 ); - - [SerializeField] - private InlineProperty m_destFactorAlpha = new InlineProperty( 0 ); - - //Blend Ops - [SerializeField] - private bool m_blendOpEnabled = false; - - [SerializeField] - private InlineProperty m_blendOpRGB = new InlineProperty( 0 ); - - [SerializeField] - private InlineProperty m_blendOpAlpha = new InlineProperty( 0 ); - - public BlendOpsHelper() - { - m_commonBlendTypesArr = new string[ m_commonBlendTypes.Count ]; - for( int i = 0; i < m_commonBlendTypesArr.Length; i++ ) - { - m_commonBlendTypesArr[ i ] = m_commonBlendTypes[ i ].Name; - } - } - - public void Draw( UndoParentNode owner, bool customBlendAvailable ) - { - m_enabled = customBlendAvailable; - - // RGB - EditorGUI.BeginChangeCheck(); - m_currentIndex = owner.EditorGUILayoutPopup( BlendModesRGBStr, m_currentIndex, m_commonBlendTypesArr ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_currentIndex > 1 ) - { - m_sourceFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].SourceFactor; - m_sourceFactorRGB.SetInlineNodeValue(); - - m_destFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].DestFactor; - m_destFactorRGB.SetInlineNodeValue(); - } - } - EditorGUI.BeginDisabledGroup( m_currentIndex == 0 ); - - EditorGUI.BeginChangeCheck(); - float cached = EditorGUIUtility.labelWidth; - EditorGUIUtility.labelWidth = 40; - - EditorGUILayout.BeginHorizontal(); - AvailableBlendFactor tempCast = (AvailableBlendFactor)m_sourceFactorRGB.IntValue; - m_sourceFactorRGB.CustomDrawer( ref owner, ( x ) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( SourceFactorStr, tempCast ); }, SourceFactorStr ); - m_sourceFactorRGB.IntValue = (int)tempCast; - EditorGUI.indentLevel--; - EditorGUIUtility.labelWidth = 25; - tempCast = (AvailableBlendFactor)m_destFactorRGB.IntValue; - m_destFactorRGB.CustomDrawer( ref owner, ( x ) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( DstFactorStr, tempCast ); }, DstFactorStr ); - m_destFactorRGB.IntValue = (int)tempCast; - EditorGUI.indentLevel++; - EditorGUILayout.EndHorizontal(); - - EditorGUIUtility.labelWidth = cached; - if( EditorGUI.EndChangeCheck() ) - { - CheckRGBIndex(); - } - - // Both these tests should be removed on a later stage - // ASE v154dev004 changed AvailableBlendOps.OFF value from -1 to 0 - // If importing the new package into an already opened ASE window makes - // hotcode to preserve the -1 value on these variables - if( m_blendOpRGB.FloatValue < 0 ) - m_blendOpRGB.FloatValue = 0; - - if( m_blendOpAlpha.FloatValue < 0 ) - m_blendOpAlpha.FloatValue = 0; - - EditorGUI.BeginChangeCheck(); - //AvailableBlendOps tempOpCast = (AvailableBlendOps)m_blendOpRGB.IntValue; - m_blendOpRGB.CustomDrawer( ref owner, ( x ) => { m_blendOpRGB.IntValue = x.EditorGUILayoutPopup( BlendOpsRGBStr, m_blendOpRGB.IntValue, BlendOpsLabels ); }, BlendOpsRGBStr ); - //m_blendOpRGB.IntValue = (int)tempOpCast; - if( EditorGUI.EndChangeCheck() ) - { - m_blendOpEnabled = ( !m_blendOpRGB.Active && m_blendOpRGB.IntValue > -1 ) || ( m_blendOpRGB.Active && m_blendOpRGB.NodeId > -1 );//AvailableBlendOps.OFF; - m_blendOpRGB.SetInlineNodeValue(); - } - - EditorGUI.EndDisabledGroup(); - - // Alpha - EditorGUILayout.Separator(); - - EditorGUI.BeginChangeCheck(); - m_currentAlphaIndex = owner.EditorGUILayoutPopup( BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_currentAlphaIndex > 0 ) - { - m_sourceFactorAlpha.IntValue = (int)m_commonBlendTypes[ m_currentAlphaIndex ].SourceFactor; - m_sourceFactorAlpha.SetInlineNodeValue(); - - m_destFactorAlpha.IntValue = (int)m_commonBlendTypes[ m_currentAlphaIndex ].DestFactor; - m_destFactorAlpha.SetInlineNodeValue(); - } - } - EditorGUI.BeginDisabledGroup( m_currentAlphaIndex == 0 ); - - EditorGUI.BeginChangeCheck(); - cached = EditorGUIUtility.labelWidth; - EditorGUIUtility.labelWidth = 40; - EditorGUILayout.BeginHorizontal(); - tempCast = (AvailableBlendFactor)m_sourceFactorAlpha.IntValue; - m_sourceFactorAlpha.CustomDrawer( ref owner, ( x ) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( SourceFactorStr, tempCast ); }, SourceFactorStr ); - m_sourceFactorAlpha.IntValue = (int)tempCast; - EditorGUI.indentLevel--; - EditorGUIUtility.labelWidth = 25; - tempCast = (AvailableBlendFactor)m_destFactorAlpha.IntValue; - m_destFactorAlpha.CustomDrawer( ref owner, ( x ) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( DstFactorStr, tempCast ); }, DstFactorStr ); - m_destFactorAlpha.IntValue = (int)tempCast; - EditorGUI.indentLevel++; - EditorGUILayout.EndHorizontal(); - EditorGUIUtility.labelWidth = cached; - - if( EditorGUI.EndChangeCheck() ) - { - CheckAlphaIndex(); - } - EditorGUI.BeginChangeCheck(); - //tempOpCast = (AvailableBlendOps)m_blendOpAlpha.IntValue; - m_blendOpAlpha.CustomDrawer( ref owner, ( x ) => { m_blendOpAlpha.IntValue = x.EditorGUILayoutPopup( BlendOpsAlphaStr, m_blendOpAlpha.IntValue, BlendOpsLabels ); }, BlendOpsAlphaStr ); - //m_blendOpAlpha.IntValue = (int)tempOpCast; - if( EditorGUI.EndChangeCheck() ) - { - m_blendOpAlpha.SetInlineNodeValue(); - } - EditorGUI.EndDisabledGroup(); - EditorGUILayout.Separator(); - } - - void CheckRGBIndex() - { - int count = m_commonBlendTypes.Count; - m_currentIndex = 1; - for( int i = 1; i < count; i++ ) - { - if( m_commonBlendTypes[ i ].SourceFactor == (AvailableBlendFactor)m_sourceFactorRGB.IntValue && m_commonBlendTypes[ i ].DestFactor == (AvailableBlendFactor)m_destFactorRGB.IntValue ) - { - m_currentIndex = i; - return; - } - } - - } - - void CheckAlphaIndex() - { - int count = m_commonBlendTypes.Count; - m_currentAlphaIndex = 1; - for( int i = 1; i < count; i++ ) - { - if( m_commonBlendTypes[ i ].SourceFactor == (AvailableBlendFactor)m_sourceFactorAlpha.IntValue && m_commonBlendTypes[ i ].DestFactor == (AvailableBlendFactor)m_destFactorAlpha.IntValue ) - { - m_currentAlphaIndex = i; - if( m_currentAlphaIndex > 0 && m_currentIndex == 0 ) - m_currentIndex = 1; - return; - } - } - - if( m_currentAlphaIndex > 0 && m_currentIndex == 0 ) - m_currentIndex = 1; - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_currentIndex = Convert.ToInt32( nodeParams[ index++ ] ); - if( UIUtils.CurrentShaderVersion() > 15103 ) - { - m_sourceFactorRGB.ReadFromString( ref index, ref nodeParams ); - m_destFactorRGB.ReadFromString( ref index, ref nodeParams ); - } - else - { - m_sourceFactorRGB.IntValue = (int)(AvailableBlendFactor)Enum.Parse( typeof( AvailableBlendFactor ), nodeParams[ index++ ] ); - m_destFactorRGB.IntValue = (int)(AvailableBlendFactor)Enum.Parse( typeof( AvailableBlendFactor ), nodeParams[ index++ ] ); - } - - m_currentAlphaIndex = Convert.ToInt32( nodeParams[ index++ ] ); - if( UIUtils.CurrentShaderVersion() > 15103 ) - { - m_sourceFactorAlpha.ReadFromString( ref index, ref nodeParams ); - m_destFactorAlpha.ReadFromString( ref index, ref nodeParams ); - - m_blendOpRGB.ReadFromString( ref index, ref nodeParams ); - m_blendOpAlpha.ReadFromString( ref index, ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 15404 ) - { - // Now BlendOps enum starts at 0 and not -1 - m_blendOpRGB.FloatValue += 1; - m_blendOpAlpha.FloatValue += 1; - } - } - else - { - m_sourceFactorAlpha.IntValue = (int)(AvailableBlendFactor)Enum.Parse( typeof( AvailableBlendFactor ), nodeParams[ index++ ] ); - m_destFactorAlpha.IntValue = (int)(AvailableBlendFactor)Enum.Parse( typeof( AvailableBlendFactor ), nodeParams[ index++ ] ); - m_blendOpRGB.IntValue = (int)(AvailableBlendOps)Enum.Parse( typeof( AvailableBlendOps ), nodeParams[ index++ ] ); - m_blendOpAlpha.IntValue = (int)(AvailableBlendOps)Enum.Parse( typeof( AvailableBlendOps ), nodeParams[ index++ ] ); - } - - m_enabled = ( m_currentIndex > 0 || m_currentAlphaIndex > 0 ); - m_blendOpEnabled = ( !m_blendOpRGB.Active && m_blendOpRGB.IntValue > -1 ) || ( m_blendOpRGB.Active && m_blendOpRGB.NodeId > -1 ); - } - - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentIndex ); - m_sourceFactorRGB.WriteToString( ref nodeInfo ); - m_destFactorRGB.WriteToString( ref nodeInfo ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentAlphaIndex ); - m_sourceFactorAlpha.WriteToString( ref nodeInfo ); - m_destFactorAlpha.WriteToString( ref nodeInfo ); - - m_blendOpRGB.WriteToString( ref nodeInfo ); - m_blendOpAlpha.WriteToString( ref nodeInfo ); - } - - public void SetBlendOpsFromBlendMode( AlphaMode mode, bool customBlendAvailable ) - { - switch( mode ) - { - case AlphaMode.Transparent: - m_currentIndex = 2; - m_sourceFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].SourceFactor; - m_destFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].DestFactor; - break; - case AlphaMode.Masked: - case AlphaMode.Translucent: - m_currentIndex = 0; - break; - case AlphaMode.Premultiply: - m_currentIndex = 3; - m_sourceFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].SourceFactor; - m_destFactorRGB.IntValue = (int)m_commonBlendTypes[ m_currentIndex ].DestFactor; - break; - } - m_enabled = customBlendAvailable; - } - - public string CreateBlendOps() - { - - string result = "\t\t" + CurrentBlendFactor + "\n"; - if( m_blendOpEnabled ) - { - result += "\t\t" + CurrentBlendOp + "\n"; - } - return result; - } - - public string CurrentBlendRGB { get { return m_commonBlendTypes[ m_currentIndex ].Name; } } - - public string CurrentBlendFactorSingle { get { return string.Format( SingleBlendFactorStr, m_sourceFactorRGB.GetValueOrProperty( ( (AvailableBlendFactor)m_sourceFactorRGB.IntValue ).ToString() ), m_destFactorRGB.GetValueOrProperty( ( (AvailableBlendFactor)m_destFactorRGB.IntValue ).ToString() ) ); } } - //public string CurrentBlendFactorSingleAlpha { get { return string.Format(SeparateBlendFactorStr, m_sourceFactorRGB, m_destFactorRGB, m_sourceFactorAlpha, m_destFactorAlpha); } } - public string CurrentBlendFactorSeparate - { - get - { - string src = ( m_currentIndex > 0 ? m_sourceFactorRGB.GetValueOrProperty( ( (AvailableBlendFactor)m_sourceFactorRGB.IntValue ).ToString() ) : AvailableBlendFactor.One.ToString() ); - string dst = ( m_currentIndex > 0 ? m_destFactorRGB.GetValueOrProperty( ( (AvailableBlendFactor)m_destFactorRGB.IntValue ).ToString() ) : AvailableBlendFactor.Zero.ToString() ); - string srca = m_sourceFactorAlpha.GetValueOrProperty( ( (AvailableBlendFactor)m_sourceFactorAlpha.IntValue ).ToString() ); - string dsta = m_destFactorAlpha.GetValueOrProperty( ( (AvailableBlendFactor)m_destFactorAlpha.IntValue ).ToString() ); - return string.Format( SeparateBlendFactorStr, src, dst, srca, dsta ); - } - } - public string CurrentBlendFactor { get { return ( ( m_currentAlphaIndex > 0 ) ? CurrentBlendFactorSeparate : CurrentBlendFactorSingle ); } } - - public string CurrentBlendOpSingle - { - get - { - string value = m_blendOpRGB.GetValueOrProperty( ( (AvailableBlendOps)m_blendOpRGB.IntValue ).ToString() ); - if( value.Equals( ( AvailableBlendOps.OFF ).ToString() ) ) - return string.Empty; - - return string.Format( SingleBlendOpStr, value ); - } - } - public string CurrentBlendOpSeparate - { - get - { - string rgbValue = m_blendOpRGB.GetValueOrProperty( ( (AvailableBlendOps)m_blendOpRGB.IntValue ).ToString() ); - - if( rgbValue.Equals( ( AvailableBlendOps.OFF ).ToString() )) - rgbValue = "Add"; - - string alphaValue = m_blendOpAlpha.GetValueOrProperty( ( (AvailableBlendOps)m_blendOpAlpha.IntValue ).ToString() ); - return string.Format( SeparateBlendOpStr, ( m_currentIndex > 0 ? rgbValue : AvailableBlendOps.Add.ToString() ), alphaValue ); - } - } - public string CurrentBlendOp { get { return ( ( m_currentAlphaIndex > 0 && m_blendOpAlpha.GetValueOrProperty( ( (AvailableBlendOps)m_blendOpAlpha.IntValue ).ToString() ) != AvailableBlendOps.OFF.ToString() ) ? CurrentBlendOpSeparate : CurrentBlendOpSingle ); } } - - public bool Active { get { return m_enabled && ( m_currentIndex > 0 || m_currentAlphaIndex > 0 ); } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs.meta deleted file mode 100644 index 95ea7b51..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/BlendOpsHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8b59649a5f829e24cb4de8c1a715f8b4 -timeCreated: 1485530925 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs deleted file mode 100644 index 5245c9f4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -namespace AmplifyShaderEditor -{ - [System.Serializable] - public class CodeGenerationData - { - [SerializeField] - public bool IsActive; - [SerializeField] - public string Name; - [SerializeField] - public string Value; - - public CodeGenerationData( string name, string value ) - { - IsActive = false; - Name = name; - Value = value; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs.meta deleted file mode 100644 index 2c5d759e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CodeGenerationData.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7a47d8101acb2e94d95016b69a1c2e41 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs deleted file mode 100644 index 2280c9f0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - class ColorMaskHelper - { - private GUIContent ColorMaskContent = new GUIContent( "Color Mask", "Sets color channel writing mask, turning all off makes the object completely invisible\nDefault: RGBA" ); - private readonly char[] m_colorMaskChar = { 'R', 'G', 'B', 'A' }; - - private GUIStyle m_leftToggleColorMask; - private GUIStyle m_middleToggleColorMask; - private GUIStyle m_rightToggleColorMask; - - - [SerializeField] - private bool[] m_colorMask = { true, true, true, true }; - - [SerializeField] - private InlineProperty m_inlineMask = new InlineProperty(); - - public void Draw( UndoParentNode owner ) - { - m_inlineMask.CustomDrawer( ref owner, DrawColorMaskControls, ColorMaskContent.text ); - } - - private void DrawColorMaskControls( UndoParentNode owner ) - { - if( m_leftToggleColorMask == null || m_leftToggleColorMask.normal.background == null ) - { - m_leftToggleColorMask = GUI.skin.GetStyle( "miniButtonLeft" ); - } - - if( m_middleToggleColorMask == null || m_middleToggleColorMask.normal.background == null ) - { - m_middleToggleColorMask = GUI.skin.GetStyle( "miniButtonMid" ); - } - - if( m_rightToggleColorMask == null || m_rightToggleColorMask.normal.background == null ) - { - m_rightToggleColorMask = GUI.skin.GetStyle( "miniButtonRight" ); - } - - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField( ColorMaskContent, GUILayout.Width( 90 ) ); - - m_colorMask[ 0 ] = owner.GUILayoutToggle( m_colorMask[ 0 ], "R", m_leftToggleColorMask ); - m_colorMask[ 1 ] = owner.GUILayoutToggle( m_colorMask[ 1 ], "G", m_middleToggleColorMask ); - m_colorMask[ 2 ] = owner.GUILayoutToggle( m_colorMask[ 2 ], "B", m_middleToggleColorMask ); - m_colorMask[ 3 ] = owner.GUILayoutToggle( m_colorMask[ 3 ], "A", m_rightToggleColorMask ); - - EditorGUILayout.EndHorizontal(); - } - - public void BuildColorMask( ref string ShaderBody, bool customBlendAvailable ) - { - int count = 0; - string colorMask = string.Empty; - for( int i = 0; i < m_colorMask.Length; i++ ) - { - if( m_colorMask[ i ] ) - { - count++; - colorMask += m_colorMaskChar[ i ]; - } - } - - if( ( count != m_colorMask.Length && customBlendAvailable ) || m_inlineMask.Active ) - { - MasterNode.AddRenderState( ref ShaderBody, "ColorMask", m_inlineMask.GetValueOrProperty( ( ( count == 0 ) ? "0" : colorMask ) ) ); - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - for( int i = 0; i < m_colorMask.Length; i++ ) - { - m_colorMask[ i ] = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 14501 ) - m_inlineMask.ReadFromString( ref index, ref nodeParams ); - } - - public void WriteToString( ref string nodeInfo ) - { - for( int i = 0; i < m_colorMask.Length; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_colorMask[ i ] ); - } - - m_inlineMask.WriteToString( ref nodeInfo ); - } - - public void Destroy() - { - m_leftToggleColorMask = null; - m_middleToggleColorMask = null; - m_rightToggleColorMask = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs.meta deleted file mode 100644 index 69c24b06..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ColorMaskHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bf65efd881afd1b4cbd2b27f3f17251b -timeCreated: 1488903773 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs deleted file mode 100644 index 11a3ee49..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs +++ /dev/null @@ -1,436 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class CustomTagData - { - private const string TagFormat = "\"{0}\"=\"{1}\""; - public string TagName; - public string TagValue; - public int TagId = -1; - public bool TagFoldout = true; - - [SerializeField] - private TemplateSpecialTags m_specialTag = TemplateSpecialTags.None; - [SerializeField] - private RenderType m_renderType = RenderType.Opaque; - [SerializeField] - private RenderQueue m_renderQueue = RenderQueue.Geometry; - [SerializeField] - private int m_renderQueueOffset = 0; - - public CustomTagData() - { - TagName = string.Empty; - TagValue = string.Empty; - m_specialTag = TemplateSpecialTags.None; - m_renderType = RenderType.Opaque; - m_renderQueue = RenderQueue.Geometry; - m_renderQueueOffset = 0; - } - - public CustomTagData( CustomTagData other ) - { - TagName = other.TagName; - TagValue = other.TagValue; - TagId = other.TagId; - TagFoldout = other.TagFoldout; - - m_specialTag = other.m_specialTag; - m_renderType = other.m_renderType; - m_renderQueue = other.m_renderQueue; - m_renderQueueOffset = other.m_renderQueueOffset; - } - - public void SetTagValue( params string[] value ) - { - TagValue = value[ 0 ]; - switch( m_specialTag ) - { - case TemplateSpecialTags.RenderType: - { - if( !TemplateHelperFunctions.StringToRenderType.TryGetValue( value[ 0 ], out m_renderType ) ) - { - m_renderType = RenderType.Custom; - TagValue = value[ 0 ]; - } - } - break; - case TemplateSpecialTags.Queue: - { - if( value.Length == 2 ) - { - m_renderQueue = TemplateHelperFunctions.StringToRenderQueue[ value[ 0 ] ]; - int.TryParse( value[ 1 ], out m_renderQueueOffset ); - } - else - { - int indexPlus = value[ 0 ].IndexOf( '+' ); - if( indexPlus > 0 ) - { - string[] args = value[ 0 ].Split( '+' ); - m_renderQueue = TemplateHelperFunctions.StringToRenderQueue[ args[ 0 ] ]; - int.TryParse( args[ 1 ], out m_renderQueueOffset ); - } - else - { - int indexMinus = value[ 0 ].IndexOf( '-' ); - if( indexMinus > 0 ) - { - string[] args = value[ 0 ].Split( '-' ); - m_renderQueue = TemplateHelperFunctions.StringToRenderQueue[ args[ 0 ] ]; - int.TryParse( args[ 1 ], out m_renderQueueOffset ); - m_renderQueueOffset *= -1; - } - else - { - m_renderQueue = TemplateHelperFunctions.StringToRenderQueue[ value[ 0 ] ]; - m_renderQueueOffset = 0; - } - } - } - BuildQueueTagValue(); - } - break; - - } - } - - void CheckSpecialTag() - { - if( TagName.Equals( Constants.RenderTypeHelperStr ) ) - { - m_specialTag = TemplateSpecialTags.RenderType; - if( !TemplateHelperFunctions.StringToRenderType.TryGetValue( TagValue, out m_renderType )) - { - m_renderType = RenderType.Custom; - } - } - else if( TagName.Equals( Constants.RenderQueueHelperStr ) ) - { - m_specialTag = TemplateSpecialTags.Queue; - SetTagValue( TagValue ); - } - else - { - m_specialTag = TemplateSpecialTags.None; - } - } - - public CustomTagData( string name, string value, int id ) - { - TagName = name; - TagValue = value; - TagId = id; - CheckSpecialTag(); - } - - //Used on Template based shaders loading - public CustomTagData( string data, int id ) - { - TagId = id; - string[] arr = data.Split( IOUtils.VALUE_SEPARATOR ); - if( arr.Length > 1 ) - { - TagName = arr[ 0 ]; - TagValue = arr[ 1 ]; - } - - if( arr.Length > 2 ) - { - m_specialTag = (TemplateSpecialTags)Enum.Parse( typeof( TemplateSpecialTags ), arr[ 2 ] ); - switch( m_specialTag ) - { - case TemplateSpecialTags.RenderType: - { - if( !TemplateHelperFunctions.StringToRenderType.TryGetValue( TagValue, out m_renderType ) ) - { - m_renderType = RenderType.Custom; - } - } - break; - case TemplateSpecialTags.Queue: - { - if( arr.Length == 4 ) - { - m_renderQueue = (RenderQueue)Enum.Parse( typeof( RenderQueue ), TagValue ); - int.TryParse( arr[ 3 ], out m_renderQueueOffset ); - } - BuildQueueTagValue(); - } - break; - } - } - else if( UIUtils.CurrentShaderVersion() < 15600 ) - { - CheckSpecialTag(); - } - } - - //Used on Standard Surface shaders loading - public CustomTagData( string data ) - { - string[] arr = data.Split( IOUtils.VALUE_SEPARATOR ); - if( arr.Length > 1 ) - { - TagName = arr[ 0 ]; - TagValue = arr[ 1 ]; - } - } - - public override string ToString() - { - switch( m_specialTag ) - { - case TemplateSpecialTags.RenderType: - return TagName + IOUtils.VALUE_SEPARATOR + - ( RenderType != RenderType.Custom? RenderType.ToString(): TagValue ) + IOUtils.VALUE_SEPARATOR + - m_specialTag; - case TemplateSpecialTags.Queue: - return TagName + IOUtils.VALUE_SEPARATOR + - m_renderQueue.ToString() + IOUtils.VALUE_SEPARATOR + - m_specialTag + IOUtils.VALUE_SEPARATOR + - m_renderQueueOffset; - } - - return TagName + IOUtils.VALUE_SEPARATOR + TagValue; - } - - public string GenerateTag() - { - switch( m_specialTag ) - { - case TemplateSpecialTags.RenderType: - return string.Format( TagFormat, TagName, ( RenderType != RenderType.Custom ? RenderType.ToString() : TagValue ) ); - case TemplateSpecialTags.Queue: - case TemplateSpecialTags.None: - default: - return string.Format( TagFormat, TagName, TagValue ); - } - } - - public void BuildQueueTagValue() - { - TagValue = m_renderQueue.ToString(); - if( m_renderQueueOffset > 0 ) - { - TagValue += "+" + m_renderQueueOffset; - } - else if( m_renderQueueOffset < 0 ) - { - TagValue += m_renderQueueOffset; - } - } - - public TemplateSpecialTags SpecialTag - { - get { return m_specialTag; } - set - { - m_specialTag = value; - switch( value ) - { - case TemplateSpecialTags.RenderType: - { - //if( m_renderType != RenderType.Custom ) - // TagValue = m_renderType.ToString(); - } - break; - case TemplateSpecialTags.Queue: - { - BuildQueueTagValue(); - } - break; - } - } - } - - public RenderType RenderType - { - get { return m_renderType; } - set - { - m_renderType = value; - //if( m_renderType != RenderType.Custom ) - // TagValue = value.ToString(); - } - } - - public RenderQueue RenderQueue - { - get { return m_renderQueue; } - set { m_renderQueue = value; } - } - public int RenderQueueOffset - { - get { return m_renderQueueOffset; } - set { m_renderQueueOffset = value; } - } - - public bool IsValid { get { return ( !string.IsNullOrEmpty( TagValue ) && !string.IsNullOrEmpty( TagName ) ); } } - } - - [Serializable] - public class CustomTagsHelper - { - private const string CustomTagsStr = " Custom SubShader Tags"; - private const string TagNameStr = "Name"; - private const string TagValueStr = "Value"; - - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<CustomTagData> m_availableTags = new List<CustomTagData>(); - - public void Draw( ParentNode owner ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedCustomTags; - NodeUtils.DrawPropertyGroup( ref value, CustomTagsStr, DrawMainBody, DrawButtons ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedCustomTags = value; - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add tag - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableTags.Add( new CustomTagData() ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove tag - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_availableTags.Count > 0 ) - { - m_availableTags.RemoveAt( m_availableTags.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - int itemCount = m_availableTags.Count; - - if( itemCount == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - - int markedToDelete = -1; - float originalLabelWidth = EditorGUIUtility.labelWidth; - for( int i = 0; i < itemCount; i++ ) - { - m_availableTags[ i ].TagFoldout = m_currentOwner.EditorGUILayoutFoldout( m_availableTags[ i ].TagFoldout, string.Format( "[{0}] - {1}", i, m_availableTags[ i ].TagName ) ); - if( m_availableTags[ i ].TagFoldout ) - { - EditorGUI.indentLevel += 1; - EditorGUIUtility.labelWidth = 70; - //Tag Name - EditorGUI.BeginChangeCheck(); - m_availableTags[ i ].TagName = EditorGUILayout.TextField( TagNameStr, m_availableTags[ i ].TagName ); - if( EditorGUI.EndChangeCheck() ) - { - m_availableTags[ i ].TagName = UIUtils.RemoveShaderInvalidCharacters( m_availableTags[ i ].TagName ); - } - - //Tag Value - EditorGUI.BeginChangeCheck(); - m_availableTags[ i ].TagValue = EditorGUILayout.TextField( TagValueStr, m_availableTags[ i ].TagValue ); - if( EditorGUI.EndChangeCheck() ) - { - m_availableTags[ i ].TagValue = UIUtils.RemoveShaderInvalidCharacters( m_availableTags[ i ].TagValue ); - } - - EditorGUIUtility.labelWidth = originalLabelWidth; - - EditorGUILayout.BeginHorizontal(); - { - GUILayout.Label( " " ); - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableTags.Insert( i + 1, new CustomTagData() ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - - EditorGUI.indentLevel -= 1; - } - - } - if( markedToDelete > -1 ) - { - if( m_availableTags.Count > markedToDelete ) - { - m_availableTags.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - } - - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_availableTags.Add( new CustomTagData( nodeParams[ index++ ] ) ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - int tagsCount = m_availableTags.Count; - IOUtils.AddFieldValueToString( ref nodeInfo, tagsCount ); - for( int i = 0; i < tagsCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_availableTags[ i ].ToString() ); - } - } - - public string GenerateCustomTags() - { - int tagsCount = m_availableTags.Count; - string result = tagsCount == 0 ? string.Empty : " "; - - for( int i = 0; i < tagsCount; i++ ) - { - if( m_availableTags[ i ].IsValid ) - { - result += m_availableTags[ i ].GenerateTag(); - if( i < tagsCount - 1 ) - { - result += " "; - } - } - } - return result; - } - - public void Destroy() - { - m_availableTags.Clear(); - m_availableTags = null; - m_currentOwner = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs.meta deleted file mode 100644 index de6b426c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/CustomTagsHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5ed32be99aefda24483c9e3499a5cd23 -timeCreated: 1500400244 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs deleted file mode 100644 index 915f173c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class DependenciesData - { - private string DependencyFormat = "Dependency \"{0}\"=\"{1}\"\n"; - public string DependencyName; - public string DependencyValue; - public bool DependencyFoldout = true; - - public DependenciesData() - { - DependencyName = string.Empty; - DependencyValue = string.Empty; - } - - public DependenciesData( string data ) - { - string[] arr = data.Split( IOUtils.VALUE_SEPARATOR ); - if( arr.Length > 1 ) - { - DependencyName = arr[ 0 ]; - DependencyValue = arr[ 1 ]; - } - } - - public override string ToString() - { - return DependencyName + IOUtils.VALUE_SEPARATOR + DependencyValue; - } - - public string GenerateDependency() - { - return string.Format( DependencyFormat, DependencyName, DependencyValue ); - } - - public bool IsValid { get { return ( !string.IsNullOrEmpty( DependencyValue ) && !string.IsNullOrEmpty( DependencyName ) ); } } - } - - [Serializable] - public class DependenciesHelper - { - private const string CustomDependencysStr = " Dependencies"; - private const string DependencyNameStr = "Name"; - private const string DependencyValueStr = "Value"; - - private const float ShaderKeywordButtonLayoutWidth = 15; - private ParentNode m_currentOwner; - - [SerializeField] - private List<DependenciesData> m_availableDependencies = new List<DependenciesData>(); - - public void Draw( ParentNode owner, bool isNested = false ) - { - m_currentOwner = owner; - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDependencies; - if( isNested ) - { - NodeUtils.DrawNestedPropertyGroup( ref value, CustomDependencysStr, DrawMainBody, DrawButtons ); - } - else - { - NodeUtils.DrawPropertyGroup( ref value, CustomDependencysStr, DrawMainBody, DrawButtons ); - } - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDependencies = value; - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add Dependency - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableDependencies.Add( new DependenciesData() ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove Dependency - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_availableDependencies.Count > 0 ) - { - m_availableDependencies.RemoveAt( m_availableDependencies.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - } - - void DrawMainBody() - { - EditorGUILayout.Separator(); - int itemCount = m_availableDependencies.Count; - - if( itemCount == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - - int markedToDelete = -1; - float originalLabelWidth = EditorGUIUtility.labelWidth; - for( int i = 0; i < itemCount; i++ ) - { - m_availableDependencies[ i ].DependencyFoldout = m_currentOwner.EditorGUILayoutFoldout( m_availableDependencies[ i ].DependencyFoldout, string.Format( "[{0}] - {1}", i, m_availableDependencies[ i ].DependencyName ) ); - if( m_availableDependencies[ i ].DependencyFoldout ) - { - EditorGUI.indentLevel += 1; - EditorGUIUtility.labelWidth = 70; - //Dependency Name - EditorGUI.BeginChangeCheck(); - m_availableDependencies[ i ].DependencyName = EditorGUILayout.TextField( DependencyNameStr, m_availableDependencies[ i ].DependencyName ); - if( EditorGUI.EndChangeCheck() ) - { - m_availableDependencies[ i ].DependencyName = UIUtils.RemoveShaderInvalidCharacters( m_availableDependencies[ i ].DependencyName ); - } - - //Dependency Value - EditorGUI.BeginChangeCheck(); - m_availableDependencies[ i ].DependencyValue = EditorGUILayout.TextField( DependencyValueStr, m_availableDependencies[ i ].DependencyValue ); - if( EditorGUI.EndChangeCheck() ) - { - m_availableDependencies[ i ].DependencyValue = UIUtils.RemoveShaderInvalidCharacters( m_availableDependencies[ i ].DependencyValue ); - } - - EditorGUIUtility.labelWidth = originalLabelWidth; - - EditorGUILayout.BeginHorizontal(); - { - GUILayout.Label( " " ); - // Add new port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_availableDependencies.Insert( i + 1, new DependenciesData() ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( m_currentOwner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - - EditorGUI.indentLevel -= 1; - } - - } - if( markedToDelete > -1 ) - { - if( m_availableDependencies.Count > markedToDelete ) - { - m_availableDependencies.RemoveAt( markedToDelete ); - EditorGUI.FocusTextInControl( null ); - } - } - EditorGUILayout.Separator(); - } - - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - m_availableDependencies.Add( new DependenciesData( nodeParams[ index++ ] ) ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - int dependencyCount = m_availableDependencies.Count; - IOUtils.AddFieldValueToString( ref nodeInfo, dependencyCount ); - for( int i = 0; i < dependencyCount; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_availableDependencies[ i ].ToString() ); - } - } - - public string GenerateDependencies() - { - int dependencyCount = m_availableDependencies.Count; - string result = dependencyCount == 0 ? string.Empty : "\n"; - UIUtils.ShaderIndentLevel++; - for( int i = 0; i < dependencyCount; i++ ) - { - if( m_availableDependencies[ i ].IsValid ) - { - result += UIUtils.ShaderIndentTabs + m_availableDependencies[ i ].GenerateDependency(); - } - } - UIUtils.ShaderIndentLevel--; - return result; - } - - public void Destroy() - { - m_availableDependencies.Clear(); - m_availableDependencies = null; - m_currentOwner = null; - } - - public bool HasDependencies { get { return m_availableDependencies.Count > 0; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs.meta deleted file mode 100644 index 92e4d819..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/DependenciesHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2daff2983fe91ac43953017a8be984a7 -timeCreated: 1512404972 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs deleted file mode 100644 index 6d006a96..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class FallbackPickerHelper : ScriptableObject - { - private const string FallbackFormat = "Fallback \"{0}\""; - private const string FallbackShaderStr = "Fallback"; - private const string ShaderPoputContext = "CONTEXT/ShaderPopup"; - - private Material m_dummyMaterial; - private MenuCommand m_dummyCommand; - - [SerializeField] - private string m_fallbackShader = string.Empty; - - public void Init() - { - hideFlags = HideFlags.HideAndDontSave; - m_dummyMaterial = null; - m_dummyCommand = null; - } - - public void Draw( ParentNode owner ) - { - EditorGUILayout.BeginHorizontal(); - m_fallbackShader = owner.EditorGUILayoutTextField( FallbackShaderStr, m_fallbackShader ); - if ( GUILayout.Button( string.Empty, UIUtils.InspectorPopdropdownFallback, GUILayout.Width( 17 ), GUILayout.Height( 19 ) ) ) - { - EditorGUI.FocusTextInControl( null ); - GUI.FocusControl( null ); - DisplayShaderContext( owner, GUILayoutUtility.GetRect( GUIContent.none, EditorStyles.popup ) ); - } - EditorGUILayout.EndHorizontal(); - } - - private void DisplayShaderContext( ParentNode node, Rect r ) - { - if ( m_dummyCommand == null ) - m_dummyCommand = new MenuCommand( this, 0 ); - - if ( m_dummyMaterial == null ) - m_dummyMaterial = new Material( Shader.Find( "Hidden/ASESShaderSelectorUnlit" ) ); - -#pragma warning disable 0618 - UnityEditorInternal.InternalEditorUtility.SetupShaderMenu( m_dummyMaterial ); -#pragma warning restore 0618 - EditorUtility.DisplayPopupMenu( r, ShaderPoputContext, m_dummyCommand ); - } - - private void OnSelectedShaderPopup( string command, Shader shader ) - { - if ( shader != null ) - { - UIUtils.MarkUndoAction(); - Undo.RecordObject( this, "Selected fallback shader" ); - m_fallbackShader = shader.name; - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_fallbackShader = nodeParams[ index++ ]; - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_fallbackShader ); - } - - public void Destroy() - { - GameObject.DestroyImmediate( m_dummyMaterial ); - m_dummyMaterial = null; - m_dummyCommand = null; - } - - public string TabbedFallbackShader - { - get - { - if( string.IsNullOrEmpty( m_fallbackShader ) ) - return string.Empty; - - return "\t" + string.Format( FallbackFormat, m_fallbackShader ) + "\n"; - } - } - - public string FallbackShader - { - get - { - if( string.IsNullOrEmpty( m_fallbackShader ) ) - return string.Empty; - - return string.Format( FallbackFormat, m_fallbackShader ); - } - } - - public string RawFallbackShader - { - get - { - return m_fallbackShader; - } - set - { - m_fallbackShader = value; - } - } - - - public bool Active { get { return !string.IsNullOrEmpty( m_fallbackShader ); } } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs.meta deleted file mode 100644 index 2336aa83..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FallbackPickerHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cd5a03cee1255ba438e2062d215b70b6 -timeCreated: 1490378537 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs deleted file mode 100644 index a253a5a8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs +++ /dev/null @@ -1,523 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Function Input", "Functions", "Function Input adds an input port to the shader function", NodeAvailabilityFlags = (int)NodeAvailability.ShaderFunction )] - public sealed class FunctionInput : ParentNode - { - private const string InputTypeStr = "Input Type"; - private readonly string[] m_inputValueTypes ={ "Int", - "Float", - "Vector2", - "Vector3", - "Vector4", - "Color", - "Matrix 3x3", - "Matrix 4x4", - "Sampler 1D", - "Sampler 2D", - "Sampler 3D", - "Sampler Cube"}; - - [SerializeField] - private int m_selectedInputTypeInt = 1; - - private WirePortDataType m_selectedInputType = WirePortDataType.FLOAT; - - [SerializeField] - private FunctionNode m_functionNode; - - [SerializeField] - private string m_inputName = "Input"; - - [SerializeField] - private bool m_autoCast = false; - - [SerializeField] - private int m_orderIndex = -1; - - private int m_typeId = -1; - - public bool m_ignoreConnection = false; - - public delegate string PortGeneration( ref MasterNodeDataCollector dataCollector, int index, ParentGraph graph ); - public PortGeneration OnPortGeneration = null; - - //Title editing - [SerializeField] - private string m_uniqueName; - - private bool m_isEditing; - private bool m_stopEditing; - private bool m_startEditing; - private double m_clickTime; - private double m_doubleClickTime = 0.3; - private Rect m_titleClickArea; - private bool m_showTitleWhenNotEditing = true; - - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].AutoDrawInternalData = true; - //m_inputPorts[ 0 ].Visible = false; - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_autoWrapProperties = true; - m_textLabelWidth = 100; - SetTitleText( m_inputName ); - UpdatePorts(); - SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - m_previewShaderGUID = "04bc8e7b317dccb4d8da601680dd8140"; - } - - public override void SetPreviewInputs() - { - if( Fnode == null ) - { - m_ignoreConnection = false; - CheckSpherePreview(); - } - else - { - var input = Fnode.GetInput( this ); - if( input != null && ( !InputPorts[ 0 ].IsConnected || input.IsConnected ) ) - { - m_ignoreConnection = true; - InputPorts[ 0 ].PreparePortCacheID(); - Fnode.SetPreviewInput( input ); - if( input.ExternalReferences.Count > 0 ) - { - SpherePreview = Fnode.ContainerGraph.GetNode( input.ExternalReferences[ 0 ].NodeId ).SpherePreview; - } - else - { - SpherePreview = false; - } - PreviewMaterial.SetTexture( InputPorts[ 0 ].CachedPropertyId, input.InputPreviewTexture( Fnode.ContainerGraph ) ); - } - else - { - m_ignoreConnection = false; - CheckSpherePreview(); - } - } - - if( !m_ignoreConnection ) - base.SetPreviewInputs(); - - for( int i = 0; i < OutputPorts[ 0 ].ExternalReferences.Count; i++ ) - { - ContainerGraph.GetNode( OutputPorts[ 0 ].ExternalReferences[ i ].NodeId ).OnNodeChange(); - } - - if( m_typeId == -1 ) - m_typeId = Shader.PropertyToID( "_Type" ); - - if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT || m_inputPorts[ 0 ].DataType == WirePortDataType.INT ) - PreviewMaterial.SetInt( m_typeId, 1 ); - else if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT2 ) - PreviewMaterial.SetInt( m_typeId, 2 ); - else if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3 ) - PreviewMaterial.SetInt( m_typeId, 3 ); - else - PreviewMaterial.SetInt( m_typeId, 0 ); - - } - - public override bool RecursivePreviewUpdate( Dictionary<string, bool> duplicatesDict = null ) - { - if( duplicatesDict == null ) - { - duplicatesDict = ContainerGraph.ParentWindow.VisitedChanged; - } - - for( int i = 0; i < InputPorts.Count; i++ ) - { - ParentNode outNode = null; - if( Fnode != null ) - { - var input = Fnode.GetInput( this ); - if( input.ExternalReferences.Count > 0 ) - { - outNode = Fnode.ContainerGraph.GetNode( input.ExternalReferences[ 0 ].NodeId ); - } - else if( InputPorts[ i ].ExternalReferences.Count > 0 ) - { - outNode = ContainerGraph.GetNode( InputPorts[ i ].ExternalReferences[ 0 ].NodeId ); - } - } - else - { - if( InputPorts[ i ].ExternalReferences.Count > 0 ) - { - outNode = ContainerGraph.GetNode( InputPorts[ i ].ExternalReferences[ 0 ].NodeId ); - } - } - if( outNode != null ) - { - if( !duplicatesDict.ContainsKey( outNode.OutputId ) ) - { - bool result = outNode.RecursivePreviewUpdate(); - if( result ) - PreviewIsDirty = true; - } - else if( duplicatesDict[ outNode.OutputId ] ) - { - PreviewIsDirty = true; - } - } - } - - bool needsUpdate = PreviewIsDirty; - RenderNodePreview(); - if( !duplicatesDict.ContainsKey( OutputId ) ) - duplicatesDict.Add( OutputId, needsUpdate ); - return needsUpdate; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterFunctionInputNode( this ); - if( m_nodeAttribs != null ) - m_uniqueName = m_nodeAttribs.Name + UniqueId; - } - - public override void Destroy() - { - base.Destroy(); - OnPortGeneration = null; - UIUtils.UnregisterFunctionInputNode( this ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( AutoCast ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - SetIntTypeFromPort(); - UpdatePorts(); - SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - } - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - if( AutoCast ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - SetIntTypeFromPort(); - UpdatePorts(); - SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - } - } - - public void SetIntTypeFromPort() - { - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.INT: m_selectedInputTypeInt = 0; break; - default: - case WirePortDataType.FLOAT: m_selectedInputTypeInt = 1; break; - case WirePortDataType.FLOAT2: m_selectedInputTypeInt = 2; break; - case WirePortDataType.FLOAT3: m_selectedInputTypeInt = 3; break; - case WirePortDataType.FLOAT4: m_selectedInputTypeInt = 4; break; - case WirePortDataType.COLOR: m_selectedInputTypeInt = 5; break; - case WirePortDataType.FLOAT3x3: m_selectedInputTypeInt = 6; break; - case WirePortDataType.FLOAT4x4: m_selectedInputTypeInt = 7; break; - case WirePortDataType.SAMPLER1D: m_selectedInputTypeInt = 8; break; - case WirePortDataType.SAMPLER2D: m_selectedInputTypeInt = 9; break; - case WirePortDataType.SAMPLER3D: m_selectedInputTypeInt = 10; break; - case WirePortDataType.SAMPLERCUBE: m_selectedInputTypeInt = 11; break; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - // Custom Editable Title - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( !m_isEditing && ( ( !ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains( drawInfo.MousePosition ) ) ) ) - { - if( ( EditorApplication.timeSinceStartup - m_clickTime ) < m_doubleClickTime ) - m_startEditing = true; - else - GUI.FocusControl( null ); - m_clickTime = EditorApplication.timeSinceStartup; - } - else if( m_isEditing && ( ( drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains( drawInfo.MousePosition ) ) || !EditorGUIUtility.editingTextField ) ) - { - m_stopEditing = true; - } - - if( m_isEditing || m_startEditing ) - { - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_uniqueName ); - m_inputName = EditorGUITextField( m_titleClickArea, string.Empty, m_inputName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_inputName ); - UIUtils.UpdateFunctionInputData( UniqueId, m_inputName ); - } - - if( m_startEditing ) - EditorGUI.FocusTextInControl( m_uniqueName ); - - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( m_startEditing ) - { - m_startEditing = false; - m_isEditing = true; - } - - if( m_stopEditing ) - { - m_stopEditing = false; - m_isEditing = false; - GUI.FocusControl( null ); - } - } - - - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - // RUN LAYOUT CHANGES AFTER TITLES CHANGE - base.OnNodeLayout( drawInfo ); - m_titleClickArea = m_titlePos; - m_titleClickArea.height = Constants.NODE_HEADER_HEIGHT; - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - // Fixed Title ( only renders when not editing ) - if( m_showTitleWhenNotEditing && !m_isEditing && !m_startEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( m_titleClickArea, m_content, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( currentMousePos2D.y - m_globalPosition.y > ( Constants.NODE_HEADER_HEIGHT + Constants.NODE_HEADER_EXTRA_HEIGHT ) * ContainerGraph.ParentWindow.CameraDrawInfo.InvertedZoom ) - { - ContainerGraph.ParentWindow.ParametersWindow.IsMaximized = !ContainerGraph.ParentWindow.ParametersWindow.IsMaximized; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - m_inputName = EditorGUILayoutTextField( "Name", m_inputName ); - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_inputName ); - UIUtils.UpdateFunctionInputData( UniqueId, m_inputName ); - } - EditorGUI.BeginChangeCheck(); - m_selectedInputTypeInt = EditorGUILayoutPopup( InputTypeStr, m_selectedInputTypeInt, m_inputValueTypes ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - } - - m_autoCast = EditorGUILayoutToggle( "Auto Cast", m_autoCast ); - - EditorGUILayout.Separator(); - if( !m_inputPorts[ 0 ].IsConnected && m_inputPorts[ 0 ].ValidInternalData ) - { - m_inputPorts[ 0 ].ShowInternalData( this, true, "Default Value" ); - } - - - EditorGUILayout.EndVertical(); - } - - void UpdatePorts() - { - //switch( m_inputPorts[ 0 ].DataType ) - //{ - // case WirePortDataType.INT: m_selectedInputTypeInt = 0; break; - // default: - // case WirePortDataType.FLOAT: m_selectedInputTypeInt = 1; break; - // case WirePortDataType.FLOAT2: m_selectedInputTypeInt = 2; break; - // case WirePortDataType.FLOAT3: m_selectedInputTypeInt = 3; break; - - // //case 2: m_selectedInputType = WirePortDataType.FLOAT2; break; - // //case 3: m_selectedInputType = WirePortDataType.FLOAT3; break; - // //case 4: m_selectedInputType = WirePortDataType.FLOAT4; break; - // //case 5: m_selectedInputType = WirePortDataType.COLOR; break; - // //case 6: m_selectedInputType = WirePortDataType.FLOAT3x3; break; - // //case 7: m_selectedInputType = WirePortDataType.FLOAT4x4; break; - // //case 8: m_selectedInputType = WirePortDataType.SAMPLER1D; break; - // //case 9: m_selectedInputType = WirePortDataType.SAMPLER2D; break; - // //case 10: m_selectedInputType = WirePortDataType.SAMPLER3D; break; - // //case 11: m_selectedInputType = WirePortDataType.SAMPLERCUBE; break; - //} - - switch( m_selectedInputTypeInt ) - { - case 0: m_selectedInputType = WirePortDataType.INT; break; - default: - case 1: m_selectedInputType = WirePortDataType.FLOAT; break; - case 2: m_selectedInputType = WirePortDataType.FLOAT2; break; - case 3: m_selectedInputType = WirePortDataType.FLOAT3; break; - case 4: m_selectedInputType = WirePortDataType.FLOAT4; break; - case 5: m_selectedInputType = WirePortDataType.COLOR; break; - case 6: m_selectedInputType = WirePortDataType.FLOAT3x3; break; - case 7: m_selectedInputType = WirePortDataType.FLOAT4x4; break; - case 8: m_selectedInputType = WirePortDataType.SAMPLER1D; break; - case 9: m_selectedInputType = WirePortDataType.SAMPLER2D; break; - case 10: m_selectedInputType = WirePortDataType.SAMPLER3D; break; - case 11: m_selectedInputType = WirePortDataType.SAMPLERCUBE; break; - } - - ChangeInputType( m_selectedInputType, false ); - - //This node doesn't have any restrictions but changing types should be restricted to prevent invalid connections - m_outputPorts[ 0 ].ChangeTypeWithRestrictions( m_selectedInputType, PortCreateRestriction( m_selectedInputType ) ); - m_sizeIsDirty = true; - } - - public int PortCreateRestriction( WirePortDataType dataType ) - { - int restrictions = 0; - WirePortDataType[] types = null; - switch( dataType ) - { - case WirePortDataType.OBJECT: - break; - case WirePortDataType.FLOAT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - case WirePortDataType.INT: - { - types = new WirePortDataType[] { WirePortDataType.FLOAT, WirePortDataType.FLOAT2, WirePortDataType.FLOAT3, WirePortDataType.FLOAT4, WirePortDataType.COLOR, WirePortDataType.INT, WirePortDataType.OBJECT }; - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - types = new WirePortDataType[] { WirePortDataType.FLOAT3x3, WirePortDataType.FLOAT4x4, WirePortDataType.OBJECT }; - } - break; - case WirePortDataType.SAMPLER1D: - case WirePortDataType.SAMPLER2D: - case WirePortDataType.SAMPLER3D: - case WirePortDataType.SAMPLERCUBE: - { - types = new WirePortDataType[] { WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT }; - } - break; - default: - break; - } - - if( types != null ) - { - for( int i = 0; i < types.Length; i++ ) - { - restrictions = restrictions | (int)types[ i ]; - } - } - - return restrictions; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - - string result = string.Empty; - if( OnPortGeneration != null ) - result = OnPortGeneration( ref dataCollector, m_orderIndex, ContainerGraph.ParentWindow.CustomGraph ); - else - result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - if( m_outputPorts[ outputId ].ConnectionCount > 1 ) - RegisterLocalVariable( outputId, result, ref dataCollector ); - else - m_outputPorts[ outputId ].SetLocalValue( result, dataCollector.PortCategory ); - - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedInputTypeInt ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_orderIndex ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoCast ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_inputName = GetCurrentParam( ref nodeParams ); - m_selectedInputTypeInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_autoCast = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - SetTitleText( m_inputName ); - UpdatePorts(); - SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - } - - public WirePortDataType SelectedInputType - { - get { return m_selectedInputType; } - } - - public string InputName - { - get { return m_inputName; } - } - - public int OrderIndex - { - get { return m_orderIndex; } - set { m_orderIndex = value; } - } - - public bool AutoCast - { - get { return m_autoCast; } - set { m_autoCast = value; } - } - - public FunctionNode Fnode - { - get { return m_functionNode; } - set { m_functionNode = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs.meta deleted file mode 100644 index c5aa5505..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionInput.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 64064ea01705e084cbe00a3bbeef2c3d -timeCreated: 1491927259 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs deleted file mode 100644 index de297c2e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs +++ /dev/null @@ -1,1236 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -//#define ADD_SHADER_FUNCTION_HEADERS - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Function Node", "Functions", "Function Node", KeyCode.None, false, 0, int.MaxValue, typeof( AmplifyShaderFunction ) )] - public class FunctionNode : ParentNode - { - [SerializeField] - private AmplifyShaderFunction m_function; - - [SerializeField] - private ParentGraph m_functionGraph; - - [SerializeField] - private int m_functionGraphId = -1; - - [SerializeField] - private List<FunctionInput> m_allFunctionInputs; - private Dictionary<int, FunctionInput> m_allFunctionInputsDict = new Dictionary<int, FunctionInput>(); - - [SerializeField] - private List<FunctionOutput> m_allFunctionOutputs; - private Dictionary<int, FunctionOutput> m_allFunctionOutputsDict = new Dictionary<int, FunctionOutput>(); - - [SerializeField] - private List<FunctionSwitch> m_allFunctionSwitches; - private Dictionary<int, FunctionSwitch> m_allFunctionSwitchesDict = new Dictionary<int, FunctionSwitch>(); - - [SerializeField] - private ReordenatorNode m_reordenator; - - [SerializeField] - private string m_filename; - - [SerializeField] - private string m_headerTitle = string.Empty; - - [SerializeField] - private int m_orderIndex; - - [SerializeField] - private string m_functionCheckSum; - - [SerializeField] - private string m_functionGUID = string.Empty; - - //[SerializeField] - //private List<string> m_includes = new List<string>(); - - //[SerializeField] - //private List<string> m_pragmas = new List<string>(); - - [SerializeField] - private List<AdditionalDirectiveContainer> m_directives = new List<AdditionalDirectiveContainer>(); - - private bool m_parametersFoldout = true; - [SerializeField] - private ParentGraph m_outsideGraph = null; - - [SerializeField] - private FunctionOutput m_mainPreviewNode; - - bool m_portsChanged = false; - //[SerializeField] - bool m_initialGraphDraw = false; - - private bool m_refreshIdsRequired = false; - - public string[] ReadOptionsHelper = new string[] { }; - - private bool m_lateRefresh = false; - - private Dictionary<int, bool> m_duplicatesBuffer = new Dictionary<int, bool>(); - string LastLine( string text ) - { - string[] lines = text.Replace( "\r", "" ).Split( '\n' ); - return lines[ lines.Length - 1 ]; - } - - public void CommonInit( AmplifyShaderFunction function, int uniqueId ) - { - SetBaseUniqueId( uniqueId ); - - if( function == null ) - return; - - m_refreshIdsRequired = UIUtils.IsLoading && ( UIUtils.CurrentShaderVersion() < 14004 ); - - m_function = function; - - if( Function.FunctionName.Length > 1 ) - { - SetTitleText( GraphContextMenu.AddSpacesToSentence( Function.FunctionName ) ); - } - else - { - SetTitleText( Function.FunctionName ); - } - m_tooltipText = Function.Description; - m_hasTooltipLink = false; - if( m_functionGraph == null ) - { - //m_functionGraph = new ParentGraph(); - m_functionGraph = CreateInstance<ParentGraph>(); - m_functionGraph.Init(); - m_functionGraph.ParentWindow = ContainerGraph.ParentWindow; - } - - if( string.IsNullOrEmpty( m_functionGUID ) ) - { - m_functionGUID = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_function ) ); - } - - m_functionGraphId = Mathf.Max( m_functionGraphId, ContainerGraph.ParentWindow.GraphCount ); - ContainerGraph.ParentWindow.GraphCount = m_functionGraphId + 1; - m_functionGraph.SetGraphId( m_functionGraphId ); - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - - AmplifyShaderEditorWindow.LoadFromMeta( ref m_functionGraph, ContainerGraph.ParentWindow.ContextMenuInstance, Function.FunctionInfo ); - //m_functionCheckSum = LastLine( m_function.FunctionInfo ); - m_functionCheckSum = AssetDatabase.GetAssetDependencyHash( AssetDatabase.GetAssetPath( m_function ) ).ToString(); - List<PropertyNode> propertyList = UIUtils.PropertyNodesList(); - m_allFunctionInputs = UIUtils.FunctionInputList(); - m_allFunctionOutputs = UIUtils.FunctionOutputList(); - m_allFunctionSwitches = UIUtils.FunctionSwitchList(); - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - m_allFunctionInputs.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - m_allFunctionOutputs.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - m_allFunctionSwitches.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - - int inputCount = m_allFunctionInputs.Count; - for( int i = 0; i < inputCount; i++ ) - { - if( m_refreshIdsRequired ) - { - AddInputPort( m_allFunctionInputs[ i ].SelectedInputType, false, m_allFunctionInputs[ i ].InputName ); - } - else - { - AddInputPort( m_allFunctionInputs[ i ].SelectedInputType, false, m_allFunctionInputs[ i ].InputName, -1, MasterNodePortCategory.Fragment, m_allFunctionInputs[ i ].UniqueId ); - } - InputPortSwitchRestriction( m_inputPorts[ i ] ); - - if( !m_allFunctionInputs[ i ].InputPorts[ 0 ].IsConnected ) - { - m_inputPorts[ i ].AutoDrawInternalData = true; - m_inputPorts[ i ].InternalData = m_allFunctionInputs[ i ].InputPorts[ 0 ].InternalData; - } - m_allFunctionInputs[ i ].Fnode = this; - } - - int outputCount = m_allFunctionOutputs.Count; - FunctionOutput first = null; - for( int i = 0; i < outputCount; i++ ) - { - if( i == 0 ) - first = m_allFunctionOutputs[ i ]; - - if( m_allFunctionOutputs[ i ].PreviewNode ) - { - m_mainPreviewNode = m_allFunctionOutputs[ i ]; - } - - if( m_refreshIdsRequired ) - { - AddOutputPort( m_allFunctionOutputs[ i ].AutoOutputType, m_allFunctionOutputs[ i ].OutputName ); - } - else - { - AddOutputPort( m_allFunctionOutputs[ i ].AutoOutputType, m_allFunctionOutputs[ i ].OutputName, m_allFunctionOutputs[ i ].UniqueId ); - } - OutputPortSwitchRestriction( m_outputPorts[ i ] ); - } - - // make sure to hide the ports properly - CheckPortVisibility(); - - if( m_mainPreviewNode == null ) - m_mainPreviewNode = first; - - //create reordenator to main graph - bool inside = false; - if( ContainerGraph.ParentWindow.CustomGraph != null ) - inside = true; - - if( /*hasConnectedProperties*/propertyList.Count > 0 ) - { - m_reordenator = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_reordenator.Init( "_" + Function.FunctionName, Function.FunctionName, propertyList, false ); - m_reordenator.OrderIndex = m_orderIndex; - m_reordenator.HeaderTitle = Function.FunctionName; - m_reordenator.IsInside = inside; - } - - if( m_reordenator != null ) - { - cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = null; - UIUtils.RegisterPropertyNode( m_reordenator ); - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - if( inside ) - { - UIUtils.RegisterPropertyNode( m_reordenator ); - } - } - - m_textLabelWidth = 120; - - UIUtils.RegisterFunctionNode( this ); - - m_previewShaderGUID = "aca70c900c50c004e8ef0b47c4fac4d4"; - m_useInternalPortData = false; - m_selectedLocation = function.PreviewPosition; - UIUtils.CurrentWindow.OutsideGraph.OnLODMasterNodesAddedEvent += OnLODMasterNodesAddedEvent; - } - - public InputPort GetInput( FunctionInput input ) - { - int index = m_allFunctionInputs.FindIndex( ( x ) => { return x.Equals( input ); } ); - if( index >= 0 ) - return InputPorts[ index ]; - else - return null; - } - - private void OnLODMasterNodesAddedEvent( int lod ) - { - AddShaderFunctionDirectivesInternal( lod ); - } - - public void SetPreviewInput( InputPort input ) - { - if( !HasPreviewShader || !m_initialized ) - return; - - if( input.IsConnected && input.InputNodeHasPreview( ContainerGraph ) ) - { - input.SetPreviewInputTexture( ContainerGraph ); - } - else - { - input.SetPreviewInputValue( ContainerGraph ); - } - } - - public override bool RecursivePreviewUpdate( Dictionary<string, bool> duplicatesDict = null ) - { - if( duplicatesDict == null ) - { - duplicatesDict = ContainerGraph.ParentWindow.VisitedChanged; - } - - if( m_allFunctionOutputs == null || m_allFunctionOutputs.Count == 0 ) - return false; - - for( int i = 0; i < m_allFunctionOutputs.Count; i++ ) - { - ParentNode outNode = m_allFunctionOutputs[ i ]; - if( outNode != null ) - { - if( !duplicatesDict.ContainsKey( outNode.OutputId ) ) - { - bool result = outNode.RecursivePreviewUpdate(); - if( result ) - PreviewIsDirty = true; - } - else if( duplicatesDict[ outNode.OutputId ] ) - { - PreviewIsDirty = true; - } - } - } - - bool needsUpdate = PreviewIsDirty; - RenderNodePreview(); - if( !duplicatesDict.ContainsKey( OutputId ) ) - duplicatesDict.Add( OutputId, needsUpdate ); - return needsUpdate; - } - - public override void RenderNodePreview() - { - if( m_outputPorts == null ) - return; - - if( !PreviewIsDirty && !m_continuousPreviewRefresh ) - return; - - // this is in the wrong place?? - if( m_drawPreviewAsSphere != m_mainPreviewNode.SpherePreview ) - { - m_drawPreviewAsSphere = m_mainPreviewNode.SpherePreview; - OnNodeChange(); - } - - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - m_outputPorts[ i ].OutputPreviewTexture = m_allFunctionOutputs[ i ].PreviewTexture; - } - - if( PreviewIsDirty ) - FinishPreviewRender = true; - - PreviewIsDirty = false; - } - - public override RenderTexture PreviewTexture - { - get - { - if( m_mainPreviewNode != null ) - return m_mainPreviewNode.PreviewTexture; - else - return base.PreviewTexture; - } - } - - private void AddShaderFunctionDirectivesInternal( int lod ) - { - List<TemplateMultiPassMasterNode> nodes = ContainerGraph.ParentWindow.OutsideGraph.GetMultiPassMasterNodes( lod ); - int count = nodes.Count; - for( int i = 0; i < count; i++ ) - { - nodes[ i ].PassModule.AdditionalDirectives.AddShaderFunctionItems( OutputId, Function.AdditionalDirectives.DirectivesList ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( Function == null ) - return; - - //Debug.Log( "RefreshExternalReferences " + m_function.FunctionName + " " + UIUtils.CurrentWindow.IsShaderFunctionWindow ); - - Function.UpdateDirectivesList(); - - MasterNode masterNode = UIUtils.CurrentWindow.OutsideGraph.CurrentMasterNode; - StandardSurfaceOutputNode surface = masterNode as StandardSurfaceOutputNode; - - - - if( surface != null ) - { - //for( int i = 0; i < Function.AdditionalIncludes.IncludeList.Count; i++ ) - //{ - // //ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalIncludes.OutsideList.Add( Function.AdditionalIncludes.IncludeList[ i ] ); - // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalDirectives.AddShaderFunctionItem( AdditionalLineType.Include, Function.AdditionalIncludes.IncludeList[ i ] ); - // m_includes.Add( Function.AdditionalIncludes.IncludeList[ i ] ); - //} - - //for( int i = 0; i < Function.AdditionalPragmas.PragmaList.Count; i++ ) - //{ - // //ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalPragmas.OutsideList.Add( Function.AdditionalPragmas.PragmaList[ i ] ); - // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalDirectives.AddShaderFunctionItem(AdditionalLineType.Pragma, Function.AdditionalPragmas.PragmaList[ i ] ); - // m_pragmas.Add( Function.AdditionalPragmas.PragmaList[ i ] ); - //} - surface.AdditionalDirectives.AddShaderFunctionItems( OutputId, Function.AdditionalDirectives.DirectivesList ); - } - else - { - if( ContainerGraph.ParentWindow.OutsideGraph.MultiPassMasterNodes.Count > 0 ) - { - for( int lod = -1; lod < ContainerGraph.ParentWindow.OutsideGraph.LodMultiPassMasternodes.Count; lod++ ) - { - AddShaderFunctionDirectivesInternal( lod ); - } - } - else - { - // Assuring that we're not editing a Shader Function, as directives setup is not needed there - if( !UIUtils.CurrentWindow.IsShaderFunctionWindow ) - { - // This function is nested inside a shader function itself and this method - // was called before the main output node was created. - // This is possible since all nodes RefreshExternalReferences(...) are called at the end - // of a LoadFromMeta - // Need to delay this setup to after all nodes are loaded to then setup the directives - m_lateRefresh = true; - return; - } - } - - } - m_directives.AddRange( Function.AdditionalDirectives.DirectivesList ); - - if( m_refreshIdsRequired ) - { - m_refreshIdsRequired = false; - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - m_inputPorts[ i ].ChangePortId( m_allFunctionInputs[ i ].UniqueId ); - } - - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPorts[ i ].ChangePortId( m_allFunctionOutputs[ i ].UniqueId ); - } - } - - if( ContainerGraph.ParentWindow.CurrentGraph != m_functionGraph ) - ContainerGraph.ParentWindow.CurrentGraph.InstancePropertyCount += m_functionGraph.InstancePropertyCount; - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - - if( ReadOptionsHelper.Length > 2 ) - { - for( int i = 1; i < ReadOptionsHelper.Length; i += 2 ) - { - int optionId = Convert.ToInt32( ReadOptionsHelper[ i ] ); - int optionValue = Convert.ToInt32( ReadOptionsHelper[ i + 1 ] ); - for( int j = 0; j < m_allFunctionSwitches.Count; j++ ) - { - if( m_allFunctionSwitches[ j ].UniqueId == optionId ) - { - m_allFunctionSwitches[ j ].SetCurrentSelectedInput( optionValue, m_allFunctionSwitches[ j ].GetCurrentSelectedInput() ); - break; - } - } - } - } - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - m_portsChanged = true; - } - - void InputPortSwitchRestriction( WirePort port ) - { - switch( port.DataType ) - { - case WirePortDataType.OBJECT: - break; - case WirePortDataType.FLOAT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - case WirePortDataType.INT: - { - port.CreatePortRestrictions( WirePortDataType.FLOAT, WirePortDataType.FLOAT2, WirePortDataType.FLOAT3, WirePortDataType.FLOAT4, WirePortDataType.COLOR, WirePortDataType.INT, WirePortDataType.OBJECT ); - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - port.CreatePortRestrictions( WirePortDataType.FLOAT3x3, WirePortDataType.FLOAT4x4, WirePortDataType.OBJECT ); - } - break; - case WirePortDataType.SAMPLER1D: - case WirePortDataType.SAMPLER2D: - case WirePortDataType.SAMPLER3D: - case WirePortDataType.SAMPLERCUBE: - { - port.CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT ); - } - break; - default: - break; - } - } - - void OutputPortSwitchRestriction( WirePort port ) - { - switch( port.DataType ) - { - case WirePortDataType.OBJECT: - break; - case WirePortDataType.FLOAT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - port.AddPortForbiddenTypes( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE ); - } - break; - case WirePortDataType.SAMPLER1D: - case WirePortDataType.SAMPLER2D: - case WirePortDataType.SAMPLER3D: - case WirePortDataType.SAMPLERCUBE: - { - port.CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT ); - } - break; - default: - break; - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - m_outsideGraph = cachedGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - - for( int i = 0; i < m_allFunctionOutputs.Count; i++ ) - { - m_allFunctionOutputs[ i ].PropagateNodeData( nodeData, ref dataCollector ); - } - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - base.PropagateNodeData( nodeData, ref dataCollector ); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterFunctionNode( this ); - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - base.SetupFromCastObject( obj ); - AmplifyShaderFunction function = obj as AmplifyShaderFunction; - CommonInit( function, UniqueId ); - RefreshExternalReferences(); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - FunctionInput functionInput = m_refreshIdsRequired ? m_allFunctionInputs[ portId ] : GetFunctionInputByUniqueId( portId ); - functionInput.PreviewIsDirty = true; - if( functionInput.AutoCast ) - { - InputPort inputPort = m_refreshIdsRequired ? m_inputPorts[ portId ] : GetInputPortByUniqueId( portId ); - inputPort.MatchPortToConnection(); - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - functionInput.ChangeOutputType( inputPort.DataType, false ); - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - } - - for( int i = 0; i < m_allFunctionOutputs.Count; i++ ) - { - m_outputPorts[ i ].ChangeType( m_allFunctionOutputs[ i ].InputPorts[ 0 ].DataType, false ); - } - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - - FunctionInput functionInput = m_refreshIdsRequired ? m_allFunctionInputs[ portId ] : GetFunctionInputByUniqueId( portId ); - functionInput.PreviewIsDirty = true; - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type ); - FunctionInput functionInput = m_refreshIdsRequired ? m_allFunctionInputs[ inputPortId ] : GetFunctionInputByUniqueId( inputPortId ); - functionInput.PreviewIsDirty = true; - if( functionInput.AutoCast ) - { - InputPort inputPort = m_refreshIdsRequired ? m_inputPorts[ inputPortId ] : GetInputPortByUniqueId( inputPortId ); - inputPort.MatchPortToConnection(); - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - functionInput.ChangeOutputType( inputPort.DataType, false ); - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - } - - for( int i = 0; i < m_allFunctionOutputs.Count; i++ ) - { - m_outputPorts[ i ].ChangeType( m_allFunctionOutputs[ i ].InputPorts[ 0 ].DataType, false ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - - if( Function == null ) - return; - - if( Function.Description.Length > 0 || m_allFunctionSwitches.Count > 0 ) - NodeUtils.DrawPropertyGroup( ref m_parametersFoldout, "Parameters", DrawDescription ); - - bool drawInternalDataUI = false; - int inputCount = m_inputPorts.Count; - if( inputCount > 0 ) - { - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Available && m_inputPorts[ i ].ValidInternalData && !m_inputPorts[ i ].IsConnected && m_inputPorts[ i ].AutoDrawInternalData /*&& ( m_inputPorts[ i ].AutoDrawInternalData || ( m_autoDrawInternalPortData && m_useInternalPortData ) )*/ /*&& m_inputPorts[ i ].AutoDrawInternalData*/ ) - { - drawInternalDataUI = true; - break; - } - } - } - - if( drawInternalDataUI ) - NodeUtils.DrawPropertyGroup( ref m_internalDataFoldout, Constants.InternalDataLabelStr, () => - { - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].ValidInternalData && !m_inputPorts[ i ].IsConnected && m_inputPorts[ i ].Visible && m_inputPorts[ i ].AutoDrawInternalData ) - { - EditorGUI.BeginChangeCheck(); - m_inputPorts[ i ].ShowInternalData( this ); - if( EditorGUI.EndChangeCheck() ) - { - m_allFunctionInputs[ i ].PreviewIsDirty = true; - } - } - } - } ); - } - - private void DrawDescription() - { - if( Function.Description.Length > 0 ) - EditorGUILayout.HelpBox( Function.Description, MessageType.Info ); - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - for( int i = 0; i < m_allFunctionSwitches.Count; i++ ) - { - m_allFunctionSwitches[ i ].AsDrawn = false; - } - - for( int i = 0; i < m_allFunctionSwitches.Count; i++ ) - { - if( m_allFunctionSwitches[ i ].DrawOption( this ) ) - { - m_portsChanged = true; - } - } - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - } - - private void RemoveShaderFunctionDirectivesInternal( int lod ) - { - List<TemplateMultiPassMasterNode> nodes = ContainerGraph.ParentWindow.OutsideGraph.GetMultiPassMasterNodes( lod ); - int count = nodes.Count; - for( int i = 0; i < count; i++ ) - { - nodes[ i ].PassModule.AdditionalDirectives.RemoveShaderFunctionItems( OutputId ); - } - } - - public override void Destroy() - { - m_mainPreviewNode = null; - base.Destroy(); - - m_duplicatesBuffer.Clear(); - m_duplicatesBuffer = null; - - if( m_functionGraph != null && ContainerGraph.ParentWindow.CurrentGraph != m_functionGraph ) - ContainerGraph.ParentWindow.CurrentGraph.InstancePropertyCount -= m_functionGraph.InstancePropertyCount; - - if( ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface != null ) - { - //for( int i = 0; i < m_includes.Count; i++ ) - //{ - // //if( ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalIncludes.OutsideList.Contains( m_includes[ i ] ) ) - // //{ - // // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalIncludes.OutsideList.Remove( m_includes[ i ] ); - // //} - // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalDirectives.RemoveShaderFunctionItem( AdditionalLineType.Include, m_includes[ i ] ); - //} - - //for( int i = 0; i < m_pragmas.Count; i++ ) - //{ - // //if( ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalPragmas.OutsideList.Contains( m_pragmas[ i ] ) ) - // //{ - // // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalPragmas.OutsideList.Remove( m_pragmas[ i ] ); - // //} - // ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalDirectives.RemoveShaderFunctionItem( AdditionalLineType.Pragma, m_pragmas[ i ] ); - //} - ContainerGraph.ParentWindow.OutsideGraph.CurrentStandardSurface.AdditionalDirectives.RemoveShaderFunctionItems( OutputId/*, m_directives */); - } - else - { - if( ContainerGraph.ParentWindow.OutsideGraph.MultiPassMasterNodes.Count > 0 ) - { - for( int lod = -1; lod < ContainerGraph.ParentWindow.OutsideGraph.LodMultiPassMasternodes.Count; lod++ ) - { - RemoveShaderFunctionDirectivesInternal( lod ); - } - } - } - - - - - // Cannot GameObject.Destroy(m_directives[i]) since we would be removing them from - // the shader function asset itself - - m_directives.Clear(); - m_directives = null; - - if( m_reordenator != null ) - { - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = null; - UIUtils.UnregisterPropertyNode( m_reordenator ); - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - m_reordenator.Destroy(); - m_reordenator = null; - } - - UIUtils.UnregisterFunctionNode( this ); - - ParentGraph cachedGraph2 = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - - if( m_allFunctionInputs != null ) - m_allFunctionInputs.Clear(); - m_allFunctionInputs = null; - - if( m_allFunctionOutputs != null ) - m_allFunctionOutputs.Clear(); - m_allFunctionOutputs = null; - - if( m_functionGraph != null ) - m_functionGraph.SoftDestroy(); - m_functionGraph = null; - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph2; - m_function = null; - - m_allFunctionOutputsDict.Clear(); - m_allFunctionOutputsDict = null; - - m_allFunctionSwitchesDict.Clear(); - m_allFunctionSwitchesDict = null; - - m_allFunctionInputsDict.Clear(); - m_allFunctionInputsDict = null; - - UIUtils.CurrentWindow.OutsideGraph.OnLODMasterNodesAddedEvent -= OnLODMasterNodesAddedEvent; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - if( m_lateRefresh ) - { - m_lateRefresh = false; - RefreshExternalReferences(); - } - - CheckForChangesRecursively(); - - base.OnNodeLogicUpdate( drawInfo ); - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - - if( m_functionGraph != null ) - { - int nodeCount = m_functionGraph.AllNodes.Count; - for( int i = 0; i < nodeCount; i++ ) - { - m_functionGraph.AllNodes[ i ].OnNodeLogicUpdate( drawInfo ); - } - - if( !string.IsNullOrEmpty( FunctionGraph.CurrentFunctionOutput.SubTitle ) ) - { - SetAdditonalTitleText( FunctionGraph.CurrentFunctionOutput.SubTitle ); - } - } - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - if( m_portsChanged ) - { - m_portsChanged = false; - for( int i = 0; i < m_allFunctionOutputs.Count; i++ ) - { - m_outputPorts[ i ].ChangeType( m_allFunctionOutputs[ i ].InputPorts[ 0 ].DataType, false ); - } - - CheckPortVisibility(); - } - } - - public override void Draw( DrawInfo drawInfo ) - { - //CheckForChangesRecursively(); - - if( !m_initialGraphDraw && drawInfo.CurrentEventType == EventType.Repaint ) - { - m_initialGraphDraw = true; - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; - if( m_functionGraph != null ) - { - for( int i = 0; i < m_functionGraph.AllNodes.Count; i++ ) - { - ParentNode node = m_functionGraph.AllNodes[ i ]; - if( node != null ) - { - node.OnNodeLayout( drawInfo ); - } - } - } - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - } - - base.Draw( drawInfo ); - } - - public bool CheckForChanges( bool forceCheck = false, bool forceChange = false ) - { - if( ( ContainerGraph.ParentWindow.CheckFunctions || forceCheck || forceChange ) && m_function != null ) - { - //string newCheckSum = LastLine( m_function.FunctionInfo ); - string newCheckSum = AssetDatabase.GetAssetDependencyHash( AssetDatabase.GetAssetPath( m_function ) ).ToString(); - if( !m_functionCheckSum.Equals( newCheckSum ) || forceChange ) - { - m_functionCheckSum = newCheckSum; - ContainerGraph.OnDuplicateEvent += DuplicateMe; - return true; - } - } - return false; - } - - public bool CheckForChangesRecursively() - { - if( m_functionGraph == null ) - return false; - - bool result = false; - for( int i = 0; i < m_functionGraph.FunctionNodes.NodesList.Count; i++ ) - { - if( m_functionGraph.FunctionNodes.NodesList[ i ].CheckForChangesRecursively() ) - result = true; - } - if( CheckForChanges( false, result ) ) - result = true; - - return result; - } - - public void DuplicateMe() - { - bool previewOpen = m_showPreview; - - string allOptions = m_allFunctionSwitches.Count.ToString(); - for( int i = 0; i < m_allFunctionSwitches.Count; i++ ) - { - allOptions += "," + m_allFunctionSwitches[ i ].UniqueId + "," + m_allFunctionSwitches[ i ].GetCurrentSelectedInput(); - } - - ReadOptionsHelper = allOptions.Split( ',' ); - - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = null; - MasterNode masterNode = ContainerGraph.ParentWindow.CurrentGraph.CurrentMasterNode; - if( masterNode != null ) - masterNode.InvalidateMaterialPropertyCount(); - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - ParentNode newNode = ContainerGraph.CreateNode( m_function, false, Vec2Position ); - newNode.ShowPreview = previewOpen; - ( newNode as FunctionNode ).ReadOptionsHelper = ReadOptionsHelper; - newNode.RefreshExternalReferences(); - if( ( newNode as FunctionNode ).m_reordenator && m_reordenator ) - ( newNode as FunctionNode ).m_reordenator.OrderIndex = m_reordenator.OrderIndex; - - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - OutputPort newOutputPort = newNode.GetOutputPortByUniqueId( m_outputPorts[ i ].PortId ); - if( newNode.OutputPorts != null && newOutputPort != null ) - { - for( int j = m_outputPorts[ i ].ExternalReferences.Count - 1; j >= 0; j-- ) - { - ContainerGraph.CreateConnection( m_outputPorts[ i ].ExternalReferences[ j ].NodeId, m_outputPorts[ i ].ExternalReferences[ j ].PortId, newOutputPort.NodeId, newOutputPort.PortId ); - } - } - } - //else - //{ - //if( newNode.OutputPorts != null && newNode.OutputPorts[ i ] != null ) - //{ - // ContainerGraph.DeleteConnection( false, newNode.UniqueId, newNode.OutputPorts[ i ].PortId, false, false, false ); - //} - //} - } - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - InputPort newInputPort = newNode.GetInputPortByUniqueId( m_inputPorts[ i ].PortId ); - if( newNode.InputPorts != null && newInputPort != null ) - { - ContainerGraph.CreateConnection( newInputPort.NodeId, newInputPort.PortId, m_inputPorts[ i ].ExternalReferences[ 0 ].NodeId, m_inputPorts[ i ].ExternalReferences[ 0 ].PortId ); - } - } - } - - ContainerGraph.OnDuplicateEvent -= DuplicateMe; - - if( Selected ) - { - ContainerGraph.DeselectNode( this ); - ContainerGraph.SelectNode( newNode, true, false ); - } - - ContainerGraph.DestroyNode( this, false ); - } - - private FunctionOutput GetFunctionOutputByUniqueId( int uniqueId ) - { - int listCount = m_allFunctionOutputs.Count; - if( m_allFunctionOutputsDict.Count != m_allFunctionOutputs.Count ) - { - m_allFunctionOutputsDict.Clear(); - for( int i = 0; i < listCount; i++ ) - { - m_allFunctionOutputsDict.Add( m_allFunctionOutputs[ i ].UniqueId, m_allFunctionOutputs[ i ] ); - } - } - - if( m_allFunctionOutputsDict.ContainsKey( uniqueId ) ) - return m_allFunctionOutputsDict[ uniqueId ]; - - return null; - } - - private FunctionInput GetFunctionInputByUniqueId( int uniqueId ) - { - int listCount = m_allFunctionInputs.Count; - if( m_allFunctionInputsDict.Count != m_allFunctionInputs.Count ) - { - m_allFunctionInputsDict.Clear(); - for( int i = 0; i < listCount; i++ ) - { - m_allFunctionInputsDict.Add( m_allFunctionInputs[ i ].UniqueId, m_allFunctionInputs[ i ] ); - } - } - - if( m_allFunctionInputsDict.ContainsKey( uniqueId ) ) - return m_allFunctionInputsDict[ uniqueId ]; - - return null; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - OutputPort outputPort = GetOutputPortByUniqueId( outputId ); - FunctionOutput functionOutput = GetFunctionOutputByUniqueId( outputId ); - - if( outputPort.IsLocalValue( dataCollector.PortCategory ) ) - return outputPort.LocalValue( dataCollector.PortCategory ); - - m_functionGraph.CurrentPrecision = ContainerGraph.ParentWindow.CurrentGraph.CurrentPrecision; - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - m_outsideGraph = cachedGraph; - ContainerGraph.ParentWindow.CustomGraph = m_functionGraph; -#if ADD_SHADER_FUNCTION_HEADERS - if( m_reordenator != null && m_reordenator.RecursiveCount() > 0 && m_reordenator.HasTitle ) - { - dataCollector.AddToProperties( UniqueId, "[Header(" + m_reordenator.HeaderTitle.Replace( "-", " " ) + ")]", m_reordenator.OrderIndex ); - } -#endif - string result = string.Empty; - for( int i = 0; i < m_allFunctionInputs.Count; i++ ) - { - if( !m_allFunctionInputs[ i ].InputPorts[ 0 ].IsConnected || m_inputPorts[ i ].IsConnected ) - m_allFunctionInputs[ i ].OnPortGeneration += FunctionNodeOnPortGeneration; - } - - result += functionOutput.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - for( int i = 0; i < m_allFunctionInputs.Count; i++ ) - { - if( !m_allFunctionInputs[ i ].InputPorts[ 0 ].IsConnected || m_inputPorts[ i ].IsConnected ) - m_allFunctionInputs[ i ].OnPortGeneration -= FunctionNodeOnPortGeneration; - } - - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - - if( outputPort.ConnectionCount > 1 ) - RegisterLocalVariable( outputId, result, ref dataCollector ); - else - outputPort.SetLocalValue( result, dataCollector.PortCategory ); - - return outputPort.LocalValue( dataCollector.PortCategory ); - } - - private string FunctionNodeOnPortGeneration( ref MasterNodeDataCollector dataCollector, int index, ParentGraph graph ) - { - ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph; - ContainerGraph.ParentWindow.CustomGraph = m_outsideGraph; - string result = m_inputPorts[ index ].GeneratePortInstructions( ref dataCollector ); - ContainerGraph.ParentWindow.CustomGraph = cachedGraph; - return result; - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - - if( Function != null ) - IOUtils.AddFieldValueToString( ref nodeInfo, m_function.name ); - else - IOUtils.AddFieldValueToString( ref nodeInfo, m_filename ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_reordenator != null ? m_reordenator.RawOrderIndex : -1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_headerTitle ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_functionGraphId ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_functionGUID ); - - int functionSwitchCount = m_allFunctionSwitches != null ? m_allFunctionSwitches.Count : 0; - string allOptions = functionSwitchCount.ToString(); - for( int i = 0; i < functionSwitchCount; i++ ) - { - allOptions += "," + m_allFunctionSwitches[ i ].UniqueId + "," + m_allFunctionSwitches[ i ].GetCurrentSelectedInput(); - } - IOUtils.AddFieldValueToString( ref nodeInfo, allOptions ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_filename = GetCurrentParam( ref nodeParams ); - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_headerTitle = GetCurrentParam( ref nodeParams ); - - if( UIUtils.CurrentShaderVersion() > 7203 ) - { - m_functionGraphId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 13704 ) - { - m_functionGUID = GetCurrentParam( ref nodeParams ); - } - - AmplifyShaderFunction loaded = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( AssetDatabase.GUIDToAssetPath( m_functionGUID ) ); - if( loaded != null ) - { - CommonInit( loaded, UniqueId ); - } - else - { - string[] guids = AssetDatabase.FindAssets( "t:AmplifyShaderFunction " + m_filename ); - if( guids.Length > 0 ) - { - string sfGuid = null; - - foreach( string guid in guids ) - { - string assetPath = AssetDatabase.GUIDToAssetPath( guid ); - string name = System.IO.Path.GetFileNameWithoutExtension( assetPath ); - if( name.Equals( m_filename, StringComparison.OrdinalIgnoreCase ) ) - { - sfGuid = guid; - break; - } - } - loaded = AssetDatabase.LoadAssetAtPath<AmplifyShaderFunction>( AssetDatabase.GUIDToAssetPath( sfGuid ) ); - - if( loaded != null ) - { - CommonInit( loaded, UniqueId ); - } - else - { - SetTitleText( "ERROR" ); - UIUtils.ShowMessage( UniqueId, string.Format( "Error loading {0} shader function from project folder", m_filename ), MessageSeverity.Error ); - } - } - else - { - SetTitleText( "Missing Function" ); - UIUtils.ShowMessage( UniqueId, string.Format( "Missing {0} shader function on project folder", m_filename ), MessageSeverity.Error ); - } - } - if( UIUtils.CurrentShaderVersion() > 14203 ) - { - ReadOptionsHelper = GetCurrentParam( ref nodeParams ).Split( ',' ); - } - } - - public override void ReadOutputDataFromString( ref string[] nodeParams ) - { - if( Function == null ) - return; - - base.ReadOutputDataFromString( ref nodeParams ); - - ConfigureInputportsAfterRead(); - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( Function == null ) - return; - - ContainerGraph.DeSelectAll(); - this.Selected = true; - - ContainerGraph.ParentWindow.OnLeftMouseUp(); - AmplifyShaderEditorWindow.LoadShaderFunctionToASE( Function, true ); - this.Selected = false; - } - - private void ConfigureInputportsAfterRead() - { - if( InputPorts != null ) - { - int inputCount = InputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - InputPorts[ i ].ChangeProperties( m_allFunctionInputs[ i ].InputName, m_allFunctionInputs[ i ].SelectedInputType, false ); - } - } - - if( OutputPorts != null ) - { - int outputCount = OutputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - OutputPorts[ i ].ChangeProperties( m_allFunctionOutputs[ i ].OutputName, m_allFunctionOutputs[ i ].AutoOutputType, false ); - } - } - } - - private void CheckPortVisibility() - { - bool changes = false; - if( InputPorts != null ) - { - for( int i = 0; i < m_allFunctionInputs.Count; i++ ) - { - if( m_inputPorts[ i ].Visible != m_allFunctionInputs[ i ].IsConnected ) - { - m_inputPorts[ i ].Visible = m_allFunctionInputs[ i ].IsConnected; - changes = true; - } - } - } - - if( changes ) - m_sizeIsDirty = true; - } - - public bool HasProperties { get { return m_reordenator != null; } } - - public ParentGraph FunctionGraph - { - get { return m_functionGraph; } - set { m_functionGraph = value; } - } - - public AmplifyShaderFunction Function - { - get { return m_function; } - set { m_function = value; } - } - - public override void RecordObjectOnDestroy( string Id ) - { - base.RecordObjectOnDestroy( Id ); - if( m_reordenator != null ) - m_reordenator.RecordObject( Id ); - - if( m_functionGraph != null ) - { - Undo.RegisterCompleteObjectUndo( m_functionGraph, Id ); - for( int i = 0; i < m_functionGraph.AllNodes.Count; i++ ) - { - m_functionGraph.AllNodes[ i ].RecordObject( Id ); - } - } - } - - public override void SetContainerGraph( ParentGraph newgraph ) - { - base.SetContainerGraph( newgraph ); - if( m_functionGraph == null ) - return; - for( int i = 0; i < m_functionGraph.AllNodes.Count; i++ ) - { - m_functionGraph.AllNodes[ i ].SetContainerGraph( m_functionGraph ); - } - } - - public override void OnMasterNodeReplaced( MasterNode newMasterNode ) - { - base.OnMasterNodeReplaced( newMasterNode ); - if( m_functionGraph == null ) - return; - - m_functionGraph.FireMasterNodeReplacedEvent( newMasterNode ); - - StandardSurfaceOutputNode surface = newMasterNode as StandardSurfaceOutputNode; - if( surface != null ) - { - surface.AdditionalDirectives.AddShaderFunctionItems( OutputId, Function.AdditionalDirectives.DirectivesList ); - } - else - { - if( ContainerGraph.ParentWindow.OutsideGraph.MultiPassMasterNodes.Count > 0 ) - { - for( int lod = -1; lod < ContainerGraph.ParentWindow.OutsideGraph.LodMultiPassMasternodes.Count; lod++ ) - { - AddShaderFunctionDirectivesInternal( lod ); - } - } - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs.meta deleted file mode 100644 index 15ea8d35..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7b3de46feda5b0f4ea58c852c4a521a9 -timeCreated: 1492001141 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs deleted file mode 100644 index baa49631..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs +++ /dev/null @@ -1,318 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Function Output", "Functions", "Function Output adds an output port to the shader function, it's port type is determined automatically.", NodeAvailabilityFlags = (int)NodeAvailability.ShaderFunction )] - public sealed class FunctionOutput : OutputNode - { - public FunctionOutput() : base() { CommonInit(); } - public FunctionOutput( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { CommonInit(); } - - [SerializeField] - private bool m_previewNode = false; - - [SerializeField] - private string m_outputName = "Output"; - - [SerializeField] - private int m_orderIndex = -1; - - [SerializeField] - private AmplifyShaderFunction m_function; - - //Title editing - [SerializeField] - private string m_uniqueName; - - private bool m_isEditing; - private bool m_stopEditing; - private bool m_startEditing; - private double m_clickTime; - private double m_doubleClickTime = 0.3; - private Rect m_titleClickArea; - private bool m_showTitleWhenNotEditing = true; - - [SerializeField] - private string m_subTitle = string.Empty; - - - void CommonInit() - { - m_isMainOutputNode = false; - m_connStatus = NodeConnectionStatus.Connected; - m_activeType = GetType(); - m_currentPrecisionType = PrecisionType.Inherit; - m_textLabelWidth = 100; - m_autoWrapProperties = true; - AddInputPort( WirePortDataType.FLOAT, false, " " ); - AddOutputPort( WirePortDataType.FLOAT, " " ); - m_outputPorts[ 0 ].Visible = false; - SetTitleText( m_outputName ); - m_previewShaderGUID = "e6d5f64114b18e24f99dc65290c0fe98"; - } - - public override void SetupNodeCategories() - { - //base.SetupNodeCategories(); - ContainerGraph.ResetNodesData(); - MasterNode masterNode = ContainerGraph.ParentWindow.CurrentGraph.CurrentMasterNode; - if( masterNode != null ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - NodeData nodeData = new NodeData( m_inputPorts[ i ].Category ); - ParentNode node = m_inputPorts[ i ].GetOutputNode(); - MasterNodeDataCollector temp = masterNode.CurrentDataCollector; - node.PropagateNodeData( nodeData, ref temp ); - temp = null; - } - } - } - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterFunctionOutputNode( this ); - if( m_nodeAttribs != null ) - m_uniqueName = m_nodeAttribs.Name + UniqueId; - } - - - public override void Destroy() - { - base.Destroy(); - UIUtils.UnregisterFunctionOutputNode( this ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_outputName = EditorGUILayoutTextField( "Name", m_outputName ); - - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_outputName ); - UIUtils.UpdateFunctionOutputData( UniqueId, m_outputName ); - } - - EditorGUI.BeginDisabledGroup( m_previewNode ); - if( GUILayout.Button( "Set as Preview" ) ) - { - List<FunctionOutput> allOutputs = UIUtils.FunctionOutputList(); - - foreach( FunctionOutput item in allOutputs ) - item.PreviewNode = false; - - m_previewNode = true; - } - EditorGUI.EndDisabledGroup(); - } - [SerializeField] - private string m_currentTitle = string.Empty; - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( m_previewNode ) - m_currentTitle = "Preview"; - else - m_currentTitle = string.Empty; - - SetAdditonalTitleTextOnCallback( m_currentTitle, ( instance, newSubTitle ) => instance.AdditonalTitleContent.text = newSubTitle ); - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( !m_isEditing && ( ( !ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains( drawInfo.MousePosition ) ) ) ) - { - if( ( EditorApplication.timeSinceStartup - m_clickTime ) < m_doubleClickTime ) - m_startEditing = true; - else - GUI.FocusControl( null ); - m_clickTime = EditorApplication.timeSinceStartup; - } - else if( m_isEditing && ( ( drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains( drawInfo.MousePosition ) ) || !EditorGUIUtility.editingTextField ) ) - { - m_stopEditing = true; - } - - if( m_isEditing || m_startEditing ) - { - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_uniqueName ); - m_outputName = EditorGUITextField( m_titleClickArea, string.Empty, m_outputName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_outputName ); - UIUtils.UpdateFunctionInputData( UniqueId, m_outputName ); - } - - if( m_startEditing ) - EditorGUI.FocusTextInControl( m_uniqueName ); - - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( m_startEditing ) - { - m_startEditing = false; - m_isEditing = true; - } - - if( m_stopEditing ) - { - m_stopEditing = false; - m_isEditing = false; - GUI.FocusControl( null ); - } - } - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - // RUN LAYOUT CHANGES AFTER TITLES CHANGE - base.OnNodeLayout( drawInfo ); - m_titleClickArea = m_titlePos; - m_titleClickArea.height = Constants.NODE_HEADER_HEIGHT; - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - // Fixed Title ( only renders when not editing ) - if( m_showTitleWhenNotEditing && !m_isEditing && !m_startEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( m_titleClickArea, m_content, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( currentMousePos2D.y - m_globalPosition.y > ( Constants.NODE_HEADER_HEIGHT + Constants.NODE_HEADER_EXTRA_HEIGHT ) * ContainerGraph.ParentWindow.CameraDrawInfo.InvertedZoom ) - { - ContainerGraph.ParentWindow.ParametersWindow.IsMaximized = !ContainerGraph.ParentWindow.ParametersWindow.IsMaximized; - } - } - - public WirePortDataType AutoOutputType - { - get { return m_inputPorts[ 0 ].DataType; } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_outputName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_orderIndex ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_previewNode ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_outputName = GetCurrentParam( ref nodeParams ); - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - if( UIUtils.CurrentShaderVersion() > 13706 ) - m_previewNode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - if( IsNodeBeingCopied ) - PreviewNode = false; - - if( m_function == null ) - m_function = UIUtils.CurrentWindow.OpenedShaderFunction; - - if( m_isMainOutputNode && m_function != null ) - { - m_function.UpdateDirectivesList(); - } - - SetTitleText( m_outputName ); - UIUtils.UpdateFunctionOutputData( UniqueId, m_outputName ); - } - - public AmplifyShaderFunction Function - { - get { return m_function; } - set - { - m_function = value; - if( m_isMainOutputNode && m_function != null ) - { - m_function.UpdateDirectivesList(); - } - } - } - - public string OutputName - { - get { return m_outputName; } - } - - public int OrderIndex - { - get { return m_orderIndex; } - set { m_orderIndex = value; } - } - - public string SubTitle - { - get { return m_subTitle; } - set { m_subTitle = value; } - } - - public bool PreviewNode - { - get { return m_previewNode; } - set - { - m_previewNode = value; - m_sizeIsDirty = true; - if( m_previewNode ) - { - m_currentTitle = "Preview"; - } - else - { - m_currentTitle = ""; - } - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs.meta deleted file mode 100644 index 7ece5125..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionOutput.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6293b1f56d13d6c4ca6a8e2a8099cca9 -timeCreated: 1491917775 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs deleted file mode 100644 index 42cf0b5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs +++ /dev/null @@ -1,124 +0,0 @@ -// 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( "Function Subtitle", "Functions", "Adds a subtitle to its shader function", NodeAvailabilityFlags = (int)NodeAvailability.ShaderFunction )] - public sealed class FunctionSubtitle : ParentNode - { - - //protected override void CommonInit( int uniqueId ) - //{ - // base.CommonInit( uniqueId ); - // AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - // AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - // m_autoWrapProperties = true; - // m_textLabelWidth = 100; - // //SetTitleText( m_inputName ); - // //SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - // m_previewShaderGUID = "04bc8e7b317dccb4d8da601680dd8140"; - //} - [SerializeField] - private string m_subttile = "Subtitle"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_autoWrapProperties = true; - m_textLabelWidth = 100; - SetTitleText( m_subttile ); - m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar ); - } - - //public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - //{ - // base.PropagateNodeData( nodeData, ref dataCollector ); - - // //if( m_containerGraph.CurrentShaderFunction != null ) - // //m_containerGraph.CurrentShaderFunction.FunctionSubtitle = m_subttile; - //} - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - //public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - //{ - // base.PropagateNodeData( nodeData, ref dataCollector ); - //Debug.Log( IsConnected + " " + m_containerGraph.CurrentFunctionOutput ); - if( m_containerGraph.CurrentFunctionOutput != null && IsConnected ) - m_containerGraph.CurrentFunctionOutput.SubTitle = m_subttile; - // m_containerGraph.CurrentShaderFunction.FunctionSubtitle = m_subttile; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - m_subttile = EditorGUILayoutTextField( "Name", m_subttile ); - if( EditorGUI.EndChangeCheck() ) - { - SetTitleText( m_subttile ); - //UIUtils.UpdateFunctionInputData( UniqueId, m_inputName ); - } - EditorGUI.BeginChangeCheck(); - //m_selectedInputTypeInt = EditorGUILayoutPopup( InputTypeStr, m_selectedInputTypeInt, m_inputValueTypes ); - //if( EditorGUI.EndChangeCheck() ) - //{ - // UpdatePorts(); - // SetAdditonalTitleText( "( " + m_inputValueTypes[ m_selectedInputTypeInt ] + " )" ); - //} - - //m_autoCast = EditorGUILayoutToggle( "Auto Cast", m_autoCast ); - - //EditorGUILayout.Separator(); - //if( !m_inputPorts[ 0 ].IsConnected && m_inputPorts[ 0 ].ValidInternalData ) - //{ - // m_inputPorts[ 0 ].ShowInternalData( this, true, "Default Value" ); - //} - - - EditorGUILayout.EndVertical(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_subttile ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_subttile = GetCurrentParam( ref nodeParams ); - SetTitleText( m_subttile ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs.meta deleted file mode 100644 index bd87bd97..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSubtitle.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 97d5e0cd26200a64fa9d127599406008 -timeCreated: 1522434121 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs deleted file mode 100644 index e25ad54a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs +++ /dev/null @@ -1,867 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Function Switch", "Functions", "Function Switch allows switching options at compile time for shader function", NodeAvailabilityFlags = (int)NodeAvailability.ShaderFunction )] - public sealed class FunctionSwitch : ParentNode - { - private const string InputPortNameStr = "In "; - - private const string ToggleFalseStr = "False"; - private const string ToggleTrueStr = "True"; - - private const string CurrSelectedStr = "Current"; - private const string MaxAmountStr = "Amount"; - private const int MaxAllowedAmount = 9; - - private const int MinComboSize = 50; - private const int MaxComboSize = 105; - - [SerializeField] - private string m_optionLabel = "Option"; - - [SerializeField] - private string[] AvailableInputsLabels = { "In 0", "In 1" }; - - [SerializeField] - private int[] AvailableInputsValues = { 0, 1 }; - - [SerializeField] - private int m_previousSelectedInput = 0; - - [SerializeField] - private int m_currentSelectedInput = 0; - - [SerializeField] - private int m_maxAmountInputs = 2; - - [SerializeField] - private bool m_toggleMode = false; - - [SerializeField] - private string[] m_optionNames = { "In 0", "In 1", "In 2", "In 3", "In 4", "In 5", "In 6", "In 7", "In 8" }; - - [SerializeField] - private int m_orderIndex = -1; - - [SerializeField] - private TexReferenceType m_referenceType = TexReferenceType.Object; - - [SerializeField] - private FunctionSwitch m_functionSwitchReference = null; - - [SerializeField] - private int m_referenceUniqueId = -1; - - [SerializeField] - private bool m_validReference = false; - - private bool m_asDrawn = false; - - private GUIContent m_checkContent; - private GUIContent m_popContent; - - private const double MaxTimestamp = 1; - private bool m_nameModified = false; - private double m_lastTimeNameModified = 0; - - private Rect m_varRect; - private Rect m_imgRect; - private bool m_editing; - - private int m_cachedPropertyId = -1; - - [SerializeField] - private int m_refMaxInputs = -1; - - [SerializeField] - private string m_refOptionLabel = string.Empty; - - [SerializeField] - private int m_refSelectedInput = -1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - AddInputPort( WirePortDataType.FLOAT, false, InputPortNameStr + i ); - m_inputPorts[ i ].Visible = ( i < 2 ); - } - AddOutputPort( WirePortDataType.FLOAT, " " ); - - m_checkContent = new GUIContent(); - m_checkContent.image = UIUtils.CheckmarkIcon; - - m_popContent = new GUIContent(); - m_popContent.image = UIUtils.PopupIcon; - - m_textLabelWidth = 100; - m_autoWrapProperties = true; - m_insideSize.Set( 80, 25 ); - m_previewShaderGUID = "a58e46feaa5e3d14383bfeac24d008bc"; - } - - public void SetCurrentSelectedInput( int newValue, int prevValue ) - { - m_previousSelectedInput = prevValue; - if( m_validReference ) - m_currentSelectedInput = Mathf.Clamp( newValue, 0, m_refMaxInputs - 1 ); - else - m_currentSelectedInput = Mathf.Clamp( newValue, 0, m_maxAmountInputs - 1 ); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ m_currentSelectedInput ].DataType, false ); - PreviewIsDirty = true; - ChangeSignalPropagation(); - } - - public int GetCurrentSelectedInput() - { - return m_currentSelectedInput; - } - - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_Current" ); - - PreviewMaterial.SetInt( m_cachedPropertyId, m_currentSelectedInput ); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterFunctionSwitchNode( this ); - } - else - { - if( ContainerGraph.ParentWindow.CustomGraph != null ) - UIUtils.RegisterFunctionSwitchNode( this ); - UIUtils.RegisterFunctionSwitchCopyNode( this ); - } - } - - public override void Destroy() - { - base.Destroy(); - - m_functionSwitchReference = null; - m_referenceUniqueId = -1; - - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.UnregisterFunctionSwitchNode( this ); - } - else - { - UIUtils.UnregisterFunctionSwitchNode( this ); - UIUtils.UnregisterFunctionSwitchCopyNode( this ); - } - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ portId ].MatchPortToConnection(); - if( portId == m_currentSelectedInput ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ portId ].DataType, false ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - InputPort port = GetInputPortByUniqueId( portId ); - int arrayPos = m_inputPorts.IndexOf( port ); - if( activateNode && m_connStatus == NodeConnectionStatus.Connected && arrayPos == m_currentSelectedInput ) - { - port.GetOutputNode().ActivateNode( m_activeNode, m_activePort, m_activeType ); - } - - OnNodeChange(); - SetSaveIsDirty(); - - m_inputPorts[ portId ].MatchPortToConnection(); - if( arrayPos == m_currentSelectedInput ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ portId ].DataType, false ); - } - - public override void ActivateNode( int signalGenNodeId, int signalGenPortId, Type signalGenNodeType ) - { - if( m_selfPowered ) - return; - - ConnStatus = m_restrictions.GetRestiction( signalGenNodeType, signalGenPortId ) ? NodeConnectionStatus.Error : NodeConnectionStatus.Connected; - m_activeConnections += 1; - - m_activeType = signalGenNodeType; - m_activeNode = signalGenNodeId; - m_activePort = signalGenPortId; - if( m_activeConnections == 1 ) - if( m_inputPorts[ m_currentSelectedInput ].IsConnected ) - m_inputPorts[ m_currentSelectedInput ].GetOutputNode().ActivateNode( signalGenNodeId, signalGenPortId, signalGenNodeType ); - - SetSaveIsDirty(); - } - - public override void DeactivateInputPortNode( int deactivatedPort, bool forceComplete ) - { - InputPort port = GetInputPortByUniqueId( deactivatedPort ); - if( deactivatedPort == m_currentSelectedInput ) - port.GetOutputNode().DeactivateNode( deactivatedPort, false ); - } - - public override void DeactivateNode( int deactivatedPort, bool forceComplete ) - { - if( m_selfPowered ) - return; - - SetSaveIsDirty(); - m_activeConnections -= 1; - - if( ( forceComplete || m_activeConnections <= 0 ) ) - { - m_activeConnections = 0; - ConnStatus = NodeConnectionStatus.Not_Connected; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected && i == m_currentSelectedInput ) - { - ParentNode node = m_inputPorts[ i ].GetOutputNode(); - if( node != null ) - node.DeactivateNode( deactivatedPort == -1 ? m_inputPorts[ i ].PortId : deactivatedPort, false ); - } - } - } - } - - public void ChangeSignalPropagation() - { - if( m_previousSelectedInput != m_currentSelectedInput && ConnStatus == NodeConnectionStatus.Connected ) - { - if( m_inputPorts[ m_previousSelectedInput ].IsConnected ) - m_inputPorts[ m_previousSelectedInput ].GetOutputNode().DeactivateNode( m_inputPorts[ m_previousSelectedInput ].PortId, false ); - - if( m_inputPorts[ m_currentSelectedInput ].IsConnected ) - m_inputPorts[ m_currentSelectedInput ].GetOutputNode().ActivateNode( UniqueId, m_inputPorts[ m_currentSelectedInput ].PortId, m_activeType ); - } - } - - public bool DrawOption( ParentNode owner, bool forceDraw = false ) - { - if( !IsConnected && !forceDraw ) - { - //EditorGUILayout.LabelField( "Not Connected" ); - return false; - } - - if( m_asDrawn ) //used to prevent the same property to be drawn more than once - return false; - - if( m_validReference ) - { - return m_functionSwitchReference.DrawOption( owner, true ); - } - - int prev = m_currentSelectedInput; - m_asDrawn = true; - if( m_toggleMode ) - { - m_currentSelectedInput = owner.EditorGUILayoutToggle( m_optionLabel, ( m_currentSelectedInput != 0 ? true : false ) ) ? 1 : 0; - - if( m_currentSelectedInput != prev ) - { - SetCurrentSelectedInput( m_currentSelectedInput, prev ); - return true; - } - else - { - return false; - } - } - else - { - m_currentSelectedInput = owner.EditorGUILayoutIntPopup( m_optionLabel, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues ); - - if( m_currentSelectedInput != prev ) - { - SetCurrentSelectedInput( m_currentSelectedInput, prev ); - return true; - } - else - { - return false; - } - } - } - - public void CheckReference() - { - if( m_referenceType != TexReferenceType.Instance ) - { - m_validReference = false; - return; - } - - if( m_functionSwitchReference == null ) - { - m_validReference = false; - ResetToSelf(); - return; - } - - if( m_referenceUniqueId != m_functionSwitchReference.UniqueId ) - { - UpdateFromSelected(); - } - if( m_refSelectedInput != m_functionSwitchReference.GetCurrentSelectedInput() || m_refMaxInputs != m_functionSwitchReference.MaxAmountInputs || m_refOptionLabel != m_functionSwitchReference.OptionLabel ) - { - UpdateFromSelected(); - } - - m_validReference = true; - } - - void ResetToSelf() - { - m_functionSwitchReference = null; - m_validReference = false; - m_referenceUniqueId = -1; - m_refMaxInputs = -1; - m_refOptionLabel = string.Empty; - m_refSelectedInput = -1; - - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - m_inputPorts[ i ].Name = m_optionNames[ i ]; - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - UpdateLabels(); - m_sizeIsDirty = true; - } - - void UpdateFromSelected() - { - if( m_referenceUniqueId < 0 ) - return; - - m_functionSwitchReference = UIUtils.GetNode( m_referenceUniqueId ) as FunctionSwitch; - if( m_functionSwitchReference != null ) - { - m_validReference = true; - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_functionSwitchReference.MaxAmountInputs ); - m_inputPorts[ i ].Name = m_functionSwitchReference.InputPorts[ i ].Name; - } - UpdateLabels(); - m_refMaxInputs = m_functionSwitchReference.m_maxAmountInputs; - m_refOptionLabel = m_functionSwitchReference.OptionLabel; - m_refSelectedInput = m_functionSwitchReference.GetCurrentSelectedInput(); - OrderIndex = m_functionSwitchReference.OrderIndex; - - SetCurrentSelectedInput( m_functionSwitchReference.GetCurrentSelectedInput(), m_currentSelectedInput ); - } - - m_sizeIsDirty = true; - m_isDirty = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_referenceType == TexReferenceType.Object ) - { - if( ContainerGraph.ParentWindow.CustomGraph == null ) - UIUtils.UnregisterFunctionSwitchCopyNode( this ); - UIUtils.RegisterFunctionSwitchNode( this ); - ResetToSelf(); - } - else - { - if( ContainerGraph.ParentWindow.CustomGraph == null ) - UIUtils.UnregisterFunctionSwitchNode( this ); - UIUtils.RegisterFunctionSwitchCopyNode( this ); - } - } - - if( m_referenceType == TexReferenceType.Instance ) - { - EditorGUI.BeginChangeCheck(); - string[] arr = new string[ UIUtils.FunctionSwitchList().Count ]; - int[] ids = new int[ UIUtils.FunctionSwitchList().Count ]; - for( int i = 0; i < arr.Length; i++ ) - { - arr[ i ] = i + " - " + UIUtils.FunctionSwitchList()[ i ].OptionLabel; - ids[ i ] = UIUtils.FunctionSwitchList()[ i ].UniqueId; - } - m_referenceUniqueId = EditorGUILayout.IntPopup( Constants.AvailableReferenceStr, m_referenceUniqueId, arr, ids ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromSelected(); - } - return; - } - - EditorGUI.BeginChangeCheck(); - m_optionLabel = EditorGUILayoutTextField( "Option Label", m_optionLabel ); - if( EditorGUI.EndChangeCheck() ) - { - m_optionLabel = UIUtils.RemoveInvalidEnumCharacters( m_optionLabel ); - if( string.IsNullOrEmpty( m_optionLabel ) ) - { - m_optionLabel = "Option"; - } - - UIUtils.UpdateFunctionSwitchData( UniqueId, m_optionLabel ); - } - - EditorGUI.BeginChangeCheck(); - m_toggleMode = EditorGUILayoutToggle( "Toggle Mode", m_toggleMode ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_toggleMode ) - { - m_inputPorts[ 0 ].Name = ToggleFalseStr; - m_inputPorts[ 1 ].Name = ToggleTrueStr; - - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < 2 ); - } - - if( m_currentSelectedInput >= 2 ) - { - m_currentSelectedInput = 1; - } - UpdateLabels(); - m_sizeIsDirty = true; - } - else - { - m_inputPorts[ 0 ].Name = m_optionNames[ 0 ]; - m_inputPorts[ 1 ].Name = m_optionNames[ 1 ]; - - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - UpdateLabels(); - m_sizeIsDirty = true; - } - } - - if( !m_toggleMode ) - { - EditorGUI.BeginChangeCheck(); - m_maxAmountInputs = EditorGUILayoutIntSlider( MaxAmountStr, m_maxAmountInputs, 2, MaxAllowedAmount ); - if( EditorGUI.EndChangeCheck() ) - { - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - UpdateLabels(); - m_sizeIsDirty = true; - } - - EditorGUI.indentLevel++; - for( int i = 0; i < m_maxAmountInputs; i++ ) - { - EditorGUI.BeginChangeCheck(); - m_inputPorts[ i ].Name = EditorGUILayoutTextField( "Item " + i, m_inputPorts[ i ].Name ); - if( EditorGUI.EndChangeCheck() ) - { - m_nameModified = true; - m_lastTimeNameModified = EditorApplication.timeSinceStartup; - m_inputPorts[ i ].Name = UIUtils.RemoveInvalidEnumCharacters( m_inputPorts[ i ].Name ); - m_optionNames[ i ] = m_inputPorts[ i ].Name; - if( string.IsNullOrEmpty( m_inputPorts[ i ].Name ) ) - { - m_inputPorts[ i ].Name = InputPortNameStr + i; - } - m_sizeIsDirty = true; - } - } - EditorGUI.indentLevel--; - - if( m_nameModified ) - { - UpdateLabels(); - } - } - - if( m_toggleMode ) - { - EditorGUI.BeginChangeCheck(); - int prevVal = m_currentSelectedInput; - m_currentSelectedInput = EditorGUILayoutToggle( CurrSelectedStr, ( m_currentSelectedInput != 0 ? true : false ) ) ? 1 : 0; - if( EditorGUI.EndChangeCheck() ) - SetCurrentSelectedInput( m_currentSelectedInput, prevVal ); - } - else - { - EditorGUI.BeginChangeCheck(); - int prevVal = m_currentSelectedInput; - m_currentSelectedInput = EditorGUILayoutIntPopup( CurrSelectedStr, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues ); - if( EditorGUI.EndChangeCheck() ) - { - SetCurrentSelectedInput( m_currentSelectedInput, prevVal ); - } - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( UIUtils.CurrentShaderVersion() > 14205 ) - { - if( m_referenceType == TexReferenceType.Instance ) - { - m_functionSwitchReference = UIUtils.GetNode( m_referenceUniqueId ) as FunctionSwitch; - UpdateFromSelected(); - } - } - - SetCurrentSelectedInput( m_currentSelectedInput, m_previousSelectedInput ); - } - - public void UpdateLabels() - { - int maxinputs = m_maxAmountInputs; - if( m_validReference ) - maxinputs = m_functionSwitchReference.MaxAmountInputs; - - AvailableInputsLabels = new string[ maxinputs ]; - AvailableInputsValues = new int[ maxinputs ]; - - for( int i = 0; i < maxinputs; i++ ) - { - AvailableInputsLabels[ i ] = m_optionNames[ i ]; - AvailableInputsValues[ i ] = i; - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - CheckReference(); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - float finalSize = 0; - if( !m_toggleMode ) - { - GUIContent dropdown = new GUIContent( m_inputPorts[ m_currentSelectedInput ].Name ); - int cacheSize = UIUtils.GraphDropDown.fontSize; - UIUtils.GraphDropDown.fontSize = 10; - Vector2 calcSize = UIUtils.GraphDropDown.CalcSize( dropdown ); - UIUtils.GraphDropDown.fontSize = cacheSize; - finalSize = Mathf.Clamp( calcSize.x, MinComboSize, MaxComboSize ); - if( m_insideSize.x != finalSize ) - { - m_insideSize.Set( finalSize, 25 ); - m_sizeIsDirty = true; - } - } - - base.OnNodeLayout( drawInfo ); - - bool toggleMode = m_toggleMode; - if( m_validReference ) - { - toggleMode = m_functionSwitchReference.m_toggleMode; - } - - if( toggleMode ) - { - m_varRect = m_remainingBox; - m_varRect.size = Vector2.one * 22 * drawInfo.InvertedZoom; - m_varRect.center = m_remainingBox.center; - if( m_showPreview ) - m_varRect.y = m_remainingBox.y; - } - else - { - m_varRect = m_remainingBox; - m_varRect.width = finalSize * drawInfo.InvertedZoom; - m_varRect.height = 16 * drawInfo.InvertedZoom; - m_varRect.x = m_remainingBox.xMax - m_varRect.width; - m_varRect.y += 1 * drawInfo.InvertedZoom; - - m_imgRect = m_varRect; - m_imgRect.x = m_varRect.xMax - 16 * drawInfo.InvertedZoom; - m_imgRect.width = 16 * drawInfo.InvertedZoom; - m_imgRect.height = m_imgRect.width; - } - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - if( m_validReference ) - { - base.DrawGUIControls( drawInfo ); - } - else - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - if( m_varRect.Contains( drawInfo.MousePosition ) ) - { - m_editing = true; - } - else if( m_editing ) - { - m_editing = false; - } - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_nameModified ) - { - if( ( EditorApplication.timeSinceStartup - m_lastTimeNameModified ) > MaxTimestamp ) - { - m_nameModified = false; - } - } - - if( m_validReference ) - { - SetAdditonalTitleTextOnCallback( m_functionSwitchReference.OptionLabel, ( instance, newSubTitle ) => instance.AdditonalTitleContent.text = string.Format( Constants.SubTitleVarNameFormatStr, newSubTitle ) ); - } - else - { - SetAdditonalTitleTextOnCallback( m_optionLabel, ( instance, newSubTitle ) => instance.AdditonalTitleContent.text = string.Format( Constants.SubTitleValueFormatStr, newSubTitle ) ); - - if( m_editing ) - { - if( m_toggleMode ) - { - if( GUI.Button( m_varRect, GUIContent.none, UIUtils.GraphButton ) ) - { - PreviewIsDirty = true; - int prevVal = m_currentSelectedInput; - m_currentSelectedInput = m_currentSelectedInput == 1 ? 0 : 1; - if( m_currentSelectedInput != prevVal ) - SetCurrentSelectedInput( m_currentSelectedInput, prevVal ); - m_editing = false; - } - - if( m_currentSelectedInput == 1 ) - { - GUI.Label( m_varRect, m_checkContent, UIUtils.GraphButtonIcon ); - } - } - else - { - EditorGUI.BeginChangeCheck(); - int prevVal = m_currentSelectedInput; - m_currentSelectedInput = EditorGUIIntPopup( m_varRect, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues, UIUtils.GraphDropDown ); - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - SetCurrentSelectedInput( m_currentSelectedInput, prevVal ); - m_editing = false; - } - } - } - } - - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - if( m_validReference ) - { - bool cacheState = GUI.enabled; - GUI.enabled = false; - if( m_functionSwitchReference.m_toggleMode ) - { - GUI.Label( m_varRect, GUIContent.none, UIUtils.GraphButton ); - if( m_functionSwitchReference.GetCurrentSelectedInput() == 1 ) - { - GUI.Label( m_varRect, m_checkContent, UIUtils.GraphButtonIcon ); - } - } - else - { - GUI.Label( m_varRect, m_functionSwitchReference.AvailableInputsLabels[ m_currentSelectedInput ], UIUtils.GraphDropDown ); - } - GUI.enabled = cacheState; - } - else - { - if( !m_editing ) - { - if( m_toggleMode ) - { - GUI.Label( m_varRect, GUIContent.none, UIUtils.GraphButton ); - - if( m_currentSelectedInput == 1 ) - { - GUI.Label( m_varRect, m_checkContent, UIUtils.GraphButtonIcon ); - } - } - else - { - GUI.Label( m_varRect, AvailableInputsLabels[ m_currentSelectedInput ], UIUtils.GraphDropDown ); - GUI.Label( m_imgRect, m_popContent, UIUtils.GraphButtonIcon ); - } - } - } - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - m_inputPorts[ m_currentSelectedInput ].GetOutputNode().PropagateNodeData( nodeData, ref dataCollector ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - return m_inputPorts[ m_currentSelectedInput ].GeneratePortInstructions( ref dataCollector ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_optionLabel = GetCurrentParam( ref nodeParams ); - m_toggleMode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_currentSelectedInput = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_previousSelectedInput = m_currentSelectedInput; - m_maxAmountInputs = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - for( int i = 0; i < m_maxAmountInputs; i++ ) - { - m_optionNames[ i ] = GetCurrentParam( ref nodeParams ); - m_inputPorts[ i ].Name = m_optionNames[ i ]; - } - - if( m_toggleMode ) - { - m_inputPorts[ 0 ].Name = ToggleFalseStr; - m_inputPorts[ 1 ].Name = ToggleTrueStr; - } - - UpdateLabels(); - m_sizeIsDirty = true; - - UIUtils.UpdateFunctionSwitchData( UniqueId, m_optionLabel ); - UIUtils.UpdateFunctionSwitchCopyData( UniqueId, m_optionLabel ); - if( UIUtils.CurrentShaderVersion() > 14205 ) - { - m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) ); - m_referenceUniqueId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - if( m_referenceType == TexReferenceType.Object ) - { - if( ContainerGraph.ParentWindow.CustomGraph == null ) - UIUtils.UnregisterFunctionSwitchCopyNode( this ); - UIUtils.RegisterFunctionSwitchNode( this ); - ResetToSelf(); - } - else - { - if( ContainerGraph.ParentWindow.CustomGraph == null ) - UIUtils.UnregisterFunctionSwitchNode( this ); - UIUtils.RegisterFunctionSwitchCopyNode( this ); - } - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_optionLabel ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_toggleMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentSelectedInput ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_maxAmountInputs ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_orderIndex ); - - for( int i = 0; i < m_maxAmountInputs; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_optionNames[ i ] ); - } - - IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceType ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_functionSwitchReference != null ? m_functionSwitchReference.UniqueId : -1 ) ); - } - - public int OrderIndex - { - get { return m_orderIndex; } - set { m_orderIndex = value; } - } - - public string OptionLabel - { - get { return m_optionLabel; } - set { m_optionLabel = value; } - } - - public bool AsDrawn { get { return m_asDrawn; } set { m_asDrawn = value; } } - - public override string DataToArray { get { return m_optionLabel; } } - public int MaxAmountInputs - { - get { return m_maxAmountInputs; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs.meta deleted file mode 100644 index 8929a454..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitch.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2bd66b9ffd0acf84ab46c9f83300495c -timeCreated: 1515408158 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs deleted file mode 100644 index 5a05605e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs +++ /dev/null @@ -1,102 +0,0 @@ -// 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( "Switch by Pipeline", "Functions", "Executes branch according to current pipeline", NodeAvailabilityFlags = (int)NodeAvailability.ShaderFunction )] - public sealed class FunctionSwitchByPipeline : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Surface", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT, false, "Default RP", -1, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, false, "Lightweight", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "HD", -1, MasterNodePortCategory.Fragment, 2 ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - GetInputPortByUniqueId( portId ).MatchPortToConnection(); - UpdateOutputPort(); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - GetInputPortByUniqueId( outputPortId ).MatchPortToConnection(); - UpdateOutputPort(); - } - - void UpdateOutputPort() - { - switch( UIUtils.CurrentWindow.OutsideGraph.CurrentSRPType ) - { - case TemplateSRPType.BuiltIn: - { - InputPort port = UIUtils.CurrentWindow.OutsideGraph.IsStandardSurface ? GetInputPortByUniqueId( 0 ) : GetInputPortByUniqueId( 3 ); - m_outputPorts[ 0 ].ChangeType( port.DataType, false ); - } - break; - case TemplateSRPType.Lightweight: - { - InputPort port = GetInputPortByUniqueId( 1 ); - m_outputPorts[ 0 ].ChangeType( port.DataType, false ); - } - break; - case TemplateSRPType.HD: - { - InputPort port = GetInputPortByUniqueId( 2 ); - m_outputPorts[ 0 ].ChangeType( port.DataType, false ); - } - break; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - switch( dataCollector.CurrentSRPType ) - { - case TemplateSRPType.BuiltIn: - { - InputPort port = UIUtils.CurrentWindow.OutsideGraph.IsStandardSurface ? GetInputPortByUniqueId( 0 ) : GetInputPortByUniqueId( 3 ); - return port.GeneratePortInstructions( ref dataCollector ); - } - case TemplateSRPType.Lightweight: - { - InputPort port = GetInputPortByUniqueId( 1 ); - return port.GeneratePortInstructions( ref dataCollector ); - } - case TemplateSRPType.HD: - { - InputPort port = GetInputPortByUniqueId( 2 ); - return port.GeneratePortInstructions( ref dataCollector ); - } - } - - return "0"; - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( UIUtils.CurrentShaderVersion() < 16303 ) - { - InputPort standardPort = GetInputPortByUniqueId( 0 ); - if( standardPort.IsConnected ) - { - UIUtils.SetConnection( UniqueId, 3, standardPort.GetConnection().NodeId, standardPort.GetConnection().PortId ); - } - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs.meta deleted file mode 100644 index 9ecd8080..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/FunctionSwitchByPipeline.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 84a4868e0b1e8dd4bb0e71c8d9a9c130 -timeCreated: 1535365719 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs deleted file mode 100644 index d431cbb8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Log", "Master", "Debug node to dump output to log", null, KeyCode.None, false )] - public sealed class LogNode : MasterNode - { - private const string InputAmountStr = "Input amount"; - - [SerializeField] - private int m_inputCount = 1; - - [SerializeField] - private int m_lastInputCount = 1; - - public LogNode() : base() { } - public LogNode( 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 ); - AddMasterPorts(); - } - - public override void AddMasterPorts() - { - DeleteAllInputConnections( true ); - base.AddMasterPorts(); - - for ( int i = 0; i < m_inputCount; i++ ) - { - AddInputPort( WirePortDataType.OBJECT, false, i.ToString() ); - } - m_sizeIsDirty = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - { - EditorGUILayout.LabelField( InputAmountStr ); - m_inputCount = EditorGUILayoutIntField( m_inputCount ); - } - EditorGUILayout.EndVertical(); - if ( m_inputCount != m_lastInputCount ) - { - m_lastInputCount = Mathf.Max( m_inputCount, 1 ); - AddMasterPorts(); - } - } - - public override void Execute( Shader currentSelected ) - { - string valueDump = ""; - string valueInstructions = ""; - - MasterNodeDataCollector dataCollector = new MasterNodeDataCollector( this ); - foreach ( InputPort port in InputPorts ) - { - if ( port.IsConnected ) - { - valueInstructions += "Port: " + port.PortId + " Value: " + port.GenerateShaderForOutput( ref dataCollector, port.DataType, false ); - } - } - Debug.Log( "Value: " + valueDump ); - Debug.Log( "Instructions: " + valueInstructions ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs.meta deleted file mode 100644 index d2debabc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/LogNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3b0e734d4c354c74999e20ce054628d2 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs deleted file mode 100644 index 5e4ec937..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs +++ /dev/null @@ -1,979 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; - -namespace AmplifyShaderEditor -{ - public enum PrecisionType - { - Float = 0, - Half, - Inherit - } - - public enum AvailableShaderTypes - { - SurfaceShader = 0, - Template - } - - [Serializable] - public class MasterNodeCategoriesData - { - public AvailableShaderTypes Category; - public string Name; - public MasterNodeCategoriesData( AvailableShaderTypes category, string name ) { Category = category; Name = name; } - } - - [Serializable] - public class MasterNode : OutputNode - { - protected const string CustomInspectorStr = "Custom Editor"; - protected const string CustomInspectorFormat = "CustomEditor \"{0}\""; - - private const string PropertyOrderFoldoutStr = " Material Properties"; - private const string PropertyOrderTemplateFoldoutStr = "Material Properties"; - - protected MasterNodeDataCollector m_currentDataCollector; - - protected const string ShaderNameStr = "Shader Name"; - protected GUIContent m_shaderNameContent; - - private const string IndentationHelper = "\t\t{0}\n"; - private const string ShaderLODFormat = "\t\tLOD {0}\n"; - - public delegate void OnMaterialUpdated( MasterNode masterNode ); - public event OnMaterialUpdated OnMaterialUpdatedEvent; - public event OnMaterialUpdated OnShaderUpdatedEvent; - - protected const string GeneralFoldoutStr = " General"; - - protected readonly string[] ShaderModelTypeArr = { "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "4.6", "5.0" }; - private const string ShaderKeywordsStr = "Shader Keywords"; - - [SerializeField] - protected int m_shaderLOD = 0; - - [SerializeField] - protected int m_shaderModelIdx = 2; - - [SerializeField] - protected Shader m_currentShader; - - [SerializeField] - protected Material m_currentMaterial; - - //[SerializeField] - //private bool m_isMainMasterNode = false; - - [SerializeField] - private Rect m_masterNodeIconCoords; - - [SerializeField] - protected string m_shaderName = Constants.DefaultShaderName; - - [SerializeField] - protected string m_croppedShaderName = Constants.DefaultShaderName; - - [SerializeField] - protected string m_customInspectorName = Constants.DefaultCustomInspector; - - [SerializeField] - protected int m_masterNodeCategory = 0;// MasterNodeCategories.SurfaceShader; - - [SerializeField] - protected string m_currentShaderData = string.Empty; - - private Texture2D m_masterNodeOnTex; - private Texture2D m_masterNodeOffTex; - - private Texture2D m_gpuInstanceOnTex; - private Texture2D m_gpuInstanceOffTex; - - // Shader Keywords - [SerializeField] - private List<string> m_shaderKeywords = new List<string>(); - - [SerializeField] - private bool m_shaderKeywordsFoldout = true; - - private GUIStyle m_addShaderKeywordStyle; - private GUIStyle m_removeShaderKeywordStyle; - private GUIStyle m_smallAddShaderKeywordItemStyle; - private GUIStyle m_smallRemoveShaderKeywordStyle; - private const float ShaderKeywordButtonLayoutWidth = 15; - - - public MasterNode() : base() { CommonInit(); } - public MasterNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { CommonInit(); } - - protected GUIContent m_categoryLabel = new GUIContent( "Shader Type ", "Specify the shader type you want to be working on" ); - - protected GUIContent[] m_availableCategoryLabels; - protected MasterNodeCategoriesData[] m_availableCategories; - - [SerializeField] - private List<PropertyNode> m_propertyNodesVisibleList = new List<PropertyNode>(); - - private ReorderableList m_propertyReordableList; - protected bool m_propertyOrderChanged = false; - //private int m_availableCount = 0; - private int m_lastCount = 0; - - private GUIStyle m_propertyAdjustment; - protected bool m_shaderNameIsTitle = true; - - void CommonInit() - { - m_currentMaterial = null; - m_masterNodeIconCoords = new Rect( 0, 0, 64, 64 ); - m_isMainOutputNode = false; - m_connStatus = NodeConnectionStatus.Connected; - m_activeType = GetType(); - m_currentPrecisionType = PrecisionType.Float; - m_textLabelWidth = 120; - m_shaderNameContent = new GUIContent( ShaderNameStr, string.Empty ); - - AddMasterPorts(); - } - - void InitAvailableCategories() - { - int templateCount = m_containerGraph.ParentWindow.TemplatesManagerInstance.TemplateCount; - m_availableCategories = new MasterNodeCategoriesData[ templateCount + 1 ]; - m_availableCategoryLabels = new GUIContent[ templateCount + 1 ]; - - m_availableCategories[ 0 ] = new MasterNodeCategoriesData( AvailableShaderTypes.SurfaceShader, string.Empty ); - m_availableCategoryLabels[ 0 ] = new GUIContent( "Surface" ); - - for( int i = 0; i < templateCount; i++ ) - { - int idx = i + 1; - TemplateDataParent templateData = m_containerGraph.ParentWindow.TemplatesManagerInstance.GetTemplate( i ); - m_availableCategories[ idx ] = new MasterNodeCategoriesData( AvailableShaderTypes.Template, templateData.GUID ); - m_availableCategoryLabels[ idx ] = new GUIContent( templateData.Name ); - } - } - - public void SetMasterNodeCategoryFromGUID( string GUID ) - { - if( m_availableCategories == null ) - InitAvailableCategories(); - - m_masterNodeCategory = 0; - for( int i = 1; i < m_availableCategories.Length; i++ ) - { - if( m_availableCategories[ i ].Name.Equals( GUID ) ) - m_masterNodeCategory = i; - } - - } - - public override void SetupNodeCategories() - { - //base.SetupNodeCategories(); - ContainerGraph.ResetNodesData(); - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - NodeData nodeData = new NodeData( m_inputPorts[ i ].Category ); - ParentNode node = m_inputPorts[ i ].GetOutputNode(); - node.PropagateNodeData( nodeData, ref m_currentDataCollector ); - } - else if( m_inputPorts[ i ].HasExternalLink ) - { - InputPort linkedPort = m_inputPorts[ i ].ExternalLink; - if( linkedPort != null && linkedPort.IsConnected ) - { - NodeData nodeData = new NodeData( linkedPort.Category ); - ParentNode node = linkedPort.GetOutputNode(); - node.PropagateNodeData( nodeData, ref m_currentDataCollector ); - } - } - } - } - - public virtual void RefreshAvailableCategories() - { - InitAvailableCategories(); - } - - public virtual void AddMasterPorts() { } - - public virtual void ForcePortType() { } - - public virtual void UpdateMasterNodeMaterial( Material material ) { } - - public virtual void SetName( string name ) { } - - public void CopyFrom( MasterNode other ) - { - Vec2Position = other.Vec2Position; - CurrentShader = other.CurrentShader; - CurrentMaterial = other.CurrentMaterial; - ShaderName = other.ShaderName; - m_masterNodeCategory = other.CurrentMasterNodeCategoryIdx; - } - - protected void DrawCurrentShaderType() - { - if( m_availableCategories == null ) - InitAvailableCategories(); - - int oldType = m_masterNodeCategory; - m_masterNodeCategory = EditorGUILayoutPopup( m_categoryLabel, m_masterNodeCategory, m_availableCategoryLabels ); - if( oldType != m_masterNodeCategory ) - { - m_containerGraph.ParentWindow.ReplaceMasterNode( m_availableCategories[ m_masterNodeCategory ], false ); - } - } - - protected void DrawCustomInspector( bool dropdown ) - { -#if !UNITY_2018_3_OR_NEWER - dropdown = false; -#else - if( ASEPackageManagerHelper.CurrentHDVersion <= ASESRPVersions.ASE_SRP_5_16_1 ) - dropdown = false; -#endif - - EditorGUILayout.BeginHorizontal(); - m_customInspectorName = EditorGUILayoutTextField( CustomInspectorStr, m_customInspectorName ); - if( !dropdown ) - { - if( GUILayoutButton( string.Empty, UIUtils.GetCustomStyle( CustomStyle.ResetToDefaultInspectorButton ), GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) ) - { - GUIUtility.keyboardControl = 0; - m_customInspectorName = Constants.DefaultCustomInspector; - } - } - else - { - if( GUILayoutButton( string.Empty, UIUtils.InspectorPopdropdownFallback, GUILayout.Width( 17 ), GUILayout.Height( 19 ) ) ) - { - EditorGUI.FocusTextInControl( null ); - GUI.FocusControl( null ); - - GenericMenu menu = new GenericMenu(); - AddMenuItem( menu, Constants.DefaultCustomInspector ); -#if UNITY_2018_3_OR_NEWER - if( ASEPackageManagerHelper.CurrentHDVersion > ASESRPVersions.ASE_SRP_6_9_1 ) - { - AddMenuItem( menu, "UnityEditor.Rendering.HighDefinition.HDLitGUI" ); - AddMenuItem( menu, "UnityEditor.ShaderGraph.PBRMasterGUI" ); - } - else - { - AddMenuItem( menu, "UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI" ); - } -#else - AddMenuItem( menu, "UnityEditor.Experimental.Rendering.HDPipeline.HDLitGUI" ); -#endif - menu.ShowAsContext(); - } - } - EditorGUILayout.EndHorizontal(); - } - - private void AddMenuItem( GenericMenu menu, string newClass ) - { - menu.AddItem( new GUIContent( newClass ), m_customInspectorName.Equals( newClass ), OnSelection, newClass ); - } - - private void OnSelection( object newClass ) - { - m_customInspectorName = (string)newClass; - } - - protected void DrawShaderName() - { - EditorGUI.BeginChangeCheck(); - string newShaderName = EditorGUILayoutTextField( m_shaderNameContent, m_shaderName ); - if( EditorGUI.EndChangeCheck() ) - { - if( newShaderName.Length > 0 ) - { - newShaderName = UIUtils.RemoveShaderInvalidCharacters( newShaderName ); - } - else - { - newShaderName = Constants.DefaultShaderName; - } - ShaderName = newShaderName; - ContainerGraph.ParentWindow.UpdateTabTitle( ShaderName, true ); - } - m_shaderNameContent.tooltip = m_shaderName; - } - - public void DrawShaderKeywords() - { - if( m_addShaderKeywordStyle == null ) - m_addShaderKeywordStyle = UIUtils.PlusStyle; - - if( m_removeShaderKeywordStyle == null ) - m_removeShaderKeywordStyle = UIUtils.MinusStyle; - - if( m_smallAddShaderKeywordItemStyle == null ) - m_smallAddShaderKeywordItemStyle = UIUtils.PlusStyle; - - if( m_smallRemoveShaderKeywordStyle == null ) - m_smallRemoveShaderKeywordStyle = UIUtils.MinusStyle; - - EditorGUILayout.BeginHorizontal(); - { - m_shaderKeywordsFoldout = EditorGUILayout.Foldout( m_shaderKeywordsFoldout, ShaderKeywordsStr ); - - // Add keyword - if( GUILayout.Button( string.Empty, m_addShaderKeywordStyle ) ) - { - m_shaderKeywords.Insert( 0, "" ); - } - - //Remove keyword - if( GUILayout.Button( string.Empty, m_removeShaderKeywordStyle ) ) - { - m_shaderKeywords.RemoveAt( m_shaderKeywords.Count - 1 ); - } - } - EditorGUILayout.EndHorizontal(); - - if( m_shaderKeywordsFoldout ) - { - EditorGUI.indentLevel += 1; - int itemCount = m_shaderKeywords.Count; - int markedToDelete = -1; - for( int i = 0; i < itemCount; i++ ) - { - EditorGUILayout.BeginHorizontal(); - { - GUILayout.Label( " " ); - // Add new port - if( GUILayoutButton( string.Empty, m_smallAddShaderKeywordItemStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - m_shaderKeywords.Insert( i, "" ); - } - - //Remove port - if( GUILayoutButton( string.Empty, m_smallRemoveShaderKeywordStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - markedToDelete = i; - } - } - EditorGUILayout.EndHorizontal(); - } - if( markedToDelete > -1 ) - { - m_shaderKeywords.RemoveAt( markedToDelete ); - } - EditorGUI.indentLevel -= 1; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - if( m_availableCategories == null ) - InitAvailableCategories(); - - base.Draw( drawInfo ); - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( m_isMainOutputNode ) - { - if( m_masterNodeOnTex == null ) - { - m_masterNodeOnTex = UIUtils.MasterNodeOnTexture; - } - - if( m_masterNodeOffTex == null ) - { - m_masterNodeOffTex = UIUtils.MasterNodeOffTexture; - } - - if( m_gpuInstanceOnTex == null ) - { - m_gpuInstanceOnTex = UIUtils.GPUInstancedOnTexture; - } - - if( m_gpuInstanceOffTex == null ) - { - m_gpuInstanceOffTex = UIUtils.GPUInstancedOffTexture; - } - - m_masterNodeIconCoords = m_globalPosition; - m_masterNodeIconCoords.x += m_globalPosition.width - m_masterNodeOffTex.width * drawInfo.InvertedZoom; - m_masterNodeIconCoords.y += m_globalPosition.height - m_masterNodeOffTex.height * drawInfo.InvertedZoom; - m_masterNodeIconCoords.width = m_masterNodeOffTex.width * drawInfo.InvertedZoom; - m_masterNodeIconCoords.height = m_masterNodeOffTex.height * drawInfo.InvertedZoom; - - GUI.DrawTexture( m_masterNodeIconCoords, m_masterNodeOffTex ); - - if( m_gpuInstanceOnTex == null ) - { - m_gpuInstanceOnTex = UIUtils.GPUInstancedOnTexture; - } - } - } - - protected void DrawInstancedIcon( DrawInfo drawInfo ) - { - if( m_gpuInstanceOffTex == null || drawInfo.CurrentEventType != EventType.Repaint ) - return; - - m_masterNodeIconCoords = m_globalPosition; - m_masterNodeIconCoords.x += m_globalPosition.width - 5 - m_gpuInstanceOffTex.width * drawInfo.InvertedZoom; - m_masterNodeIconCoords.y += m_headerPosition.height; - m_masterNodeIconCoords.width = m_gpuInstanceOffTex.width * drawInfo.InvertedZoom; - m_masterNodeIconCoords.height = m_gpuInstanceOffTex.height * drawInfo.InvertedZoom; - GUI.DrawTexture( m_masterNodeIconCoords, m_gpuInstanceOffTex ); - } - //public override void DrawProperties() - //{ - // base.DrawProperties(); - // //EditorGUILayout.LabelField( _shaderTypeLabel ); - //} - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - //IOUtils.AddFieldValueToString( ref nodeInfo, m_isMainMasterNode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_shaderModelIdx ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_customInspectorName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_shaderLOD ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_masterNodeCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 21 ) - { - m_shaderModelIdx = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() < 17005 ) - { - string val = GetCurrentParam( ref nodeParams ); - if( m_customPrecision ) - { - if( val.Equals( "Fixed" ) ) - m_currentPrecisionType = PrecisionType.Half; - else - m_currentPrecisionType = (PrecisionType)Enum.Parse( typeof( PrecisionType ), val ); - } - else - { - m_currentPrecisionType = PrecisionType.Inherit; - } - } - } - - if( UIUtils.CurrentShaderVersion() > 2404 ) - { - m_customInspectorName = GetCurrentParam( ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 6101 ) - { - ShaderLOD = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() >= 13001 ) - { - //Debug.LogWarning( "Add correct version as soon as it is merged into master" ); - m_masterNodeCategory = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - if( activateNode ) - { - InputPort port = GetInputPortByUniqueId( portId ); - port.GetOutputNode().ActivateNode( UniqueId, portId, m_activeType ); - } - } - - public void FireMaterialChangedEvt() - { - if( OnMaterialUpdatedEvent != null ) - { - OnMaterialUpdatedEvent( this ); - } - } - - public void FireShaderChangedEvt() - { - if( OnShaderUpdatedEvent != null ) - OnShaderUpdatedEvent( this ); - } - - public void RegisterStandaloneFuntions() - { - List<CustomExpressionNode> nodes = m_containerGraph.CustomExpressionOnFunctionMode.NodesList; - int count = nodes.Count; - Dictionary<int, CustomExpressionNode> examinedNodes = new Dictionary<int, CustomExpressionNode>(); - for( int i = 0; i < count; i++ ) - { - if( nodes[ i ].AutoRegisterMode ) - { - nodes[ i ].CheckDependencies( ref m_currentDataCollector, ref examinedNodes ); - } - } - examinedNodes.Clear(); - examinedNodes = null; - } - - // What operation this node does - public virtual void Execute( Shader selectedShader ) - { - Execute( AssetDatabase.GetAssetPath( selectedShader ), false ); - } - - public virtual Shader Execute( string pathname, bool isFullPath ) - { - ContainerGraph.ResetNodesLocalVariables(); - m_currentDataCollector = new MasterNodeDataCollector( this ); - return null; - } - - protected void SortInputPorts( ref List<InputPort> vertexPorts, ref List<InputPort> fragmentPorts ) - { - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].Category == MasterNodePortCategory.Fragment || m_inputPorts[ i ].Category == MasterNodePortCategory.Debug ) - { - if( fragmentPorts != null ) - fragmentPorts.Add( m_inputPorts[ i ] ); - } - else - { - if( vertexPorts != null ) - vertexPorts.Add( m_inputPorts[ i ] ); - } - } - - if( fragmentPorts.Count > 0 ) - { - fragmentPorts.Sort( ( x, y ) => x.OrderId.CompareTo( y.OrderId ) ); - } - - if( vertexPorts.Count > 0 ) - { - vertexPorts.Sort( ( x, y ) => x.OrderId.CompareTo( y.OrderId ) ); - } - } - - protected void UpdateShaderAsset( ref string pathname, ref string shaderBody, bool isFullPath ) - { - // Generate Graph info - shaderBody += ContainerGraph.ParentWindow.GenerateGraphInfo(); - - //TODO: Remove current SaveDebugShader and uncomment SaveToDisk as soon as pathname is editable - if( !String.IsNullOrEmpty( pathname ) ) - { - IOUtils.StartSaveThread( shaderBody, ( isFullPath ? pathname : ( IOUtils.dataPath + pathname ) ) ); - } - else - { - IOUtils.StartSaveThread( shaderBody, Application.dataPath + "/AmplifyShaderEditor/Samples/Shaders/" + m_shaderName + ".shader" ); - } - - - if( CurrentShader == null ) - { - AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate ); - CurrentShader = Shader.Find( ShaderName ); - } - //else - //{ - // // need to always get asset datapath because a user can change and asset location from the project window - // AssetDatabase.ImportAsset( AssetDatabase.GetAssetPath( m_currentShader ) ); - // //ShaderUtil.UpdateShaderAsset( m_currentShader, ShaderBody ); - // //ShaderImporter importer = (ShaderImporter)ShaderImporter.GetAtPath( AssetDatabase.GetAssetPath( CurrentShader ) ); - // //importer.SaveAndReimport(); - //} - - if( m_currentShader != null ) - { - m_currentDataCollector.UpdateShaderImporter( ref m_currentShader ); - if( m_currentMaterial != null ) - { - if( m_currentMaterial.shader != m_currentShader ) - m_currentMaterial.shader = m_currentShader; - - //m_currentDataCollector.UpdateMaterialOnPropertyNodes( m_currentMaterial ); - //This master node UpdateMaterial is needed on Standard Surface node to update its internal properties - UpdateMaterial( m_currentMaterial ); - - UIUtils.CurrentWindow.OutsideGraph.UpdateMaterialOnPropertyNodes( m_currentMaterial ); - - FireMaterialChangedEvt(); - // need to always get asset datapath because a user can change and asset location from the project window - //AssetDatabase.ImportAsset( AssetDatabase.GetAssetPath( m_currentMaterial ) ); - } - - } - - m_currentDataCollector.Destroy(); - m_currentDataCollector = null; - } - - - public void InvalidateMaterialPropertyCount() - { - m_lastCount = -1; - } - - private void RefreshVisibleList( ref List<PropertyNode> allNodes ) - { - // temp reference for lambda expression - List<PropertyNode> nodes = allNodes; - m_propertyNodesVisibleList.Clear(); - - for( int i = 0; i < nodes.Count; i++ ) - { - ReordenatorNode rnode = nodes[ i ] as ReordenatorNode; - if( ( rnode == null || !rnode.IsInside ) && ( !m_propertyNodesVisibleList.Exists( x => x.PropertyName.Equals( nodes[ i ].PropertyName ) ) ) ) - m_propertyNodesVisibleList.Add( nodes[ i ] ); - } - - m_propertyNodesVisibleList.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - } - - public void DrawMaterialInputs( GUIStyle toolbarstyle, bool style = true ) - { - m_propertyOrderChanged = false; - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( toolbarstyle ); - GUI.color = cachedColor; - - EditorGUI.BeginChangeCheck(); - if( style ) - { - ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties = GUILayoutToggle( ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties, PropertyOrderFoldoutStr, UIUtils.MenuItemToggleStyle ); - } - else - { - ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties = GUILayoutToggle( ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties, PropertyOrderTemplateFoldoutStr, UIUtils.MenuItemToggleStyle ); - } - - if( EditorGUI.EndChangeCheck() ) - { - EditorPrefs.SetBool( "ExpandedProperties", ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties ); - } - - EditorGUILayout.EndHorizontal(); - if( !ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties ) - return; - - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - - List<PropertyNode> nodes = UIUtils.PropertyNodesList(); - - if( nodes.Count != m_lastCount ) - { - RefreshVisibleList( ref nodes ); - m_lastCount = nodes.Count; - } - - if( m_propertyReordableList == null ) - { - m_propertyReordableList = new ReorderableList( m_propertyNodesVisibleList, typeof( PropertyNode ), true, false, false, false ) - { - headerHeight = 0, - footerHeight = 0, - showDefaultBackground = false, - - drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) => - { - var first = rect; - first.width *= 0.60f; - EditorGUI.LabelField( first, m_propertyNodesVisibleList[ index ].PropertyInspectorName ); - var second = rect; - second.width *= 0.4f; - second.x += first.width; - if( GUI.Button( second, m_propertyNodesVisibleList[ index ].PropertyName, new GUIStyle( "AssetLabel Partial" ) ) ) - { - UIUtils.FocusOnNode( m_propertyNodesVisibleList[ index ], 1, false ); - } - }, - - onReorderCallback = ( list ) => - { - ReorderList( ref nodes ); - m_propertyOrderChanged = true; - //RecursiveLog(); - } - }; - ReorderList( ref nodes ); - } - - if( m_propertyReordableList != null ) - { - if( m_propertyAdjustment == null ) - { - m_propertyAdjustment = new GUIStyle(); - m_propertyAdjustment.padding.left = 17; - } - EditorGUILayout.BeginVertical( m_propertyAdjustment ); - m_propertyReordableList.DoLayoutList(); - EditorGUILayout.EndVertical(); - } - EditorGUILayout.EndVertical(); - } - - public void ForceReordering() - { - List<PropertyNode> nodes = UIUtils.PropertyNodesList(); - - if( nodes.Count != m_lastCount ) - { - RefreshVisibleList( ref nodes ); - m_lastCount = nodes.Count; - } - - ReorderList( ref nodes ); - //RecursiveLog(); - } - - private void RecursiveLog() - { - List<PropertyNode> nodes = UIUtils.PropertyNodesList(); - nodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - for( int i = 0; i < nodes.Count; i++ ) - { - if( ( nodes[ i ] is ReordenatorNode ) ) - ( nodes[ i ] as ReordenatorNode ).RecursiveLog(); - else - Debug.Log( nodes[ i ].OrderIndex + " " + nodes[ i ].PropertyName ); - } - } - - private void ReorderList( ref List<PropertyNode> nodes ) - { - // clear lock list before reordering because of multiple sf being used - for( int i = 0; i < nodes.Count; i++ ) - { - ReordenatorNode rnode = nodes[ i ] as ReordenatorNode; - if( rnode != null ) - rnode.RecursiveClear(); - } - - int propoffset = 0; - int count = 0; - for( int i = 0; i < m_propertyNodesVisibleList.Count; i++ ) - { - ReordenatorNode renode = m_propertyNodesVisibleList[ i ] as ReordenatorNode; - if( renode != null ) - { - if( !renode.IsInside ) - { - m_propertyNodesVisibleList[ i ].OrderIndex = count + propoffset; - - if( renode.PropertyListCount > 0 ) - { - propoffset += renode.RecursiveCount(); - // the same reordenator can exist multiple times, apply ordering to all of them - for( int j = 0; j < nodes.Count; j++ ) - { - ReordenatorNode pnode = ( nodes[ j ] as ReordenatorNode ); - if( pnode != null && pnode.PropertyName.Equals( renode.PropertyName ) ) - { - pnode.OrderIndex = renode.RawOrderIndex; - pnode.RecursiveSetOrderOffset( renode.RawOrderIndex, true ); - } - } - } - else - { - count++; - } - } - else - { - m_propertyNodesVisibleList[ i ].OrderIndex = 0; - } - } - else - { - m_propertyNodesVisibleList[ i ].OrderIndex = count + propoffset; - count++; - } - } - } - - public void CopyPropertyListFrom( MasterNode masterNode ) - { - m_lastCount = masterNode.ReordableListLastCount; - m_propertyNodesVisibleList.Clear(); - m_propertyNodesVisibleList.AddRange( masterNode.PropertyNodesVisibleList ); - } - - public virtual void UpdateFromShader( Shader newShader ) { } - - public void ClearUpdateEvents() - { - OnShaderUpdatedEvent = null; - OnMaterialUpdatedEvent = null; - } - - public Material CurrentMaterial { get { return m_currentMaterial; } set { m_currentMaterial = value; } } - public Shader CurrentShader - { - set - { - if( value != null ) - { - SetName( value.name ); - } - - m_currentShader = value; - FireShaderChangedEvt(); - } - get { return m_currentShader; } - } - public virtual void OnRefreshLinkedPortsComplete() { } - public virtual void ReleaseResources() { } - public override void Destroy() - { - base.Destroy(); - OnMaterialUpdatedEvent = null; - OnShaderUpdatedEvent = null; - m_masterNodeOnTex = null; - m_masterNodeOffTex = null; - m_gpuInstanceOnTex = null; - m_gpuInstanceOffTex = null; - m_addShaderKeywordStyle = null; - m_removeShaderKeywordStyle = null; - m_smallAddShaderKeywordItemStyle = null; - m_smallRemoveShaderKeywordStyle = null; - m_shaderKeywords.Clear(); - m_shaderKeywords = null; - m_propertyReordableList = null; - m_propertyAdjustment = null; - if( m_currentDataCollector != null ) - { - m_currentDataCollector.Destroy(); - m_currentDataCollector = null; - } - } - - public static void OpenShaderBody( ref string result, string name ) - { - result += string.Format( "Shader \"{0}\"\n", name ) + "{\n"; - } - - public static void CloseShaderBody( ref string result ) - { - result += "}\n"; - } - - public static void OpenSubShaderBody( ref string result ) - { - result += "\n\tSubShader\n\t{\n"; - } - - public static void CloseSubShaderBody( ref string result ) - { - result += "\t}\n"; - } - - public static void AddShaderProperty( ref string result, string name, string value ) - { - result += string.Format( "\t{0} \"{1}\"\n", name, value ); - } - - public static void AddShaderPragma( ref string result, string value ) - { - result += string.Format( "\t\t#pragma {0}\n", value ); - } - - public static void AddRenderState( ref string result, string state, string stateParams ) - { - result += string.Format( "\t\t{0} {1}\n", state, stateParams ); - } - - public static void AddRenderTags( ref string result, string tags ) - { - result += string.Format( IndentationHelper, tags ); ; - } - - public static void AddShaderLOD( ref string result, int shaderLOD ) - { - if( shaderLOD > 0 ) - { - result += string.Format( ShaderLODFormat, shaderLOD ); - } - } - - public static void AddMultilineBody( ref string result, string[] lines ) - { - for( int i = 0; i < lines.Length; i++ ) - { - result += string.Format( IndentationHelper, lines[ i ] ); - } - } - - public static void OpenCGInclude( ref string result ) - { - result += "\t\tCGINCLUDE\n"; - } - - public static void OpenCGProgram( ref string result ) - { - result += "\t\tCGPROGRAM\n"; - } - - public static void CloseCGProgram( ref string result ) - { - result += "\n\t\tENDCG\n"; - } - - public string ShaderName - { - //get { return ( ( _isHidden ? "Hidden/" : string.Empty ) + ( String.IsNullOrEmpty( _shaderCategory ) ? "" : ( _shaderCategory + "/" ) ) + _shaderName ); } - get { return m_shaderName; } - set - { - m_shaderName = value; - string[] shaderNameArr = m_shaderName.Split( '/' ); - m_croppedShaderName = shaderNameArr[ shaderNameArr.Length - 1 ]; - - if( m_shaderNameIsTitle ) - m_content.text = GenerateClippedTitle( m_croppedShaderName ); - - m_sizeIsDirty = true; - } - } - public string CustomInspectorFormatted { get { return string.Format( CustomInspectorFormat, m_customInspectorName ); } } - public string CroppedShaderName { get { return m_croppedShaderName; } } - public AvailableShaderTypes CurrentMasterNodeCategory { get { return ( m_masterNodeCategory == 0 ) ? AvailableShaderTypes.SurfaceShader : AvailableShaderTypes.Template; } } - public int CurrentMasterNodeCategoryIdx { get { return m_masterNodeCategory; } } - public MasterNodeDataCollector CurrentDataCollector { get { return m_currentDataCollector; } set { m_currentDataCollector = value; } } - public List<PropertyNode> PropertyNodesVisibleList { get { return m_propertyNodesVisibleList; } } - public ReorderableList PropertyReordableList { get { return m_propertyReordableList; } } - public int ReordableListLastCount { get { return m_lastCount; } } - public MasterNodeCategoriesData CurrentCategoriesData { get { return m_availableCategories[ m_masterNodeCategory ]; } } - public int ShaderLOD - { - get { return m_shaderLOD; } - set - { - m_shaderLOD = Mathf.Max( 0, value ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs.meta deleted file mode 100644 index 8a8a9339..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7fc2c839ab9f3a045877b59493c51502 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs deleted file mode 100644 index d6fce5fd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs +++ /dev/null @@ -1,2038 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using System.Text.RegularExpressions; - -namespace AmplifyShaderEditor -{ - public class PropertyDataCollector - { - public int NodeId; - public int OrderIndex; - public string PropertyName; - public WirePortDataType DataType; - - public PropertyDataCollector( int nodeId, string propertyName, int orderIndex = -1 ) - { - NodeId = nodeId; - PropertyName = propertyName; - OrderIndex = orderIndex; - } - } - - public class InputCoordsCollector - { - public int NodeId; - public string CoordName; - public WirePortDataType DataType; - public PrecisionType Precision; - public int TextureSlot; - public int TextureIndex; - - public InputCoordsCollector( int nodeId, string coordName, WirePortDataType dataType, PrecisionType precision, int textureSlot, int textureIndex ) - { - NodeId = nodeId; - CoordName = coordName; - DataType = dataType; - Precision = precision; - TextureSlot = textureSlot; - TextureIndex = textureIndex; - } - } - - public class TextureDefaultsDataColector - { - private List<string> m_names = new List<string>(); - private List<Texture> m_values = new List<Texture>(); - public void AddValue( string newName, Texture newValue ) - { - m_names.Add( newName ); - m_values.Add( newValue ); - } - - public void Destroy() - { - m_names.Clear(); - m_names = null; - - m_values.Clear(); - m_values = null; - } - - public string[] NamesArr { get { return m_names.ToArray(); } } - public Texture[] ValuesArr { get { return m_values.ToArray(); } } - } - - public enum TextureChannelUsage - { - Not_Used, - Used, - Required - } - - public class MasterNodeDataCollector - { - private bool m_showDebugMessages = false; - private string m_input; - private string m_customInput; - private string m_properties; - private string m_instancedProperties; - private string m_instanceBlockName; - private string m_uniforms; - private string m_includes; - private string m_pragmas; - private string m_defines; - private string m_instructions; - private string m_localVariables; - private string m_vertexLocalVariables; - private string m_specialLocalVariables; - private string m_vertexData; - private string m_customOutput; - private string m_functions; - private string m_grabPass; - - private List<PropertyDataCollector> m_inputList; - private List<PropertyDataCollector> m_customInputList; - private List<PropertyDataCollector> m_propertiesList; - private List<PropertyDataCollector> m_instancedPropertiesList; - private List<PropertyDataCollector> m_dotsPropertiesList; - private List<PropertyDataCollector> m_dotsDefinesList; - private List<PropertyDataCollector> m_uniformsList; - private List<PropertyDataCollector> m_includesList; - private List<PropertyDataCollector> m_additionalDirectivesList; - //private List<PropertyDataCollector> m_tagsList; - private List<PropertyDataCollector> m_pragmasList; - private List<PropertyDataCollector> m_definesList; - private List<PropertyDataCollector> m_instructionsList; - private List<PropertyDataCollector> m_localVariablesList; - private List<PropertyDataCollector> m_vertexLocalVariablesList; - private List<PropertyDataCollector> m_specialLocalVariablesList; - private List<PropertyDataCollector> m_vertexDataList; - private List<PropertyDataCollector> m_customOutputList; - private List<PropertyDataCollector> m_functionsList; - private List<PropertyDataCollector> m_grabPassList; - private List<PropertyDataCollector> m_aboveUsePassesList; - private List<PropertyDataCollector> m_belowUsePassesList; - - private List<InputCoordsCollector> m_customShadowCoordsList; - private List<int> m_packSlotsList; - private string m_customAppDataItems; - - private Dictionary<string, PropertyDataCollector> m_inputDict; - private Dictionary<string, PropertyDataCollector> m_customInputDict; - private Dictionary<string, PropertyDataCollector> m_propertiesDict; - private Dictionary<string, PropertyDataCollector> m_instancedPropertiesDict; - private Dictionary<string, PropertyDataCollector> m_dotsPropertiesDict; - private Dictionary<string, PropertyDataCollector> m_uniformsDict; - private Dictionary<string, PropertyDataCollector> m_softRegisteredUniformsDict; - private Dictionary<string, PropertyDataCollector> m_includesDict; - private Dictionary<string, PropertyDataCollector> m_additionalDirectivesDict; - private Dictionary<string, string> m_includesExclusionDict; - - //private Dictionary<string, PropertyDataCollector> m_tagsDict; - private Dictionary<string, PropertyDataCollector> m_pragmasDict; - private Dictionary<string, PropertyDataCollector> m_definesDict; - private Dictionary<string, int> m_virtualCoordinatesDict; - private Dictionary<string, string> m_virtualVariablesDict; - private Dictionary<string, PropertyDataCollector> m_localVariablesDict; - private Dictionary<string, PropertyDataCollector> m_vertexLocalVariablesDict; - private Dictionary<string, PropertyDataCollector> m_specialLocalVariablesDict; - private Dictionary<string, PropertyDataCollector> m_vertexDataDict; - private Dictionary<string, PropertyDataCollector> m_customOutputDict; - private Dictionary<string, string> m_localFunctions; - private Dictionary<string, string> m_grabPassDict; - private Dictionary<string, string> m_usePassesDict; - private Dictionary<string, string> m_customAppDataItemsDict; - - private Dictionary<string, InputCoordsCollector> m_customShadowCoordsDict; - - private TextureChannelUsage[] m_requireTextureProperty = { TextureChannelUsage.Not_Used, TextureChannelUsage.Not_Used, TextureChannelUsage.Not_Used, TextureChannelUsage.Not_Used }; - - private bool m_dirtyAppData; - private bool m_dirtyInputs; - private bool m_dirtyCustomInputs; - private bool m_dirtyFunctions; - private bool m_dirtyProperties; - private bool m_dirtyInstancedProperties; - private bool m_dirtyUniforms; - private bool m_dirtyIncludes; - private bool m_dirtyPragmas; - private bool m_dirtyDefines; - private bool m_dirtyAdditionalDirectives; - private bool m_dirtyInstructions; - private bool m_dirtyLocalVariables; - private bool m_dirtyVertexLocalVariables; - private bool m_dirtySpecialLocalVariables; - private bool m_dirtyPerVertexData; - private bool m_dirtyNormal; - private bool m_forceNormal; - - private bool m_usingInternalData; - private bool m_usingVertexColor; - private bool m_usingWorldPosition; - private bool m_usingWorldNormal; - private bool m_usingScreenPos; - private bool m_usingWorldReflection; - private bool m_usingViewDirection; - private bool m_usingLightAttenuation; - private bool m_usingArrayDerivatives; - - private bool m_usingHigherSizeTexcoords; - private bool m_usingCustomScreenPos; - - private bool m_usingCustomOutlineColor; - private bool m_usingCustomOutlineWidth; - private bool m_usingCustomOutlineAlpha; - private int m_customOutlineSelectedAlpha = 0; - private bool m_usingCustomOutput; - - private bool m_safeNormalizeLightDir; - private bool m_safeNormalizeViewDir; - - private bool m_isOutlineDataCollector = false; - - private bool m_forceNormalIsDirty; - private bool m_grabPassIsDirty; - private bool m_tesselationActive; - - private Dictionary<int, PropertyNode> m_propertyNodes; - private MasterNode m_masterNode; - - private int m_availableVertexTempId = 0; - private int m_availableFragTempId = 0; - - private MasterNodePortCategory m_portCategory; - private PortGenType m_genType; - private RenderPath m_renderPath = RenderPath.All; - private NodeAvailability m_currentCanvasMode = NodeAvailability.SurfaceShader; - - //Templates specific data - private AvailableShaderTypes m_masterNodeCategory; - private List<string> m_vertexInputList; - private Dictionary<string, string> m_vertexInputDict; - private List<string> m_interpolatorsList; - private Dictionary<string, string> m_interpolatorsDict; - private List<string> m_vertexInterpDeclList; - private Dictionary<string, string> m_vertexInterpDeclDict; - private TemplateDataCollector m_templateDataCollector; - - public MasterNodeDataCollector( MasterNode masterNode ) : this() - { - m_masterNode = masterNode; - m_masterNodeCategory = masterNode.CurrentMasterNodeCategory; - m_currentCanvasMode = masterNode.ContainerGraph.CurrentCanvasMode; - } - - public MasterNodeDataCollector() - { - //m_masterNode = masterNode; - m_input = "struct Input\n\t\t{\n"; - m_customInput = "\t\tstruct SurfaceOutput{0}\n\t\t{\n"; - m_properties = IOUtils.PropertiesBegin;//"\tProperties\n\t{\n"; - m_uniforms = string.Empty; - m_instructions = string.Empty; - m_includes = string.Empty; - m_pragmas = string.Empty; - m_defines = string.Empty; - m_localVariables = string.Empty; - m_specialLocalVariables = string.Empty; - m_customOutput = string.Empty; - - m_inputList = new List<PropertyDataCollector>(); - m_customInputList = new List<PropertyDataCollector>(); - m_propertiesList = new List<PropertyDataCollector>(); - m_instancedPropertiesList = new List<PropertyDataCollector>(); - m_dotsPropertiesList = new List<PropertyDataCollector>(); - m_dotsDefinesList = new List<PropertyDataCollector>(); - m_uniformsList = new List<PropertyDataCollector>(); - m_includesList = new List<PropertyDataCollector>(); - m_additionalDirectivesList = new List<PropertyDataCollector>(); - //m_tagsList = new List<PropertyDataCollector>(); - m_pragmasList = new List<PropertyDataCollector>(); - m_definesList = new List<PropertyDataCollector>(); - m_instructionsList = new List<PropertyDataCollector>(); - m_localVariablesList = new List<PropertyDataCollector>(); - m_vertexLocalVariablesList = new List<PropertyDataCollector>(); - m_specialLocalVariablesList = new List<PropertyDataCollector>(); - m_vertexDataList = new List<PropertyDataCollector>(); - m_customOutputList = new List<PropertyDataCollector>(); - m_functionsList = new List<PropertyDataCollector>(); - m_grabPassList = new List<PropertyDataCollector>(); - m_aboveUsePassesList = new List<PropertyDataCollector>(); - m_belowUsePassesList = new List<PropertyDataCollector>(); - m_customAppDataItems = string.Empty; - m_customAppDataItemsDict = new Dictionary<string, string>(); - m_customShadowCoordsList = new List<InputCoordsCollector>(); - m_packSlotsList = new List<int>(); - - m_inputDict = new Dictionary<string, PropertyDataCollector>(); - m_customInputDict = new Dictionary<string, PropertyDataCollector>(); - - m_propertiesDict = new Dictionary<string, PropertyDataCollector>(); - m_instancedPropertiesDict = new Dictionary<string, PropertyDataCollector>(); - m_dotsPropertiesDict = new Dictionary<string, PropertyDataCollector>(); - m_uniformsDict = new Dictionary<string, PropertyDataCollector>(); - m_softRegisteredUniformsDict = new Dictionary<string, PropertyDataCollector>(); - m_includesDict = new Dictionary<string, PropertyDataCollector>(); - m_additionalDirectivesDict = new Dictionary<string, PropertyDataCollector>(); - m_includesExclusionDict = new Dictionary<string, string>(); - - //m_tagsDict = new Dictionary<string, PropertyDataCollector>(); - m_pragmasDict = new Dictionary<string, PropertyDataCollector>(); - m_definesDict = new Dictionary<string, PropertyDataCollector>(); - m_virtualCoordinatesDict = new Dictionary<string, int>(); - m_localVariablesDict = new Dictionary<string, PropertyDataCollector>(); - m_virtualVariablesDict = new Dictionary<string, string>(); - m_specialLocalVariablesDict = new Dictionary<string, PropertyDataCollector>(); - m_vertexLocalVariablesDict = new Dictionary<string, PropertyDataCollector>(); - m_localFunctions = new Dictionary<string, string>(); - m_vertexDataDict = new Dictionary<string, PropertyDataCollector>(); - m_customOutputDict = new Dictionary<string, PropertyDataCollector>(); - m_grabPassDict = new Dictionary<string, string>(); - m_usePassesDict = new Dictionary<string, string>(); - - m_customShadowCoordsDict = new Dictionary<string, InputCoordsCollector>(); - - m_dirtyAppData = false; - m_dirtyInputs = false; - m_dirtyCustomInputs = false; - m_dirtyProperties = false; - m_dirtyInstancedProperties = false; - m_dirtyUniforms = false; - m_dirtyInstructions = false; - m_dirtyIncludes = false; - m_dirtyPragmas = false; - m_dirtyDefines = false; - m_dirtyAdditionalDirectives = false; - m_dirtyLocalVariables = false; - m_dirtySpecialLocalVariables = false; - m_grabPassIsDirty = false; - - m_portCategory = MasterNodePortCategory.Fragment; - m_propertyNodes = new Dictionary<int, PropertyNode>(); - m_showDebugMessages = ( m_showDebugMessages && DebugConsoleWindow.DeveloperMode ); - - //templates - //m_masterNodeCategory = masterNode.CurrentMasterNodeCategory; - - m_vertexInputList = new List<string>(); - m_vertexInputDict = new Dictionary<string, string>(); - - m_interpolatorsList = new List<string>(); - m_interpolatorsDict = new Dictionary<string, string>(); - - m_vertexInterpDeclList = new List<string>(); - m_vertexInterpDeclDict = new Dictionary<string, string>(); - - m_templateDataCollector = new TemplateDataCollector(); - } - - public void SetChannelUsage( int channelId, TextureChannelUsage usage ) - { - if( channelId > -1 && channelId < 4 ) - m_requireTextureProperty[ channelId ] = usage; - } - - public TextureChannelUsage GetChannelUsage( int channelId ) - { - if( channelId > -1 && channelId < 4 ) - return m_requireTextureProperty[ channelId ]; - - return TextureChannelUsage.Not_Used; - } - public string SurfaceVertexStructure { get { return ( m_dirtyAppData ? Constants.CustomAppDataFullName : Constants.AppDataFullName ); } } - public void OpenPerVertexHeader( bool includeCustomData ) - { - string appData = "inout " + ( m_dirtyAppData ? Constants.CustomAppDataFullName : Constants.AppDataFullName ) + " "; - if( m_dirtyPerVertexData ) - return; - - m_dirtyPerVertexData = true; - if( m_tesselationActive ) - { - m_vertexData = "\t\tvoid " + Constants.VertexDataFunc + "( " + appData + Constants.VertexShaderInputStr + " )\n\t\t{\n"; - } - else - { - m_vertexData = "\t\tvoid " + Constants.VertexDataFunc + "( " + appData + Constants.VertexShaderInputStr + ( includeCustomData ? ( string.Format( ", out Input {0}", Constants.VertexShaderOutputStr ) ) : string.Empty ) + " )\n\t\t{\n"; - if( includeCustomData ) - m_vertexData += string.Format( "\t\t\tUNITY_INITIALIZE_OUTPUT( Input, {0} );\n", Constants.VertexShaderOutputStr ); - } - } - - public void ClosePerVertexHeader() - { - if( m_dirtyPerVertexData ) - m_vertexData += "\t\t}\n\n"; - } - - public void AddToVertexDisplacement( string value, VertexMode vertexMode ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_dirtyPerVertexData ) - { - OpenPerVertexHeader( true ); - } - - switch( vertexMode ) - { - default: - case VertexMode.Relative: - { - m_vertexData += "\t\t\t" + Constants.VertexShaderInputStr + ".vertex.xyz += " + value + ";\n"; - } - break; - case VertexMode.Absolute: - { - m_vertexData += "\t\t\t" + Constants.VertexShaderInputStr + ".vertex.xyz = " + value + ";\n"; - } - break; - } - } - - - public void AddToVertexNormal( string value ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_dirtyPerVertexData ) - { - OpenPerVertexHeader( true ); - } - - m_vertexData += "\t\t\t" + Constants.VertexShaderInputStr + ".normal = " + value + ";\n"; - } - - - public void AddVertexInstruction( string value, int nodeId = -1, bool addDelimiters = true ) - { - if( !m_dirtyPerVertexData && !IsOutlineDataCollector/*&& !(m_usingCustomOutlineColor || m_usingCustomOutlineWidth)*/ ) - { - OpenPerVertexHeader( true ); - } - if( !m_vertexDataDict.ContainsKey( value ) ) - { - m_vertexDataDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - m_vertexDataList.Add( m_vertexDataDict[ value ] ); - m_vertexData += ( addDelimiters ? ( "\t\t\t" + value + ";\n" ) : value ); - } - } - - public bool ContainsInput( string value ) - { - return m_inputDict.ContainsKey( value ); - } - - public void AddToInput( int nodeId, string interpName, WirePortDataType dataType, PrecisionType precision = PrecisionType.Float, bool addSemiColon = true ) - { - string value = UIUtils.PrecisionWirePortToCgType( precision, dataType ) + " " + interpName; - AddToInput( nodeId, value, addSemiColon ); - - if( !m_customShadowCoordsDict.ContainsKey( interpName ) ) - { - int slot = 0; - int index = 0; - int size = UIUtils.GetChannelsAmount( dataType ); - - if( m_packSlotsList.Count == 0 ) - m_packSlotsList.Add( 4 ); - - for( int i = 0; i < m_packSlotsList.Count; i++ ) - { - slot = i; - if( m_packSlotsList[ i ] >= size ) - { - index = 4 - m_packSlotsList[ i ]; - m_packSlotsList[ i ] -= size; - break; - } - else if( i == m_packSlotsList.Count - 1 ) - { - m_packSlotsList.Add( 4 ); - } - } - m_customShadowCoordsDict.Add( interpName, new InputCoordsCollector( nodeId, interpName, dataType, precision, slot, index ) ); - m_customShadowCoordsList.Add( m_customShadowCoordsDict[ interpName ] ); - } - } - - public void AddToInput( int nodeId, SurfaceInputs surfaceInput, PrecisionType precision = PrecisionType.Float, bool addSemiColon = true ) - { - switch( surfaceInput ) - { - case SurfaceInputs.VIEW_DIR: - UsingViewDirection = true; - break; - case SurfaceInputs.SCREEN_POS: - UsingScreenPos = true; - break; - case SurfaceInputs.WORLD_POS: - UsingWorldPosition = true; - break; - case SurfaceInputs.WORLD_REFL: - UsingWorldReflection = true; - break; - case SurfaceInputs.WORLD_NORMAL: - UsingWorldNormal = true; - break; - case SurfaceInputs.INTERNALDATA: - UsingInternalData = true; - break; - case SurfaceInputs.COLOR: - UsingVertexColor = true; - break; - } - - AddToInput( nodeId, UIUtils.GetInputDeclarationFromType( precision, surfaceInput ), addSemiColon ); - } - - /// <summary> - /// Direct access to inputs, plese use another overload - /// </summary> - /// <param name="nodeId"></param> - /// <param name="value"></param> - /// <param name="addSemiColon"></param> - public void AddToInput( int nodeId, string value, bool addSemiColon ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_inputDict.ContainsKey( value ) ) - { - m_inputDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - m_inputList.Add( m_inputDict[ value ] ); - - m_input += "\t\t\t" + value + ( ( addSemiColon ) ? ( ";\n" ) : "\n" ); - m_dirtyInputs = true; - } - } - - public void CloseInputs() - { - m_input += "\t\t};"; - } - - public void ChangeCustomInputHeader( string value ) - { - m_customInput = m_customInput.Replace( "{0}", value ); - } - - public void AddToCustomInput( int nodeId, string value, bool addSemiColon ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_customInputDict.ContainsKey( value ) ) - { - m_customInputDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - m_customInputList.Add( m_customInputDict[ value ] ); - m_customInput += "\t\t\t" + value + ( ( addSemiColon ) ? ( ";\n" ) : "\n" ); - m_dirtyCustomInputs = true; - } - } - - public void CloseCustomInputs() - { - m_customInput += "\t\t};"; - } - - - // Used by Template Master Node to add tabs into variable declaration - public void TabifyInstancedVars() - { - for( int i = 0; i < m_instancedPropertiesList.Count; i++ ) - { - m_instancedPropertiesList[ i ].PropertyName = '\t' + m_instancedPropertiesList[ i ].PropertyName; - } - } - - private int GetWeightForInstancedType( WirePortDataType type ) - { - switch( type ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: return -1; - case WirePortDataType.FLOAT2: return -2; - case WirePortDataType.FLOAT3: return -3; - case WirePortDataType.COLOR: - case WirePortDataType.FLOAT4: return -4; - case WirePortDataType.FLOAT3x3: return -9; - case WirePortDataType.FLOAT4x4: return -16; - default: - case WirePortDataType.OBJECT: - case WirePortDataType.SAMPLER1D: - case WirePortDataType.SAMPLER2D: - case WirePortDataType.SAMPLER3D: - case WirePortDataType.SAMPLERCUBE: - return 0; - } - } - - public void OptimizeInstancedProperties() - { - if( m_instancedPropertiesList.Count > 0 ) - { - m_instancedProperties = string.Empty; - m_instancedPropertiesList.Sort( ( x, y ) => { return GetWeightForInstancedType( x.DataType ).CompareTo( GetWeightForInstancedType( y.DataType ) ); } ); - int count = m_instancedPropertiesList.Count; - for( int i = 0; i < count; i++ ) - { - m_instancedProperties += m_instancedPropertiesList[ i ].PropertyName; - } - } - } - // Instanced properties - public void SetupInstancePropertiesBlock( string blockName ) - { - m_instanceBlockName = blockName; - if( IsTemplate ) - { - //if( DebugConsoleWindow.DeveloperMode ) - // Debug.LogWarning( "SetupInstancePropertiesBlock should not be used during template mode" ); - - return; - } - - OptimizeInstancedProperties(); - - if( m_dirtyInstancedProperties ) - { - m_instancedProperties = string.Format( IOUtils.InstancedPropertiesBeginTabs, blockName ) + m_instancedProperties + IOUtils.InstancedPropertiesEndTabs; - } - } - - public void AddToDotsProperties( WirePortDataType dataType, int nodeId, string value, int orderIndex, PrecisionType precision ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - string prop = string.Format( IOUtils.DotsInstancedPropertiesData, UIUtils.PrecisionWirePortToCgType( precision, dataType ), value ); - string define = string.Format( IOUtils.DotsInstancedDefinesData, UIUtils.PrecisionWirePortToCgType( precision, dataType ), value ); - - if( !m_dotsPropertiesDict.ContainsKey( value ) ) - { - PropertyDataCollector dataColl = new PropertyDataCollector( nodeId, prop, orderIndex ); - dataColl.DataType = dataType; - m_dotsPropertiesDict.Add( value, dataColl ); - m_dotsPropertiesList.Add( dataColl ); - - dataColl = new PropertyDataCollector( nodeId, define, orderIndex ); - m_dotsDefinesList.Add( dataColl ); - } - } - - public void AddToInstancedProperties( WirePortDataType dataType, int nodeId, string value, int orderIndex ) - { - if( string.IsNullOrEmpty( value ) ) - return; - string uniformValue = value.Contains( "uniform" ) ? value : "uniform " + value; - if( !m_instancedPropertiesDict.ContainsKey( value ) && - !m_uniformsDict.ContainsKey( value ) && - !m_uniformsDict.ContainsKey( uniformValue ) - ) - { - PropertyDataCollector dataColl = new PropertyDataCollector( nodeId, value, orderIndex ); - dataColl.DataType = dataType; - m_instancedPropertiesDict.Add( value, dataColl ); - m_instancedPropertiesList.Add( dataColl ); - m_instancedProperties += value; - m_dirtyInstancedProperties = true; - } - } - - public void CloseInstancedProperties() - { - if( m_dirtyInstancedProperties ) - { - m_instancedProperties += IOUtils.InstancedPropertiesEnd; - } - } - - // Properties - public void CopyPropertiesFromDataCollector( MasterNodeDataCollector dataCollector ) - { - if( dataCollector == null ) - return; - - int propertyCount = dataCollector.PropertiesList.Count; - for( int i = 0; i < propertyCount; i++ ) - { - AddToProperties( dataCollector.PropertiesList[ i ].NodeId, - dataCollector.PropertiesList[ i ].PropertyName, - dataCollector.PropertiesList[ i ].OrderIndex ); - } - - foreach( KeyValuePair<string, string> kvp in dataCollector.GrabPassDict ) - { - AddGrabPass( kvp.Value ); - } - - m_templateDataCollector.CopySRPPropertiesFromDataCollector( -1, dataCollector.TemplateDataCollectorInstance ); - } - - public void AddToProperties( int nodeId, string value, int orderIndex ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_propertiesDict.ContainsKey( value ) ) - { - //Debug.Log( UIUtils ); - m_propertiesDict.Add( value, new PropertyDataCollector( nodeId, value, orderIndex ) ); - m_propertiesList.Add( m_propertiesDict[ value ] ); - m_properties += string.Format( IOUtils.PropertiesElement, value ); - m_dirtyProperties = true; - } - } - - public string BuildPropertiesString() - { - List<PropertyDataCollector> list = new List<PropertyDataCollector>( m_propertiesDict.Values ); - //for ( int i = 0; i < list.Count; i++ ) - //{ - // Debug.Log( list[ i ].OrderIndex + " " + list[ i ].PropertyName ); - //} - - list.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - CleanUpList( ref list ); - m_properties = IOUtils.PropertiesBegin; - for( int i = 0; i < list.Count; i++ ) - { - m_properties += string.Format( IOUtils.PropertiesElement, list[ i ].PropertyName ); - //Debug.Log() - } - m_properties += IOUtils.PropertiesEnd; - return m_properties; - } - - public bool ContainsProperty( string propertyName ) - { - // TODO: this needs to change, find the property should be dependant of have a "(" - List<PropertyDataCollector> list = new List<PropertyDataCollector>( m_propertiesDict.Values ); - return list.Find( x => x.PropertyName.Contains( propertyName+"(" ) ) != null; - } - - public string[] BuildUnformatedPropertiesStringArr() - { - List<PropertyDataCollector> list = new List<PropertyDataCollector>( m_propertiesDict.Values ); - list.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - CleanUpList( ref list ); - string[] arr = new string[ list.Count ]; - for( int i = 0; i < list.Count; i++ ) - { - arr[ i ] = list[ i ].PropertyName; - } - return arr; - } - //This clean up was set to remove Header attributes from shader functions which would be last on the property list - //Thus creating a label on the inspector with no properties below - public void CleanUpList( ref List<PropertyDataCollector> list ) - { - if( list.Count == 0 ) - return; - - if( list[ list.Count - 1 ].PropertyName.Contains( "[Header(" ) ) - { - //Check if this is a complete property or just a standalone header - Match match = Regex.Match( list[ list.Count - 1 ].PropertyName, TemplateHelperFunctions.PropertiesPatternG ); - if( !match.Success ) - { - list.RemoveAt( list.Count - 1 ); - CleanUpList( ref list ); - } - } - } - - public void CloseProperties() - { - if( m_dirtyProperties ) - { - m_properties += IOUtils.PropertiesEnd; - } - } - - public void AddUsePass( string value, bool above ) - { - if( m_usePassesDict.ContainsKey( value ) ) - return; - m_usePassesDict.Add( value, value ); - if( above ) - { - m_aboveUsePassesList.Add( new PropertyDataCollector( -1, value ) ); - } - else - { - m_belowUsePassesList.Add( new PropertyDataCollector( -1, value ) ); - } - } - - public void AddGrabPass( string value ) - { - if( m_grabPassDict.ContainsKey( value ) ) - return; - - m_grabPassDict.Add( value, value ); - - if( string.IsNullOrEmpty( value ) ) - { - if( !m_grabPassIsDirty ) - m_grabPass += IOUtils.GrabPassEmpty; - } - else - { - m_grabPass += IOUtils.GrabPassBegin + value + IOUtils.GrabPassEnd; - } - m_grabPassList.Add( new PropertyDataCollector( -1, m_grabPass.Replace( "\t", string.Empty ).Replace( "\n", string.Empty ) ) ); - m_grabPassIsDirty = true; - } - - // This is used by templates global variables to register already existing globals/properties - //public void SoftRegisterUniform( string dataName ) - //{ - // if( !m_uniformsDict.ContainsKey( dataName ) ) - // { - // m_uniformsDict.Add( dataName, new PropertyDataCollector( -1, dataName ) ); - // } - //} - - public string GenerateInstanced(PrecisionType precisionType, WirePortDataType dataType,string propertyName ) - { - if( IsSRP ) - { - return string.Format( IOUtils.LWSRPInstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( precisionType, dataType ), propertyName ); - } - else - { - return string.Format( IOUtils.InstancedPropertiesElement, UIUtils.PrecisionWirePortToCgType( precisionType, dataType ), propertyName ); - } - } - - public bool CheckIfSoftRegistered( string name ) - { - return m_softRegisteredUniformsDict.ContainsKey( name ); - } - - public void SoftRegisterUniform( TemplateShaderPropertyData data ) - { - bool excludeUniformKeyword = ( data.PropertyType == PropertyType.InstancedProperty ) || IsSRP; - - string uniformName = UIUtils.GenerateUniformName( excludeUniformKeyword, data.PropertyDataType, data.PropertyName ); - if( !m_uniformsDict.ContainsKey( uniformName ) ) - { - PropertyDataCollector newEntry = new PropertyDataCollector( -1, uniformName ); - m_uniformsDict.Add( uniformName, newEntry ); - m_softRegisteredUniformsDict.Add( uniformName, newEntry ); - } - - string instancedUniform = GenerateInstanced( PrecisionType.Float, data.PropertyDataType, data.PropertyName ); - if( !m_uniformsDict.ContainsKey( instancedUniform ) ) - { - PropertyDataCollector newEntry = new PropertyDataCollector( -1, instancedUniform ); - m_uniformsDict.Add( instancedUniform, newEntry ); - m_softRegisteredUniformsDict.Add( instancedUniform, newEntry ); - } - - instancedUniform = GenerateInstanced( PrecisionType.Half, data.PropertyDataType, data.PropertyName ); - if( !m_uniformsDict.ContainsKey( instancedUniform ) ) - { - PropertyDataCollector newEntry = new PropertyDataCollector( -1, instancedUniform ); - m_uniformsDict.Add( instancedUniform, newEntry ); - m_softRegisteredUniformsDict.Add( instancedUniform, newEntry ); - } - } - - public void AddToUniforms( int nodeId, string dataType, string dataName, bool checkSRPBatch = false, bool excludeUniform = false ) - { - if( string.IsNullOrEmpty( dataName ) || string.IsNullOrEmpty( dataType ) ) - return; - - string value = UIUtils.GenerateUniformName( IsSRP || excludeUniform, dataType, dataName ); - if( !m_uniformsDict.ContainsKey( value ) && !m_uniformsDict.ContainsKey( dataName ) ) - { - m_uniformsDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - if( IsSRP && checkSRPBatch ) - { - m_templateDataCollector.AddSRPBatcherProperty( nodeId, value ); - } - else - { - m_uniforms += "\t\t" + value + '\n'; - m_uniformsList.Add( m_uniformsDict[ value ] ); - } - m_dirtyUniforms = true; - } - } - - public void AddToUniforms( int nodeId, string value, bool checkSRPBatch = false ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_uniformsDict.ContainsKey( value ) ) - { - m_uniformsDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - if( IsSRP && checkSRPBatch ) - { - m_templateDataCollector.AddSRPBatcherProperty( nodeId, value ); - } - else - { - m_uniforms += "\t\t" + value + '\n'; - m_uniformsList.Add( m_uniformsDict[ value ] ); - } - m_dirtyUniforms = true; - } - } - - public void AddToDirectives( string value, int orderIndex = -1 , AdditionalLineType type = AdditionalLineType.Custom ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - switch( type ) - { - case AdditionalLineType.Include:value = "#include " + value;break; - case AdditionalLineType.Define:value = "#define " + value; break; - case AdditionalLineType.Pragma:value = "#pragma " + value; break; - } - if( !m_additionalDirectivesDict.ContainsKey( value ) ) - { - PropertyDataCollector data = new PropertyDataCollector( -1, value, orderIndex ); - m_additionalDirectivesDict.Add( value, data ); - m_additionalDirectivesList.Add( data ); - m_dirtyAdditionalDirectives = true; - } - } - - public void AddToIncludes( int nodeId, string value ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( m_includesExclusionDict.ContainsKey( value ) ) - { - return; - } - - if( IsTemplate ) - { - if( m_templateDataCollector.HasDirective( AdditionalLineType.Include, value ) ) - return; - } - - if( !m_includesDict.ContainsKey( value ) ) - { - PropertyDataCollector data = new PropertyDataCollector( nodeId, "#include \"" + value + "\"" ); - m_includesDict.Add( value, data ); - m_includesList.Add( data ); - m_includes += "\t\t#include \"" + value + "\"\n"; - m_dirtyIncludes = true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToIncludes:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - - - public void RemoveFromIncludes( string value ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( !m_includesExclusionDict.ContainsKey( value ) ) - { - m_includesExclusionDict.Add( value, value ); - } - - if( m_includesDict.ContainsKey( value ) ) - { - PropertyDataCollector data = m_includesDict[ value ]; - m_includesDict.Remove( value ); - m_includesList.Remove( data ); - m_dirtyIncludes = true; - string finalValueName = "\t\t#include \"" + value + "\"\n"; - m_includes = m_includes.Replace( finalValueName, string.Empty ); - } - } - - //public void AddToTags( int nodeId, string name, string value ) - //{ - // if( string.IsNullOrEmpty( name ) || string.IsNullOrEmpty( value ) ) - // return; - - // if( !m_tagsDict.ContainsKey( name ) ) - // { - // string finalResult = string.Format( "\"{0}\"=\"{1}\"", name, value ); - // m_tagsDict.Add( name, new PropertyDataCollector( nodeId, finalResult ) ); - // m_tagsList.Add( new PropertyDataCollector( nodeId, finalResult ) ); - // } - //} - - public void AddToPragmas( int nodeId, string value ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( IsTemplate ) - { - if( m_templateDataCollector.HasDirective( AdditionalLineType.Pragma, value ) ) - return; - } - - if( !m_pragmasDict.ContainsKey( value ) ) - { - m_pragmasDict.Add( value, new PropertyDataCollector( nodeId, "#pragma " + value ) ); - m_pragmasList.Add( m_pragmasDict[ value ] ); - m_pragmas += "\t\t#pragma " + value + "\n"; - m_dirtyPragmas = true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToPragmas:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - - public void AddToDefines( int nodeId, string value, bool define = true ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( IsTemplate ) - { - if( m_templateDataCollector.HasDirective( AdditionalLineType.Define, value ) ) - return; - } - - if( !m_definesDict.ContainsKey( value ) ) - { - string defineValue = ( define ? "#define " : "#undef " ) + value; - m_definesDict.Add( value, new PropertyDataCollector( nodeId, defineValue ) ); - m_definesList.Add( m_definesDict[ value ] ); - m_defines += "\t\t" + defineValue + "\n"; - m_dirtyDefines = true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToDefines:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - - public int GetVirtualCoordinatesId( int nodeId, string coord, string lodBias ) - { - if( !m_virtualCoordinatesDict.ContainsKey( coord ) ) - { - m_virtualCoordinatesDict.Add( coord, nodeId ); - AddLocalVariable( nodeId, "VirtualCoord " + Constants.VirtualCoordNameStr + nodeId + " = VTComputeVirtualCoord" + lodBias + "(" + coord + ");" ); - return nodeId; - } - else - { - int fetchedId = 0; - m_virtualCoordinatesDict.TryGetValue( coord, out fetchedId ); - return fetchedId; - } - } - - public bool AddToLocalVariables( MasterNodePortCategory category, int nodeId, PrecisionType precisionType, WirePortDataType type, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = UIUtils.PrecisionWirePortToCgType( precisionType, type ) + " " + varName + " = " + varValue + ";"; - return AddToLocalVariables( category, nodeId, value ); - } - - public bool AddToLocalVariables( int nodeId, PrecisionType precisionType, WirePortDataType type, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = UIUtils.PrecisionWirePortToCgType( precisionType, type ) + " " + varName + " = " + varValue + ";"; - return AddToLocalVariables( nodeId, value ); - } - - public bool AddToLocalVariables( MasterNodePortCategory category, int nodeId, string value, bool ignoreDuplicates = false ) - { - if( string.IsNullOrEmpty( value ) ) - return false; - - switch( category ) - { - case MasterNodePortCategory.Vertex: - case MasterNodePortCategory.Tessellation: - { - return AddToVertexLocalVariables( nodeId, value, ignoreDuplicates ); - } - case MasterNodePortCategory.Fragment: - case MasterNodePortCategory.Debug: - { - return AddToLocalVariables( nodeId, value, ignoreDuplicates ); - } - } - - return false; - } - - public bool AddLocalVariable( int nodeId, string customType, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = customType + " " + varName + " = " + varValue + ";"; - return AddLocalVariable( nodeId, value ); - } - - public bool AddLocalVariable( int nodeId, PrecisionType precisionType, WirePortDataType type, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = UIUtils.PrecisionWirePortToCgType( precisionType, type ) + " " + varName + " = " + varValue + ";"; - return AddLocalVariable( nodeId, value ); - } - - public bool AddLocalVariable( int nodeId, string name, string value, bool ignoreDuplicates = false , bool addSemiColon = false ) - { - string finalValue = addSemiColon ? name + " = " + value + ";" : name + " = " + value; - return AddLocalVariable( nodeId, finalValue, ignoreDuplicates ); - } - - public bool AddLocalVariable( int nodeId, string value, bool ignoreDuplicates = false ) - { - if( string.IsNullOrEmpty( value ) ) - return false; - - switch( m_portCategory ) - { - case MasterNodePortCategory.Vertex: - case MasterNodePortCategory.Tessellation: - { - return AddToVertexLocalVariables( nodeId, value, ignoreDuplicates ); - } - case MasterNodePortCategory.Fragment: - case MasterNodePortCategory.Debug: - { - return AddToLocalVariables( nodeId, value, ignoreDuplicates ); - } - } - - return false; - } - - public string AddVirtualLocalVariable( int nodeId, string variable, string value ) - { - if( string.IsNullOrEmpty( value ) ) - return string.Empty; - - string result = string.Empty; - - //switch ( m_portCategory ) - //{ - //case MasterNodePortCategory.Vertex: - //case MasterNodePortCategory.Tessellation: - //{ - //} - //break; - //case MasterNodePortCategory.Fragment: - //case MasterNodePortCategory.Debug: - //{ - if( !m_virtualVariablesDict.ContainsKey( value ) ) - { - m_virtualVariablesDict.Add( value, variable ); - result = variable; - } - else - { - m_virtualVariablesDict.TryGetValue( value, out result ); - } - //} - //break; - //} - - return result; - } - - public void AddCodeComments( bool forceForwardSlash, params string[] comments ) - { - if( m_portCategory == MasterNodePortCategory.Tessellation || m_portCategory == MasterNodePortCategory.Vertex ) - { - AddToVertexLocalVariables( 0, IOUtils.CreateCodeComments( forceForwardSlash, comments ) ); - } - else - { - AddToLocalVariables( 0, IOUtils.CreateCodeComments( forceForwardSlash, comments ) ); - } - } - - public bool HasLocalVariable( string value ) - { - switch( m_portCategory ) - { - case MasterNodePortCategory.Vertex: - case MasterNodePortCategory.Tessellation: - { - return m_vertexLocalVariablesDict.ContainsKey( value ); - } - case MasterNodePortCategory.Fragment: - case MasterNodePortCategory.Debug: - { - if( m_usingCustomOutput ) - { - return m_customOutputDict.ContainsKey( value ); - } - else - { - return m_localVariablesDict.ContainsKey( value ); - } - } - } - return false; - } - - public bool AddToLocalVariables( int nodeId, string value, bool ignoreDuplicates = false ) - { - if( string.IsNullOrEmpty( value ) ) - return false; - - if( m_usingCustomOutput ) - { - if( !m_customOutputDict.ContainsKey( value ) || ignoreDuplicates ) - { - if( !m_customOutputDict.ContainsKey( value ) ) - m_customOutputDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - - m_customOutputList.Add( m_customOutputDict[ value ] ); - m_customOutput += "\t\t\t" + value + '\n'; - return true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToLocalVariables:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - else - { - if( !m_localVariablesDict.ContainsKey( value ) || ignoreDuplicates ) - { - if( !m_localVariablesDict.ContainsKey( value ) ) - m_localVariablesDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - - m_localVariablesList.Add( m_localVariablesDict[ value ] ); - AddToSpecialLocalVariables( nodeId, value, ignoreDuplicates ); - return true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToLocalVariables:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - return false; - } - - public void AddToSpecialLocalVariables( int nodeId, string value, bool ignoreDuplicates = false ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - if( m_usingCustomOutput ) - { - if( !m_customOutputDict.ContainsKey( value ) || ignoreDuplicates ) - { - if( !m_customOutputDict.ContainsKey( value ) ) - m_customOutputDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - - m_customOutputList.Add( m_customOutputDict[ value ] ); - m_customOutput += "\t\t\t" + value + '\n'; - m_dirtySpecialLocalVariables = true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToSpecialLocalVariables:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - else - { - if( !m_specialLocalVariablesDict.ContainsKey( value ) || ignoreDuplicates ) - { - if( !m_specialLocalVariablesDict.ContainsKey( value ) ) - m_specialLocalVariablesDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - - m_specialLocalVariablesList.Add( m_specialLocalVariablesDict[ value ] ); - m_specialLocalVariables += "\t\t\t" + value + '\n'; - m_dirtySpecialLocalVariables = true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToSpecialLocalVariables:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - } - } - - public void ClearSpecialLocalVariables() - { - //m_specialLocalVariablesDict.Clear(); - m_specialLocalVariables = string.Empty; - m_dirtySpecialLocalVariables = false; - } - - public bool AddToVertexLocalVariables( int nodeId, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = varName + " = " + varValue + ";"; - return AddToVertexLocalVariables( nodeId, value ); - } - - public bool AddToVertexLocalVariables( int nodeId, PrecisionType precisionType, WirePortDataType type, string varName, string varValue ) - { - if( string.IsNullOrEmpty( varName ) || string.IsNullOrEmpty( varValue ) ) - return false; - - string value = UIUtils.PrecisionWirePortToCgType( precisionType, type ) + " " + varName + " = " + varValue + ";"; - return AddToVertexLocalVariables( nodeId, value ); - } - - public bool AddToVertexLocalVariables( int nodeId, string value, bool ignoreDuplicates = false ) - { - if( string.IsNullOrEmpty( value ) ) - return false; - - if( !m_vertexLocalVariablesDict.ContainsKey( value ) || ignoreDuplicates ) - { - if( !m_vertexLocalVariablesDict.ContainsKey( value ) ) - m_vertexLocalVariablesDict.Add( value, new PropertyDataCollector( nodeId, value ) ); - - m_vertexLocalVariablesList.Add( m_vertexLocalVariablesDict[ value ] ); - m_vertexLocalVariables += "\t\t\t" + value + '\n'; - m_dirtyVertexLocalVariables = true; - return true; - } - else - { - if( m_showDebugMessages ) UIUtils.ShowMessage( "AddToVertexLocalVariables:Attempting to add duplicate " + value, MessageSeverity.Warning ); - } - - return false; - } - - public void ClearVertexLocalVariables() - { - //m_vertexLocalVariablesDict.Clear(); - m_vertexLocalVariables = string.Empty; - m_dirtyVertexLocalVariables = false; - } - - - public bool CheckFunction( string header ) - { - return m_localFunctions.ContainsKey( header ); - } - - public string AddFunctions( string header, string body, params object[] inParams ) - { - if( !m_localFunctions.ContainsKey( header ) ) - { - m_localFunctions.Add( header, body ); - m_functionsList.Add( new PropertyDataCollector( -1, body.Replace( "\t\t", string.Empty ) ) ); - m_functions += "\n" + body + "\n"; - m_dirtyFunctions = true; - } - - return String.Format( header, inParams ); - } - - public string AddFunctions( string header, string[] bodyLines, bool addNewLine, params object[] inParams ) - { - if( !m_localFunctions.ContainsKey( header ) ) - { - string body = string.Empty; - for( int i = 0; i < bodyLines.Length; i++ ) - { - body += ( m_masterNodeCategory == AvailableShaderTypes.Template ) ? bodyLines[ i ] : "\t\t" + bodyLines[ i ]; - if( addNewLine ) - body += '\n'; - } - - m_localFunctions.Add( header, body ); - m_functionsList.Add( new PropertyDataCollector( -1, body ) ); - m_functions += "\n" + body + "\n"; - m_dirtyFunctions = true; - } - - return String.Format( header, inParams ); - } - - public bool HasFunction( string functionId ) - { - return m_localFunctions.ContainsKey( functionId ); - } - - public void AddFunction( string functionId, string body ) - { - if( !m_localFunctions.ContainsKey( functionId ) ) - { - m_functionsList.Add( new PropertyDataCollector( -1, body ) ); - - m_localFunctions.Add( functionId, body ); - m_functions += "\n" + body + "\n"; - m_dirtyFunctions = true; - } - } - - public void AddFunction( string functionId, string[] bodyLines, bool addNewline ) - { - if( !m_localFunctions.ContainsKey( functionId ) ) - { - string body = string.Empty; - for( int i = 0; i < bodyLines.Length; i++ ) - { - body += ( m_masterNodeCategory == AvailableShaderTypes.Template ) ? bodyLines[ i ] : "\t\t" + bodyLines[ i ]; - if( addNewline ) - body += '\n'; - - } - m_functionsList.Add( new PropertyDataCollector( -1, body ) ); - - m_localFunctions.Add( functionId, body ); - m_functions += "\n" + body + "\n"; - m_dirtyFunctions = true; - } - } - - public void AddInstructions( string value, bool addTabs = false, bool addLineEnding = false ) - { - m_instructionsList.Add( new PropertyDataCollector( -1, value ) ); - m_instructions += addTabs ? "\t\t\t" + value : value; - if( addLineEnding ) - { - m_instructions += '\n'; - } - m_dirtyInstructions = true; - } - - - public void AddInstructions( bool addLineEnding, bool addTabs, params string[] values ) - { - for( int i = 0; i < values.Length; i++ ) - { - m_instructionsList.Add( new PropertyDataCollector( -1, values[ i ] ) ); - m_instructions += addTabs ? "\t\t\t" + values[ i ] : values[ i ]; - if( addLineEnding ) - { - m_instructions += '\n'; - } - } - m_dirtyInstructions = true; - } - - - - public void AddToStartInstructions( string value ) - { - if( string.IsNullOrEmpty( value ) ) - return; - - m_instructions = value + m_instructions; - m_dirtyInstructions = true; - } - - public void ResetInstructions() - { - m_instructionsList.Clear(); - m_instructions = string.Empty; - m_dirtyInstructions = false; - } - - - public void ResetVertexInstructions() - { - m_vertexDataList.Clear(); - m_vertexData = string.Empty; - m_dirtyPerVertexData = false; - } - - public void AddPropertyNode( PropertyNode node ) - { - if( !m_propertyNodes.ContainsKey( node.UniqueId ) ) - { - m_propertyNodes.Add( node.UniqueId, node ); - } - } - - public void UpdateMaterialOnPropertyNodes( Material material ) - { - m_masterNode.UpdateMaterial( material ); - foreach( KeyValuePair<int, PropertyNode> kvp in m_propertyNodes ) - { - kvp.Value.UpdateMaterial( material ); - } - } - - public void AddToVertexInput( string value ) - { - if( !m_vertexInputDict.ContainsKey( value ) ) - { - m_vertexInputDict.Add( value, value ); - m_vertexInputList.Add( value ); - } - } - - public void AddToInterpolators( string value ) - { - if( !m_interpolatorsDict.ContainsKey( value ) ) - { - m_interpolatorsDict.Add( value, value ); - m_interpolatorsList.Add( value ); - } - } - - public void AddToVertexInterpolatorsDecl( string value ) - { - if( !m_vertexInterpDeclDict.ContainsKey( value ) ) - { - m_vertexInterpDeclDict.Add( value, value ); - m_vertexInterpDeclList.Add( value ); - } - } - - public void UpdateShaderImporter( ref Shader shader ) - { - ShaderImporter importer = (ShaderImporter)ShaderImporter.GetAtPath( AssetDatabase.GetAssetPath( shader ) ); - if( m_propertyNodes.Count > 0 ) - { - try - { - bool hasContents = false; - TextureDefaultsDataColector defaultCol = new TextureDefaultsDataColector(); - foreach( KeyValuePair<int, PropertyNode> kvp in m_propertyNodes ) - { - hasContents = kvp.Value.UpdateShaderDefaults( ref shader, ref defaultCol ) || hasContents; - } - - if( hasContents ) - { - importer.SetDefaultTextures( defaultCol.NamesArr, defaultCol.ValuesArr ); - defaultCol.Destroy(); - defaultCol = null; - } - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - importer.SaveAndReimport(); - } - - public void AddCustomAppData( string value ) - { - if( m_customAppDataItemsDict.ContainsKey( value ) ) - return; - - m_customAppDataItemsDict.Add( value, value ); - m_customAppDataItems += "\t\t\t" + value + "\n"; - m_dirtyAppData = true; - } - public string CustomAppDataName { get { return m_dirtyAppData ? Constants.CustomAppDataFullName : Constants.AppDataFullName; } } - - public string CustomAppData - { - get - { - if( m_dirtyPerVertexData ) - return Constants.CustomAppDataFullBody + m_customAppDataItems + "\t\t};\n"; - - return string.Empty; - } - } - - public void Destroy() - { - m_masterNode = null; - - m_customAppDataItemsDict.Clear(); - m_customAppDataItemsDict = null; - - m_inputList.Clear(); - m_inputList = null; - - m_customInputList.Clear(); - m_customInputList = null; - - m_propertiesList.Clear(); - m_propertiesList = null; - - m_instancedPropertiesList.Clear(); - m_instancedPropertiesList = null; - - m_dotsPropertiesList.Clear(); - m_dotsPropertiesList = null; - - m_dotsDefinesList.Clear(); - m_dotsDefinesList = null; - - m_uniformsList.Clear(); - m_uniformsList = null; - - m_additionalDirectivesList.Clear(); - m_additionalDirectivesList = null; - - m_includesList.Clear(); - m_includesList = null; - - //m_tagsList.Clear(); - //m_tagsList = null; - - m_pragmasList.Clear(); - m_pragmasList = null; - - m_definesList.Clear(); - m_definesList = null; - - m_instructionsList.Clear(); - m_instructionsList = null; - - m_localVariablesList.Clear(); - m_localVariablesList = null; - - m_vertexLocalVariablesList.Clear(); - m_vertexLocalVariablesList = null; - - m_specialLocalVariablesList.Clear(); - m_specialLocalVariablesList = null; - - m_vertexDataList.Clear(); - m_vertexDataList = null; - - m_customOutputList.Clear(); - m_customOutputList = null; - - m_functionsList.Clear(); - m_functionsList = null; - - m_grabPassList.Clear(); - m_grabPassList = null; - - m_aboveUsePassesList.Clear(); - m_aboveUsePassesList = null; - - m_belowUsePassesList.Clear(); - m_belowUsePassesList = null; - - m_grabPassDict.Clear(); - m_grabPassDict = null; - - m_usePassesDict.Clear(); - m_usePassesDict = null; - - m_propertyNodes.Clear(); - m_propertyNodes = null; - - m_inputDict.Clear(); - m_inputDict = null; - - m_customInputDict.Clear(); - m_customInputDict = null; - - m_propertiesDict.Clear(); - m_propertiesDict = null; - - m_dotsPropertiesDict.Clear(); - m_dotsPropertiesDict = null; - - m_instancedPropertiesDict.Clear(); - m_instancedPropertiesDict = null; - - m_uniformsDict.Clear(); - m_uniformsDict = null; - - m_softRegisteredUniformsDict.Clear(); - m_softRegisteredUniformsDict = null; - - m_includesDict.Clear(); - m_includesDict = null; - - m_additionalDirectivesDict.Clear(); - m_additionalDirectivesDict = null; - - m_includesExclusionDict.Clear(); - m_includesExclusionDict = null; - //m_tagsDict.Clear(); - //m_tagsDict = null; - - m_pragmasDict.Clear(); - m_pragmasDict = null; - - m_definesDict.Clear(); - m_definesDict = null; - - m_virtualCoordinatesDict.Clear(); - m_virtualCoordinatesDict = null; - - m_virtualVariablesDict.Clear(); - m_virtualVariablesDict = null; - - m_localVariablesDict.Clear(); - m_localVariablesDict = null; - - m_specialLocalVariablesDict.Clear(); - m_specialLocalVariablesDict = null; - - m_vertexLocalVariablesDict.Clear(); - m_vertexLocalVariablesDict = null; - - m_localFunctions.Clear(); - m_localFunctions = null; - - m_vertexDataDict.Clear(); - m_vertexDataDict = null; - - m_customOutputDict.Clear(); - m_customOutputDict = null; - - //templates - m_vertexInputList.Clear(); - m_vertexInputList = null; - - m_vertexInputDict.Clear(); - m_vertexInputDict = null; - - m_interpolatorsList.Clear(); - m_interpolatorsList = null; - - m_interpolatorsDict.Clear(); - m_interpolatorsDict = null; - - m_vertexInterpDeclList.Clear(); - m_vertexInterpDeclList = null; - - m_vertexInterpDeclDict.Clear(); - m_vertexInterpDeclDict = null; - - m_templateDataCollector.Destroy(); - m_templateDataCollector = null; - - m_customShadowCoordsDict.Clear(); - m_customShadowCoordsDict = null; - - m_customShadowCoordsList.Clear(); - m_customShadowCoordsDict = null; - - m_packSlotsList.Clear(); - m_packSlotsList = null; - } - - public string Inputs { get { return m_input; } } - public string CustomInput { get { return m_customInput; } } - public string Properties { get { return m_properties; } } - public string InstanceBlockName { get { return m_instanceBlockName; } } - public string InstancedProperties { get { return m_instancedProperties; } } - public string Uniforms { get { return m_uniforms; } } - public string Instructions { get { return m_instructions; } } - public string Includes { get { return m_includes; } } - public string Pragmas { get { return m_pragmas; } } - public string Defines { get { return m_defines; } } - public string LocalVariables { get { return m_localVariables; } } - public string SpecialLocalVariables { get { return m_specialLocalVariables; } } - public string VertexLocalVariables { get { return m_vertexLocalVariables; } } - //public string VertexLocalVariablesFromList - //{ - // get - // { - // string result = string.Empty; - // int count = m_vertexLocalVariablesList.Count; - // for( int i = 0; i < count; i++ ) - // { - // result += m_vertexLocalVariablesList[ i ].PropertyName + "\n"; - // } - // return result; - // } - //} - public string VertexData { get { return m_vertexData; } } - public string CustomOutput { get { return m_customOutput; } } - public string Functions { get { return m_functions; } } - public string GrabPass { get { return m_grabPass; } } - public bool DirtyAppData { get { return m_dirtyAppData; } } - public bool DirtyInstructions { get { return m_dirtyInstructions; } } - public bool DirtyUniforms { get { return m_dirtyUniforms; } } - public bool DirtyProperties { get { return m_dirtyProperties; } } - public bool DirtyInstancedProperties { get { return m_dirtyInstancedProperties; } } - public bool DirtyInputs { get { return m_dirtyInputs; } } - public bool DirtyCustomInput { get { return m_dirtyCustomInputs; } } - public bool DirtyIncludes { get { return m_dirtyIncludes; } } - public bool DirtyPragmas { get { return m_dirtyPragmas; } } - public bool DirtyDefines { get { return m_dirtyDefines; } } - public bool DirtyAdditionalDirectives { get { return m_dirtyAdditionalDirectives; } } - public bool DirtyLocalVariables { get { return m_dirtyLocalVariables; } } - public bool DirtyVertexVariables { get { return m_dirtyVertexLocalVariables; } } - public bool DirtySpecialLocalVariables { get { return m_dirtySpecialLocalVariables; } } - public bool DirtyPerVertexData { get { return m_dirtyPerVertexData; } } - public bool DirtyFunctions { get { return m_dirtyFunctions; } } - public bool DirtyGrabPass { get { return m_grabPassIsDirty; } } - public int LocalVariablesAmount { get { return m_localVariablesDict.Count; } } - public int SpecialLocalVariablesAmount { get { return m_specialLocalVariablesDict.Count; } } - public int VertexLocalVariablesAmount { get { return m_vertexLocalVariablesDict.Count; } } - public bool TesselationActive { set { m_tesselationActive = value; } get { return m_tesselationActive; } } - - - public int AvailableVertexTempId { get { return m_availableVertexTempId++; } } - public int AvailableFragTempId { get { return m_availableFragTempId++; } } - - /// <summary> - /// Returns true if Normal output is being written by something else - /// </summary> - public bool DirtyNormal - { - get { return m_dirtyNormal; } - set { m_dirtyNormal = value; } - } - - public bool IsFragmentCategory - { - get { return m_portCategory == MasterNodePortCategory.Fragment || m_portCategory == MasterNodePortCategory.Debug; } - } - - public MasterNodePortCategory PortCategory - { - get { return m_portCategory; } - set { m_portCategory = value; } - } - - public PortGenType GenType - { - get { return m_genType; } - set { m_genType = value; } - } - - public bool IsTemplate { get { return m_masterNodeCategory == AvailableShaderTypes.Template; } } - - public bool IsSRP { get { return ( TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight || TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ); } } - - public AvailableShaderTypes MasterNodeCategory - { - get { return m_masterNodeCategory; } - set { m_masterNodeCategory = value; } - } - - /// <summary> - /// Forces write to Normal output when the output is not connected - /// </summary> - public bool ForceNormal - { - get { return m_forceNormal; } - set - { - if( value ) - { - if( !m_forceNormalIsDirty ) - { - m_forceNormal = value; - m_forceNormalIsDirty = value; - } - } - else - { - m_forceNormal = value; - } - } - } - - public bool UsingVertexColor - { - get { return m_usingVertexColor; } - set { m_usingVertexColor = value; } - } - - public bool UsingInternalData - { - get { return m_usingInternalData; } - set { m_usingInternalData = value; } - } - - public bool UsingScreenPos - { - get { return m_usingScreenPos; } - set { m_usingScreenPos = value; } - } - - public bool UsingCustomScreenPos - { - get { return m_usingCustomScreenPos; } - set { m_usingCustomScreenPos = value; } - } - - public bool UsingWorldNormal - { - get { return m_usingWorldNormal; } - set { m_usingWorldNormal = value; } - } - - public bool UsingWorldReflection - { - get { return m_usingWorldReflection; } - set { m_usingWorldReflection = value; } - } - - public bool UsingWorldPosition - { - get { return m_usingWorldPosition; } - set { m_usingWorldPosition = value; } - } - - public bool UsingViewDirection - { - get { return m_usingViewDirection; } - set { m_usingViewDirection = value; } - } - - public bool IsOutlineDataCollector - { - get { return m_isOutlineDataCollector; } - set { m_isOutlineDataCollector = value; } - } - - public bool UsingCustomOutlineColor - { - get { return m_usingCustomOutlineColor; } - set { m_usingCustomOutlineColor = value; } - } - - public bool UsingCustomOutlineWidth - { - get { return m_usingCustomOutlineWidth; } - set { m_usingCustomOutlineWidth = value; } - } - - public bool UsingCustomOutlineAlpha - { - get { return m_usingCustomOutlineAlpha; } - set { m_usingCustomOutlineAlpha = value; } - } - - public int CustomOutlineSelectedAlpha - { - get { return m_customOutlineSelectedAlpha; } - set { m_customOutlineSelectedAlpha = value; } - } - - public bool UsingCustomOutput - { - get { return m_usingCustomOutput; } - set { m_usingCustomOutput = value; } - } - - public bool UsingHigherSizeTexcoords - { - get { return m_usingHigherSizeTexcoords; } - set { m_usingHigherSizeTexcoords = value; } - } - - public bool UsingLightAttenuation - { - get { return m_usingLightAttenuation; } - set { m_usingLightAttenuation = value; } - } - - public bool UsingArrayDerivatives - { - get { return m_usingArrayDerivatives; } - set - { - if( value ) - { - MasterNodeDataCollector instance = this; - GeneratorUtils.AddCustomArraySamplingMacros( ref instance ); - } - - m_usingArrayDerivatives = value; - } - } - - public bool SafeNormalizeLightDir - { - get { return m_safeNormalizeLightDir; } - set { m_safeNormalizeLightDir = value; } - } - - public bool SafeNormalizeViewDir - { - get { return m_safeNormalizeViewDir; } - set { m_safeNormalizeViewDir = value; } - } - - public string StandardAdditionalDirectives - { - get - { - string body = string.Empty; - int count = m_additionalDirectivesList.Count; - for( int i = 0; i < count; i++ ) - { - body += "\t\t" + m_additionalDirectivesList[ i ].PropertyName + "\n"; - } - return body; - } - } - - public List<PropertyDataCollector> InputList { get { return m_inputList; } } - public List<PropertyDataCollector> CustomInputList { get { return m_customInputList; } } - public List<PropertyDataCollector> PropertiesList { get { return m_propertiesList; } } - public List<PropertyDataCollector> InstancedPropertiesList { get { return m_instancedPropertiesList; } } - public List<PropertyDataCollector> DotsPropertiesList { get { return m_dotsPropertiesList; } } - public List<PropertyDataCollector> DotsDefinesList { get { return m_dotsDefinesList; } } - public List<PropertyDataCollector> UniformsList { get { return m_uniformsList; } } - public List<PropertyDataCollector> MiscList { get { return m_additionalDirectivesList; } } - public List<PropertyDataCollector> BeforeNativeDirectivesList { get { return m_additionalDirectivesList.FindAll( obj => obj.OrderIndex < 0 ); } } - public List<PropertyDataCollector> AfterNativeDirectivesList { get { return m_additionalDirectivesList.FindAll( obj => obj.OrderIndex > 0 ); } } - public List<PropertyDataCollector> IncludesList { get { return m_includesList; } } - //public List<PropertyDataCollector> TagsList { get { return m_tagsList; } } - public List<PropertyDataCollector> PragmasList { get { return m_pragmasList; } } - public List<PropertyDataCollector> DefinesList { get { return m_definesList; } } - public List<PropertyDataCollector> InstructionsList { get { return m_instructionsList; } } - public List<PropertyDataCollector> LocalVariablesList { get { return m_localVariablesList; } } - public List<PropertyDataCollector> VertexLocalVariablesList { get { return m_vertexLocalVariablesList; } } - public List<PropertyDataCollector> SpecialLocalVariablesList { get { return m_specialLocalVariablesList; } } - public List<PropertyDataCollector> VertexDataList { get { return m_vertexDataList; } } - public List<PropertyDataCollector> CustomOutputList { get { return m_customOutputList; } } - public List<PropertyDataCollector> FunctionsList { get { return m_functionsList; } } - public List<PropertyDataCollector> GrabPassList { get { return m_grabPassList; } } - public Dictionary<string, string> GrabPassDict { get { return m_grabPassDict; } } - public List<PropertyDataCollector> AboveUsePassesList { get { return m_aboveUsePassesList; } } - public List<PropertyDataCollector> BelowUsePassesList { get { return m_belowUsePassesList; } } - public Dictionary<string, string> AboveUsePassesDict { get { return m_usePassesDict; } } - public List<InputCoordsCollector> CustomShadowCoordsList { get { return m_customShadowCoordsList; } } - public List<int> PackSlotsList { get { return m_packSlotsList; } } - public Dictionary<string, string> LocalFunctions { get { return m_localFunctions; } } - //Templates - public List<string> VertexInputList { get { return m_vertexInputList; } } - public List<string> InterpolatorList { get { return m_interpolatorsList; } } - public List<string> VertexInterpDeclList { get { return m_vertexInterpDeclList; } } - public TemplateDataCollector TemplateDataCollectorInstance { get { return m_templateDataCollector; } } - public RenderPath CurrentRenderPath - { - get { return m_renderPath; } - set { m_renderPath = value; } - } - - public NodeAvailability CurrentCanvasMode { get { return m_currentCanvasMode; } set { m_currentCanvasMode = value; } } - public TemplateSRPType CurrentSRPType - { - get - { - if( IsTemplate ) - return m_templateDataCollector.CurrentSRPType; - - return TemplateSRPType.BuiltIn; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs.meta deleted file mode 100644 index 2b16420a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/MasterNodeDataCollector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d026d775ff431f34789437db3fb4abbb -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs deleted file mode 100644 index 38137434..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs +++ /dev/null @@ -1,629 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - public enum OutlineMode - { - VertexOffset, - VertexScale - } - - [Serializable] - public sealed class OutlineOpHelper - { - - private string[] ModeTags = - { - "Tags{ }", - "Tags{ \"RenderType\" = \"TransparentCutout\" \"Queue\" = \"AlphaTest+0\"}", - "Tags{ \"RenderType\" = \"Transparent\" \"Queue\" = \"Transparent+0\"}", - "Tags{ \"RenderType\" = \"Transparent\" \"Queue\" = \"Transparent+0\" }" - }; - - private string[] ModePragma = - { - string.Empty, - string.Empty, - "alpha:fade ", - "alpha:premul " - }; - - - private readonly string OutlineSurfaceConfig = "#pragma surface outlineSurf Outline {0} keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc "; - - private readonly string OutlineBodyStructBegin = "struct Input {"; - private readonly string OutlineBodyStructDefault = "\thalf filler;"; - private readonly string OutlineBodyStructEnd = "};"; - - private readonly string OutlineDefaultUniformColor = "half4 _ASEOutlineColor;"; - private readonly string OutlineDefaultUniformWidth = "half _ASEOutlineWidth;"; - private readonly string OutlineDefaultUniformColorInstanced = "UNITY_DEFINE_INSTANCED_PROP( half4, _ASEOutlineColor )"; - private readonly string OutlineDefaultUniformWidthInstanced = "UNITY_DEFINE_INSTANCED_PROP( half, _ASEOutlineWidth )"; - - private readonly string OutlineDefaultVertexHeader = "void outlineVertexDataFunc( inout appdata_full v, out Input o )\n\t\t{"; - private readonly string OutlineTessVertexHeader = "void outlineVertexDataFunc( inout appdata_full v )\n\t\t{"; - - private readonly string OutlineDefaultVertexOutputDeclaration = "\tUNITY_INITIALIZE_OUTPUT( Input, o );"; - - private readonly string[] OutlineSurfBody = { - "\to.Emission = _ASEOutlineColor.rgb;", - "\to.Alpha = 1;" - }; - - private readonly string[] OutlineSurfBodyInstanced = { - "\to.Emission = UNITY_ACCESS_INSTANCED_PROP(_ASEOutlineColor).rgb;", - "\to.Alpha = 1;" - }; - - private readonly string[] OutlineBodyDefaultSurfBegin = { - "}", - "inline half4 LightingOutline( SurfaceOutput s, half3 lightDir, half atten ) { return half4 ( 0,0,0, s.Alpha); }", - "void outlineSurf( Input i, inout SurfaceOutput o )", - "{"}; - - private readonly string[] OutlineBodyDefaultSurfEnd = { - "}", - "ENDCG", - "\n"}; - - //private const string OutlineInstancedHeader = "#pragma multi_compile_instancing"; - - //private readonly string[] OutlineBodyInstancedBegin = { - // "UNITY_INSTANCING_CBUFFER_START({0})", - // "\tUNITY_DEFINE_INSTANCED_PROP( half4, _ASEOutlineColor )", - // "\tUNITY_DEFINE_INSTANCED_PROP(half, _ASEOutlineWidth)", - // "UNITY_INSTANCING_CBUFFER_END", - // "void outlineVertexDataFunc( inout appdata_full v, out Input o )", - // "{", - // "\tUNITY_INITIALIZE_OUTPUT( Input, o );"}; - - //private readonly string[] OutlineBodyInstancedEnd = { - // "}", - // "inline half4 LightingOutline( SurfaceOutput s, half3 lightDir, half atten ) { return half4 ( 0,0,0, s.Alpha); }", - // "void outlineSurf( Input i, inout SurfaceOutput o ) { o.Emission = UNITY_ACCESS_INSTANCED_PROP( _ASEOutlineColor ).rgb; o.Alpha = 1; }", - // "ENDCG", - // "\n"}; - - private const string WidthVariableAccessInstanced = "UNITY_ACCESS_INSTANCED_PROP( _ASEOutlineWidth )"; - - private const string OutlineVertexOffsetMode = "\tv.vertex.xyz += ( v.normal * {0} );"; - private const string OutlineVertexScaleMode = "\tv.vertex.xyz *= ( 1 + {0});"; - private const string OutlineVertexCustomMode = "\tv.vertex.xyz += {0};"; - - private const string OutlineColorLabel = "Color"; - private const string OutlineWidthLabel = "Width"; - - private const string ColorPropertyName = "_ASEOutlineColor"; - private const string WidthPropertyName = "_ASEOutlineWidth"; - - - private const string WidthPropertyNameInstanced = "UNITY_ACCESS_INSTANCED_PROP(_ASEOutlineWidth)"; - - - - private const string ColorPropertyDec = "_ASEOutlineColor( \"Outline Color\", Color ) = ({0})"; - private const string OutlinePropertyDec = "_ASEOutlineWidth( \"Outline Width\", Float ) = {0}"; - - private const string ModePropertyStr = "Mode"; - - private const string NoFogStr = "No Fog"; - - private const string BillboardInstructionFormat = "\t{0};"; - - [SerializeField] - private Color m_outlineColor; - - [SerializeField] - private float m_outlineWidth; - - [SerializeField] - private bool m_enabled; - - [SerializeField] - private OutlineMode m_mode = OutlineMode.VertexOffset; - - [SerializeField] - private bool m_noFog = true; - - private CullMode m_cullMode = CullMode.Front; - private int m_zTestMode = 0; - private int m_zWriteMode = 0; - private bool m_dirtyInput = false; - private string m_inputs = string.Empty; - private List<PropertyDataCollector> m_inputList = new List<PropertyDataCollector>(); - private string m_uniforms = string.Empty; - private List<PropertyDataCollector> m_uniformList = new List<PropertyDataCollector>(); - private List<PropertyDataCollector> m_instancedPropertiesList = new List<PropertyDataCollector>(); - private string m_instancedProperties = string.Empty; - private string m_instructions = string.Empty; - private string m_functions = string.Empty; - private string m_includes = string.Empty; - private string m_pragmas = string.Empty; - private string m_defines = string.Empty; - private string m_vertexData = string.Empty; - private string m_grabPasses = string.Empty; - private Dictionary<string, string> m_localFunctions; - - //private OutlineMode m_customMode = OutlineMode.VertexOffset; - private int m_offsetMode = 0; - private bool m_customNoFog = true; - - public void Draw( ParentNode owner, GUIStyle toolbarstyle, Material mat ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( toolbarstyle ); - GUI.color = cachedColor; - owner.ContainerGraph.ParentWindow.InnerWindowVariables.OutlineActiveMode = owner.GUILayoutToggle( owner.ContainerGraph.ParentWindow.InnerWindowVariables.OutlineActiveMode , EditorVariablesManager.OutlineActiveMode.LabelName, UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth( true ) ); - EditorGUI.BeginChangeCheck(); - m_enabled = owner.EditorGUILayoutToggle( string.Empty, m_enabled, UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_enabled ) - UpdateToMaterial( mat ); - - UIUtils.RequestSave(); - } - EditorGUILayout.EndHorizontal(); - - if( owner.ContainerGraph.ParentWindow.InnerWindowVariables.OutlineActiveMode ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - - EditorGUILayout.Separator(); - EditorGUI.BeginDisabledGroup( !m_enabled ); - - EditorGUI.indentLevel += 1; - { - m_mode = (OutlineMode)owner.EditorGUILayoutEnumPopup( ModePropertyStr, m_mode ); - - EditorGUI.BeginChangeCheck(); - m_outlineColor = owner.EditorGUILayoutColorField( OutlineColorLabel, m_outlineColor ); - if( EditorGUI.EndChangeCheck() && mat != null ) - { - if( mat.HasProperty( ColorPropertyName ) ) - { - mat.SetColor( ColorPropertyName, m_outlineColor ); - } - } - - EditorGUI.BeginChangeCheck(); - m_outlineWidth = owner.EditorGUILayoutFloatField( OutlineWidthLabel, m_outlineWidth ); - if( EditorGUI.EndChangeCheck() && mat != null ) - { - if( mat.HasProperty( WidthPropertyName ) ) - { - mat.SetFloat( WidthPropertyName, m_outlineWidth ); - } - } - - m_noFog = owner.EditorGUILayoutToggle( NoFogStr, m_noFog ); - } - - EditorGUI.indentLevel -= 1; - EditorGUI.EndDisabledGroup(); - EditorGUILayout.Separator(); - EditorGUILayout.EndVertical(); - } - } - - public void UpdateToMaterial( Material mat ) - { - if( mat == null ) - return; - - if( mat.HasProperty( ColorPropertyName ) ) - { - mat.SetColor( ColorPropertyName, m_outlineColor ); - } - - if( mat.HasProperty( WidthPropertyName ) ) - { - mat.SetFloat( WidthPropertyName, m_outlineWidth ); - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_enabled = Convert.ToBoolean( nodeParams[ index++ ] ); - m_outlineWidth = Convert.ToSingle( nodeParams[ index++ ] ); - m_outlineColor = IOUtils.StringToColor( nodeParams[ index++ ] ); - if( UIUtils.CurrentShaderVersion() > 5004 ) - { - m_mode = (OutlineMode)Enum.Parse( typeof( OutlineMode ), nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 13902 ) - { - m_noFog = Convert.ToBoolean( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_enabled ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_outlineWidth ); - IOUtils.AddFieldValueToString( ref nodeInfo, IOUtils.ColorToString( m_outlineColor ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_noFog ); - } - - public void AddToDataCollector( ref MasterNodeDataCollector dataCollector ) - { - if( !dataCollector.UsingCustomOutlineColor ) - dataCollector.AddToProperties( -1, string.Format( ColorPropertyDec, IOUtils.ColorToString( m_outlineColor ) ), -1 ); - if( !dataCollector.UsingCustomOutlineWidth ) - dataCollector.AddToProperties( -1, string.Format( OutlinePropertyDec, m_outlineWidth ), -1 ); - } - - public void UpdateFromMaterial( Material mat ) - { - if( mat.HasProperty( ColorPropertyName ) ) - { - m_outlineColor = mat.GetColor( ColorPropertyName ); - } - - if( mat.HasProperty( WidthPropertyName ) ) - { - m_outlineWidth = mat.GetFloat( WidthPropertyName ); - } - } - - void AddMultibodyString( string body , List<string> list ) - { - body = body.Replace( "\t\t", string.Empty ); - string[] strArr = body.Split( '\n' ); - for( int i = 0; i < strArr.Length; i++ ) - { - list.Add( strArr[ i ] ); - } - - } - public string[] OutlineFunctionBody( ref MasterNodeDataCollector dataCollector, bool instanced, bool isShadowCaster, string shaderName, string[] billboardInfo, ref TessellationOpHelper tessOpHelper, string target, PrecisionType precision ) - { - List<string> body = new List<string>(); - body.Add( ModeTags[ dataCollector.CustomOutlineSelectedAlpha ] ); - if( !string.IsNullOrEmpty( m_grabPasses )) - body.Add( m_grabPasses.Replace( "\t\t",string.Empty )); - - if( m_zWriteMode != 0 ) - body.Add( "ZWrite " + ZBufferOpHelper.ZWriteModeValues[ m_zWriteMode ] ); - if( m_zTestMode != 0 ) - body.Add( "ZTest " + ZBufferOpHelper.ZTestModeValues[ m_zTestMode ] ); - - body.Add( "Cull " + m_cullMode ); - body.Add( "CGPROGRAM" ); - if( tessOpHelper.EnableTesselation ) - { - body.Add( "#include \"" + TessellationOpHelper.TessInclude + "\"" ); - body.Add( "#pragma target " + target ); - } - else - { - body.Add( "#pragma target 3.0" ); - } - - bool customOutline = dataCollector.UsingCustomOutlineColor || dataCollector.UsingCustomOutlineWidth || dataCollector.UsingCustomOutlineAlpha; - int outlineMode = customOutline ? m_offsetMode : ( m_mode == OutlineMode.VertexOffset ? 0 : 1 ); - string extraOptions = ( customOutline ? m_customNoFog : m_noFog ) ? "nofog " : string.Empty; - if( dataCollector.CustomOutlineSelectedAlpha > 0 ) - { - extraOptions += ModePragma[ dataCollector.CustomOutlineSelectedAlpha ]; - } - - string surfConfig = string.Format( OutlineSurfaceConfig, extraOptions ); - - if( tessOpHelper.EnableTesselation ) - tessOpHelper.WriteToOptionalParams( ref surfConfig ); - - body.Add( surfConfig ); - if( !isShadowCaster ) - { - AddMultibodyString( m_defines, body ); - AddMultibodyString( m_includes, body ); - AddMultibodyString( m_pragmas, body ); - } - - //if( instanced ) - //{ - // body.Add( OutlineInstancedHeader ); - //} - - if( customOutline ) - { - if( isShadowCaster ) - { - - for( int i = 0; i < InputList.Count; i++ ) - { - dataCollector.AddToInput( InputList[ i ].NodeId, InputList[ i ].PropertyName, true ); - } - } - else - { - if( !string.IsNullOrEmpty( m_inputs ) ) - body.Add( m_inputs.Trim( '\t', '\n' ) ); - } - - if( !DirtyInput && !isShadowCaster ) - body.Add( OutlineBodyStructDefault ); - - if( !isShadowCaster ) - body.Add( OutlineBodyStructEnd ); - } - else if( !isShadowCaster ) - { - body.Add( OutlineBodyStructBegin ); - body.Add( OutlineBodyStructDefault ); - body.Add( OutlineBodyStructEnd ); - } - - if( instanced ) - { - //for( int i = 0; i < OutlineBodyInstancedBegin.Length; i++ ) - //{ - // body.Add( ( i == 0 ) ? string.Format( OutlineBodyInstancedBegin[ i ], shaderName ) : OutlineBodyInstancedBegin[ i ] ); - //} - - //if( (object)billboardInfo != null ) - //{ - // for( int j = 0; j < billboardInfo.Length; j++ ) - // { - // body.Add( string.Format( BillboardInstructionFormat, billboardInfo[ j ] ) ); - // } - //} - - //switch( outlineMode ) - //{ - // case 0: body.Add( string.Format( OutlineVertexOffsetMode, WidthVariableAccessInstanced ) ); break; - // case 1: body.Add( string.Format( OutlineVertexScaleMode, WidthVariableAccessInstanced ) ); break; - // case 2: body.Add( string.Format( OutlineVertexCustomMode, WidthVariableAccessInstanced ) ); break; - //} - //for( int i = 0; i < OutlineBodyInstancedEnd.Length; i++ ) - //{ - // body.Add( OutlineBodyInstancedEnd[ i ] ); - //} - bool openCBuffer = true; - if( customOutline ) - { - if( isShadowCaster ) - { - for( int i = 0; i < UniformList.Count; i++ ) - { - dataCollector.AddToUniforms( UniformList[ i ].NodeId, UniformList[ i ].PropertyName ); - } - - foreach( KeyValuePair<string, string> kvp in m_localFunctions ) - { - dataCollector.AddFunction( kvp.Key, kvp.Value ); - } - } - else - { - if( !string.IsNullOrEmpty( Uniforms ) ) - body.Add( Uniforms.Trim( '\t', '\n' ) ); - - openCBuffer = false; - body.Add( string.Format( IOUtils.InstancedPropertiesBegin, shaderName )); - if( !string.IsNullOrEmpty( InstancedProperties ) ) - body.Add( InstancedProperties.Trim( '\t', '\n' ) ); - } - } - - if( openCBuffer) - body.Add( string.Format( IOUtils.InstancedPropertiesBegin, shaderName ) ); - - if( !dataCollector.UsingCustomOutlineColor ) - body.Add( precision == PrecisionType.Float ? OutlineDefaultUniformColorInstanced.Replace( "half", "float" ) : OutlineDefaultUniformColorInstanced ); - - if( !dataCollector.UsingCustomOutlineWidth ) - body.Add( precision == PrecisionType.Float ? OutlineDefaultUniformWidthInstanced.Replace( "half", "float" ) : OutlineDefaultUniformWidthInstanced ); - - body.Add( IOUtils.InstancedPropertiesEnd ); - - //Functions - if( customOutline && !isShadowCaster ) - body.Add( Functions ); - - if( tessOpHelper.EnableTesselation && !isShadowCaster ) - { - body.Add( tessOpHelper.Uniforms().TrimStart( '\t' ) ); - body.Add( tessOpHelper.GetCurrentTessellationFunction.Trim( '\t', '\n' ) + "\n" ); - } - - if( tessOpHelper.EnableTesselation ) - { - body.Add( OutlineTessVertexHeader ); - } - else - { - body.Add( OutlineDefaultVertexHeader ); - body.Add( OutlineDefaultVertexOutputDeclaration ); - } - - if( customOutline ) - { - if( !string.IsNullOrEmpty( VertexData ) ) - body.Add( "\t" + VertexData.Trim( '\t', '\n' ) ); - } - - if( (object)billboardInfo != null ) - { - for( int j = 0; j < billboardInfo.Length; j++ ) - { - body.Add( string.Format( BillboardInstructionFormat, billboardInfo[ j ] ) ); - } - } - - switch( outlineMode ) - { - case 0: body.Add( string.Format( OutlineVertexOffsetMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced ) ); break; - case 1: body.Add( string.Format( OutlineVertexScaleMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced ) ); break; - case 2: body.Add( string.Format( OutlineVertexCustomMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyNameInstanced ) ); break; - } - - for( int i = 0; i < OutlineBodyDefaultSurfBegin.Length; i++ ) - { - body.Add( OutlineBodyDefaultSurfBegin[ i ] ); - } - if( dataCollector.UsingCustomOutlineColor || dataCollector.CustomOutlineSelectedAlpha > 0 ) - { - body.Add( "\t" + Instructions.Trim( '\t', '\n' ) ); - } - else - { - for( int i = 0; i < OutlineSurfBodyInstanced.Length; i++ ) - { - body.Add( OutlineSurfBodyInstanced[ i ] ); - } - } - - for( int i = 0; i < OutlineBodyDefaultSurfEnd.Length; i++ ) - { - body.Add( OutlineBodyDefaultSurfEnd[ i ] ); - } - } - else - { - if( customOutline ) - { - if( isShadowCaster ) - { - for( int i = 0; i < UniformList.Count; i++ ) - { - dataCollector.AddToUniforms( UniformList[ i ].NodeId, UniformList[ i ].PropertyName ); - } - - foreach( KeyValuePair<string, string> kvp in m_localFunctions ) - { - dataCollector.AddFunction( kvp.Key, kvp.Value ); - } - } - else - { - if( !string.IsNullOrEmpty( Uniforms ) ) - body.Add( Uniforms.Trim( '\t', '\n' ) ); - } - } - - if( !dataCollector.UsingCustomOutlineColor ) - body.Add( precision == PrecisionType.Float ? OutlineDefaultUniformColor.Replace( "half", "float" ) : OutlineDefaultUniformColor ); - - if( !dataCollector.UsingCustomOutlineWidth ) - body.Add( precision == PrecisionType.Float ? OutlineDefaultUniformWidth.Replace( "half", "float" ) : OutlineDefaultUniformWidth ); - - //Functions - if( customOutline && !isShadowCaster ) - body.Add( Functions ); - - if( tessOpHelper.EnableTesselation && !isShadowCaster ) - { - body.Add( tessOpHelper.Uniforms().TrimStart( '\t' ) ); - body.Add( tessOpHelper.GetCurrentTessellationFunction.Trim( '\t', '\n' ) + "\n" ); - } - - if( tessOpHelper.EnableTesselation ) - { - body.Add( OutlineTessVertexHeader ); - } - else - { - body.Add( OutlineDefaultVertexHeader ); - body.Add( OutlineDefaultVertexOutputDeclaration ); - } - - if( customOutline ) - { - if( !string.IsNullOrEmpty( VertexData ) ) - body.Add( "\t" + VertexData.Trim( '\t', '\n' ) ); - } - - if( (object)billboardInfo != null ) - { - for( int j = 0; j < billboardInfo.Length; j++ ) - { - body.Add( string.Format( BillboardInstructionFormat, billboardInfo[ j ] ) ); - } - } - - switch( outlineMode ) - { - case 0: body.Add( string.Format( OutlineVertexOffsetMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName ) ); break; - case 1: body.Add( string.Format( OutlineVertexScaleMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName ) ); break; - case 2: body.Add( string.Format( OutlineVertexCustomMode, dataCollector.UsingCustomOutlineWidth ? "outlineVar" : WidthPropertyName ) ); break; - } - for( int i = 0; i < OutlineBodyDefaultSurfBegin.Length; i++ ) - { - body.Add( OutlineBodyDefaultSurfBegin[ i ] ); - } - if( dataCollector.UsingCustomOutlineColor || dataCollector.CustomOutlineSelectedAlpha > 0 ) - { - body.Add( "\t" + Instructions.Trim( '\t', '\n' ) ); - } - else - { - for( int i = 0; i < OutlineSurfBody.Length; i++ ) - { - body.Add( OutlineSurfBody[ i ] ); - } - } - - for( int i = 0; i < OutlineBodyDefaultSurfEnd.Length; i++ ) - { - body.Add( OutlineBodyDefaultSurfEnd[ i ] ); - } - } - - string[] bodyArr = body.ToArray(); - body.Clear(); - body = null; - return bodyArr; - } - - - public void Destroy() - { - m_inputList = null; - m_uniformList = null; - m_instancedPropertiesList = null; - m_localFunctions = null; - } - - public bool EnableOutline { get { return m_enabled; } } - - public bool UsingCullMode { get { return m_cullMode != CullMode.Front; } } - public bool UsingZWrite { get { return m_zWriteMode != 0; } } - public bool UsingZTest { get { return m_zTestMode != 0; } } - public int ZWriteMode { get { return m_zWriteMode; } set { m_zWriteMode = value; } } - public int ZTestMode { get { return m_zTestMode; } set { m_zTestMode = value; } } - public CullMode OutlineCullMode { get { return m_cullMode; } set { m_cullMode = value; } } - public string Inputs { get { return m_inputs; } set { m_inputs = value; } } - public string Uniforms { get { return m_uniforms; } set { m_uniforms = value; } } - public string InstancedProperties { get { return m_instancedProperties; } set { m_instancedProperties = value; } } - public string Instructions { get { return m_instructions; } set { m_instructions = value; } } - public string Functions { get { return m_functions; } set { m_functions = value; } } - public string Includes { get { return m_includes; } set { m_includes = value; } } - public string Pragmas { get { return m_pragmas; } set { m_pragmas = value; } } - public string Defines { get { return m_defines; } set { m_defines = value; } } - public string VertexData { get { return m_vertexData; } set { m_vertexData = value; } } - public string GrabPasses { get { return m_grabPasses; } set { m_grabPasses = value; } } - public List<PropertyDataCollector> InputList { get { return m_inputList; } set { m_inputList = value; } } - public List<PropertyDataCollector> UniformList { get { return m_uniformList; } set { m_uniformList = value; } } - public List<PropertyDataCollector> InstancedPropertiesList { get { return m_instancedPropertiesList; } set { m_instancedPropertiesList = value; } } - - public Dictionary<string, string> LocalFunctions { get { return m_localFunctions; } set { m_localFunctions = value; } } - public bool DirtyInput { get { return m_dirtyInput; } set { m_dirtyInput = value; } } - - //public OutlineMode CustomMode { get { return m_customMode; } set { m_customMode = value; } } - public int OffsetMode { get { return m_offsetMode; } set { m_offsetMode = value; } } - public bool CustomNoFog { get { return m_customNoFog; } set { m_customNoFog = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs.meta deleted file mode 100644 index bb79b681..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutlineOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d0900a4b7d1563e49b6184d7579dcbec -timeCreated: 1487331466 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs deleted file mode 100644 index 1fffc290..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - public class OutputNode : SignalGeneratorNode - { - public static int LOD_SUBSHADER_VERSION = 17200; - [SerializeField] - protected bool m_isMainOutputNode = false; - - [SerializeField] - protected int m_lodIndex = -1; - - public OutputNode() : base() { } - public OutputNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { } - - public override void ResetNodeData() - { - base.ResetNodeData(); - m_graphDepth = -1; - } - - public virtual void SetupNodeCategories() - { - ContainerGraph.ResetNodesData(); - //int count = m_inputPorts.Count; - //for( int i = 0; i < count; i++ ) - //{ - // if( m_inputPorts[ i ].IsConnected ) - // { - // NodeData nodeData = new NodeData( m_inputPorts[ i ].Category ); - // ParentNode node = m_inputPorts[ i ].GetOutputNode(); - // node.PropagateNodeData( nodeData, ref collector ); - // } - //} - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_isMainOutputNode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_lodIndex ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_isMainOutputNode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > LOD_SUBSHADER_VERSION ) - { - m_lodIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( IsLODMainMasterNode && !ContainerGraph.IsDuplicating ) - { - ContainerGraph.AssignMasterNode( this, true ); - } - } - - public override void AfterDuplication() - { - base.AfterDuplication(); - m_isMainOutputNode = false; - } - - public bool IsMainOutputNode - { - get { return m_isMainOutputNode; } - set - { - if( value != m_isMainOutputNode ) - { - m_isMainOutputNode = value; - if( m_isMainOutputNode ) - { - GenerateSignalPropagation(); - } - else - { - GenerateSignalInibitor(); - } - } - } - } - - public int LODIndex { get { return m_lodIndex; } set { m_lodIndex = value; } } - public bool IsLODMainMasterNode { get { return m_isMainOutputNode && m_lodIndex == -1; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs.meta deleted file mode 100644 index 79cae85e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/OutputNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ed0ee3a73f11f344495d16b54bb3af29 -timeCreated: 1491918470 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs deleted file mode 100644 index 34c8e548..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs +++ /dev/null @@ -1,227 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public enum DisableBatchingTagValues - { - True, - False, - LODFading - } - - [Serializable] - public class RenderingOptionsOpHelper - { - private const string RenderingOptionsStr = " Rendering Options"; - private readonly static GUIContent EmissionGIFlags = new GUIContent( "Emission GI Flag", "Modifies Emission GI flags" ); - private readonly static GUIContent LODCrossfadeContent = new GUIContent( " LOD Group Cross Fade", "Applies a dither crossfade to be used with LOD groups for smoother transitions. Uses one interpolator\nDefault: OFF" ); - private readonly static GUIContent DisableBatchingContent = new GUIContent( "Disable Batching", "\nDisables objects to be batched and used with DrawCallBatching Default: False" ); - private readonly static GUIContent IgnoreProjectorContent = new GUIContent( " Ignore Projector", "\nIf True then an object that uses this shader will not be affected by Projectors Default: False" ); - private readonly static GUIContent UseDefaultCasterContent = new GUIContent( " Use Default Shadow Caster", "\nIf True always use surface default shadow caster Default: False" ); - private readonly static GUIContent ForceNoShadowCastingContent = new GUIContent( " Force No Shadow Casting", "\nIf True then an object that is rendered using this subshader will never cast shadows Default: False" ); - private readonly static GUIContent ForceEnableInstancingContent = new GUIContent( " Force Enable Instancing", "\nIf True forces instancing on shader independent of having instanced properties" ); -#if UNITY_5_6_OR_NEWER - private readonly static GUIContent ForceDisableInstancingContent = new GUIContent( " Force Disable Instancing", "\nIf True forces disable instancing on shader independent of having instanced properties" ); -#endif - private readonly static GUIContent SpecularHightlightsContent = new GUIContent( " Fwd Specular Highlights Toggle", "\nIf True creates a material toggle to set Unity's internal specular highlight rendering keyword" ); - private readonly static GUIContent ReflectionsContent = new GUIContent( " Fwd Reflections Toggle", "\nIf True creates a material toggle to set Unity's internal reflections rendering keyword" ); - - [SerializeField] - private bool m_forceEnableInstancing = false; - - [SerializeField] - private bool m_forceDisableInstancing = false; - - [SerializeField] - private bool m_specularHighlightToggle = false; - - [SerializeField] - private bool m_reflectionsToggle = false; - - [SerializeField] - private bool m_lodCrossfade = false; - - [SerializeField] - private DisableBatchingTagValues m_disableBatching = DisableBatchingTagValues.False; - - [SerializeField] - private bool m_ignoreProjector = false; - - [SerializeField] - private bool m_useDefaultShadowCaster = false; - - [SerializeField] - private bool m_forceNoShadowCasting = false; - - [SerializeField] - private List<CodeGenerationData> m_codeGenerationDataList; - - public RenderingOptionsOpHelper() - { - m_codeGenerationDataList = new List<CodeGenerationData>(); - m_codeGenerationDataList.Add( new CodeGenerationData( " Exclude Deferred", "exclude_path:deferred" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Exclude Forward", "exclude_path:forward" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Exclude Legacy Deferred", "exclude_path:prepass" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Shadows", "noshadow" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Ambient Light", "noambient" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Per Vertex Light", "novertexlights" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Lightmaps", "nolightmap " ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Dynamic Global GI", "nodynlightmap" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Directional lightmaps", "nodirlightmap" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Built-in Fog", "nofog" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Meta Pass", "nometa" ) ); - m_codeGenerationDataList.Add( new CodeGenerationData( " Add Pass", "noforwardadd" ) ); - } - - public bool IsOptionActive( string option ) - { - return !m_codeGenerationDataList.Find( x => x.Name.Equals( option ) ).IsActive; - } - - public void Draw( StandardSurfaceOutputNode owner ) - { - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedRenderingOptions; - NodeUtils.DrawPropertyGroup( ref value, RenderingOptionsStr, () => - { - int codeGenCount = m_codeGenerationDataList.Count; - // Starting from index 4 because other options are already contemplated with m_renderPath and add/receive shadows - for( int i = 4; i < codeGenCount; i++ ) - { - m_codeGenerationDataList[ i ].IsActive = !owner.EditorGUILayoutToggleLeft( m_codeGenerationDataList[ i ].Name, !m_codeGenerationDataList[ i ].IsActive ); - } - m_lodCrossfade = owner.EditorGUILayoutToggleLeft( LODCrossfadeContent, m_lodCrossfade ); - m_ignoreProjector = owner.EditorGUILayoutToggleLeft( IgnoreProjectorContent, m_ignoreProjector ); - EditorGUI.BeginDisabledGroup( !owner.CastShadows ); - m_useDefaultShadowCaster = owner.EditorGUILayoutToggleLeft( UseDefaultCasterContent, m_useDefaultShadowCaster ); - EditorGUI.EndDisabledGroup(); - m_forceNoShadowCasting = owner.EditorGUILayoutToggleLeft( ForceNoShadowCastingContent, m_forceNoShadowCasting ); - if( owner.ContainerGraph.IsInstancedShader ) - { - GUI.enabled = false; - owner.EditorGUILayoutToggleLeft( ForceEnableInstancingContent, true ); - GUI.enabled = true; - } - else - { - m_forceEnableInstancing = owner.EditorGUILayoutToggleLeft( ForceEnableInstancingContent, m_forceEnableInstancing ); - } - -#if UNITY_5_6_OR_NEWER - m_forceDisableInstancing = owner.EditorGUILayoutToggleLeft( ForceDisableInstancingContent, m_forceDisableInstancing ); -#endif - m_specularHighlightToggle = owner.EditorGUILayoutToggleLeft( SpecularHightlightsContent, m_specularHighlightToggle ); - m_reflectionsToggle = owner.EditorGUILayoutToggleLeft( ReflectionsContent, m_reflectionsToggle ); - m_disableBatching = (DisableBatchingTagValues)owner.EditorGUILayoutEnumPopup( DisableBatchingContent, m_disableBatching ); - Material mat = owner.ContainerGraph.CurrentMaterial; - if( mat != null ) - { - mat.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)owner.EditorGUILayoutEnumPopup( EmissionGIFlags, mat.globalIlluminationFlags ); - } - } ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedRenderingOptions = value; - } - - public void Build( ref string OptionalParameters ) - { - int codeGenCount = m_codeGenerationDataList.Count; - - for( int i = 0; i < codeGenCount; i++ ) - { - if( m_codeGenerationDataList[ i ].IsActive ) - { - OptionalParameters += m_codeGenerationDataList[ i ].Value + Constants.OptionalParametersSep; - } - } - -#if UNITY_2017_1_OR_NEWER - if( m_lodCrossfade ) - { - OptionalParameters += Constants.LodCrossFadeOption2017 + Constants.OptionalParametersSep; - } -#endif - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - for( int i = 0; i < m_codeGenerationDataList.Count; i++ ) - { - m_codeGenerationDataList[ i ].IsActive = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 10005 ) - { - m_lodCrossfade = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 10007 ) - { - m_disableBatching = (DisableBatchingTagValues)Enum.Parse( typeof( DisableBatchingTagValues ), nodeParams[ index++ ] ); - m_ignoreProjector = Convert.ToBoolean( nodeParams[ index++ ] ); - m_forceNoShadowCasting = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 11002 ) - { - m_forceEnableInstancing = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 15205 ) - { - m_forceDisableInstancing = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 14403 ) - { - m_specularHighlightToggle = Convert.ToBoolean( nodeParams[ index++ ] ); - m_reflectionsToggle = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 16307 ) - { - m_useDefaultShadowCaster = Convert.ToBoolean( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - for( int i = 0; i < m_codeGenerationDataList.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_codeGenerationDataList[ i ].IsActive ); - } - - IOUtils.AddFieldValueToString( ref nodeInfo, m_lodCrossfade ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_disableBatching ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_ignoreProjector ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_forceNoShadowCasting ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_forceEnableInstancing ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_forceDisableInstancing ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_specularHighlightToggle ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_reflectionsToggle ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_useDefaultShadowCaster ); - } - - public void Destroy() - { - m_codeGenerationDataList.Clear(); - m_codeGenerationDataList = null; - } - public bool UseDefaultShadowCaster { get { return m_useDefaultShadowCaster; } } - public bool ForceEnableInstancing { get { return m_forceEnableInstancing; } } - public bool ForceDisableInstancing { get { return m_forceDisableInstancing; } } - - public bool LodCrossfade { get { return m_lodCrossfade; } } - public bool IgnoreProjectorValue { get { return m_ignoreProjector; } set { m_ignoreProjector = value; } } - public bool SpecularHighlightToggle { get { return m_specularHighlightToggle; } set { m_specularHighlightToggle = value; } } - public bool ReflectionsToggle { get { return m_reflectionsToggle; } set { m_reflectionsToggle = value; } } - - public string DisableBatchingTag { get { return ( m_disableBatching != DisableBatchingTagValues.False ) ? string.Format( Constants.TagFormat, "DisableBatching", m_disableBatching ) : string.Empty; } } - public string IgnoreProjectorTag { get { return ( m_ignoreProjector ) ? string.Format( Constants.TagFormat, "IgnoreProjector", "True" ) : string.Empty; } } - public string ForceNoShadowCastingTag { get { return ( m_forceNoShadowCasting ) ? string.Format( Constants.TagFormat, "ForceNoShadowCasting", "True" ) : string.Empty; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs.meta deleted file mode 100644 index e94a1528..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingOptionsOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 26d840af03d4f7b418e9c7bece143648 -timeCreated: 1488906067 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs deleted file mode 100644 index c049d6d7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs +++ /dev/null @@ -1,238 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEditor; -using UnityEngine; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class RenderPlatformInfo - { - public string Label; - public RenderPlatforms Value; - } - - [Serializable] - public class RenderingPlatformOpHelper - { - private const string RenderingPlatformsStr = " Rendering Platforms"; - private readonly RenderPlatformInfo[] RenderingPlatformsInfo = - { - new RenderPlatformInfo(){Label = " Direct3D 9", Value = RenderPlatforms.d3d9}, - new RenderPlatformInfo(){Label = " Direct3D 11 9.x", Value = RenderPlatforms.d3d11_9x}, - new RenderPlatformInfo(){Label = " Direct3D 11/12", Value = RenderPlatforms.d3d11}, - new RenderPlatformInfo(){Label = " OpenGL 3.x/4.x", Value = RenderPlatforms.glcore}, - new RenderPlatformInfo(){Label = " OpenGL ES 2.0", Value = RenderPlatforms.gles}, - new RenderPlatformInfo(){Label = " OpenGL ES 3.x", Value = RenderPlatforms.gles3}, - new RenderPlatformInfo(){Label = " iOS/Mac Metal", Value = RenderPlatforms.metal}, - new RenderPlatformInfo(){Label = " Vulkan", Value = RenderPlatforms.vulkan}, - new RenderPlatformInfo(){Label = " Xbox 360", Value = RenderPlatforms.xbox360}, - new RenderPlatformInfo(){Label = " Xbox One", Value = RenderPlatforms.xboxone}, - new RenderPlatformInfo(){Label = " PlayStation 4", Value = RenderPlatforms.ps4}, - new RenderPlatformInfo(){Label = " PlayStation Vita", Value = RenderPlatforms.psp2}, - new RenderPlatformInfo(){Label = " Nintendo 3DS", Value = RenderPlatforms.n3ds}, - new RenderPlatformInfo(){Label = " Nintendo Wii U", Value = RenderPlatforms.wiiu} - }; - - // Values from this dictionary must be the indices corresponding from the list above - private readonly Dictionary<RenderPlatforms, int> PlatformToIndex = new Dictionary<RenderPlatforms, int>() - { - {RenderPlatforms.d3d9, 0}, - {RenderPlatforms.d3d11_9x, 1}, - {RenderPlatforms.d3d11, 2}, - {RenderPlatforms.glcore, 3}, - {RenderPlatforms.gles, 4}, - {RenderPlatforms.gles3, 5}, - {RenderPlatforms.metal, 6}, - {RenderPlatforms.vulkan, 7}, - {RenderPlatforms.xbox360, 8}, - {RenderPlatforms.xboxone, 9}, - {RenderPlatforms.ps4, 10}, - {RenderPlatforms.psp2, 11}, - {RenderPlatforms.n3ds, 12}, - {RenderPlatforms.wiiu, 13} - }; - - - private readonly List<RenderPlatforms> LegacyIndexToPlatform = new List<RenderPlatforms>() - { - RenderPlatforms.d3d9, - RenderPlatforms.d3d11, - RenderPlatforms.glcore, - RenderPlatforms.gles, - RenderPlatforms.gles3, - RenderPlatforms.metal, - RenderPlatforms.d3d11_9x, - RenderPlatforms.xbox360, - RenderPlatforms.xboxone, - RenderPlatforms.ps4, - RenderPlatforms.psp2, - RenderPlatforms.n3ds, - RenderPlatforms.wiiu - }; - - [SerializeField] - private bool[] m_renderingPlatformValues; - - public RenderingPlatformOpHelper() - { - m_renderingPlatformValues = new bool[ RenderingPlatformsInfo.Length ]; - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - m_renderingPlatformValues[ i ] = true; - } - } - - - public void Draw( ParentNode owner ) - { - bool value = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedRenderingPlatforms; - NodeUtils.DrawPropertyGroup( ref value, RenderingPlatformsStr, () => - { - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - m_renderingPlatformValues[ i ] = owner.EditorGUILayoutToggleLeft( RenderingPlatformsInfo[ i ].Label, m_renderingPlatformValues[ i ] ); - } - } ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedRenderingPlatforms = value; - } - - public void SetRenderingPlatforms( ref string ShaderBody ) - { - int checkedPlatforms = 0; - int uncheckedPlatforms = 0; - - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - if( m_renderingPlatformValues[ i ] ) - { - checkedPlatforms += 1; - } - else - { - uncheckedPlatforms += 1; - } - } - - if( checkedPlatforms > 0 && checkedPlatforms < m_renderingPlatformValues.Length ) - { - string result = string.Empty; - if( checkedPlatforms < uncheckedPlatforms ) - { - result = "only_renderers "; - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - if( m_renderingPlatformValues[ i ] ) - { - result += (RenderPlatforms)RenderingPlatformsInfo[i].Value + " "; - } - } - } - else - { - result = "exclude_renderers "; - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - if( !m_renderingPlatformValues[ i ] ) - { - result += (RenderPlatforms)RenderingPlatformsInfo[ i ].Value + " "; - } - } - } - MasterNode.AddShaderPragma( ref ShaderBody, result ); - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - if( UIUtils.CurrentShaderVersion() < 17006 ) - { - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - m_renderingPlatformValues[ i ] = false; - } - - int count = LegacyIndexToPlatform.Count; - int activeCount = 0; - for( int i = 0; i < count; i++ ) - { - RenderPlatforms platform = LegacyIndexToPlatform[ i ]; - int newIndex = PlatformToIndex[ platform ]; - bool value = Convert.ToBoolean( nodeParams[ index++ ] ); - if( value ) - { - m_renderingPlatformValues[ newIndex ] = true; - activeCount += 1; - } - else - { - m_renderingPlatformValues[ newIndex ] = false; - } - } - - if( activeCount == count ) - { - m_renderingPlatformValues[ PlatformToIndex[ RenderPlatforms.vulkan ] ] = true; - } - } - else - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - if( count > 0 ) - { - RenderPlatforms firstPlatform = (RenderPlatforms)Enum.Parse( typeof(RenderPlatforms), nodeParams[ index++ ] ); - if( firstPlatform == RenderPlatforms.all ) - { - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - m_renderingPlatformValues[ i ] = true; - } - } - else - { - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - m_renderingPlatformValues[ i ] = false; - } - - m_renderingPlatformValues[ PlatformToIndex[ firstPlatform ]] = true; - for( int i = 1; i < count; i++ ) - { - RenderPlatforms currPlatform = (RenderPlatforms)Enum.Parse( typeof( RenderPlatforms ), nodeParams[ index++ ] ); - m_renderingPlatformValues[ PlatformToIndex[ currPlatform ] ] = true; - } - } - } - } - } - - public void WriteToString( ref string nodeInfo ) - { - int active = 0; - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - if( m_renderingPlatformValues[ i ] ) - active += 1; - } - IOUtils.AddFieldValueToString( ref nodeInfo, active ); - if( active == m_renderingPlatformValues.Length ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, RenderPlatforms.all ); - } - else - { - for( int i = 0; i < m_renderingPlatformValues.Length; i++ ) - { - if( m_renderingPlatformValues[ i ] ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, RenderingPlatformsInfo[i].Value ); - } - } - } - - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs.meta deleted file mode 100644 index 96f19245..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/RenderingPlatformsOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 50a1f03b042823f469cef7d97c73fdc3 -timeCreated: 1488907373 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs deleted file mode 100644 index 9fd57e8a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs +++ /dev/null @@ -1,3302 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; - -namespace AmplifyShaderEditor -{ - public enum VertexMode - { - Relative, - Absolute - } - - public enum RenderPath - { - All, - ForwardOnly, - DeferredOnly - } - - public enum StandardShaderLightModel - { - Standard, - StandardSpecular, - Lambert, - BlinnPhong, - Unlit, - CustomLighting - } - - public enum CullMode - { - Back, - Front, - Off - } - - public enum AlphaMode - { - Opaque = 0, - Masked = 1, - Transparent = 2, // Transparent (alpha:fade) - Translucent = 3, - Premultiply = 4, // Alpha Premul (alpha:premul) - Custom = 5, - } - - public enum RenderType - { - Opaque, - Transparent, - TransparentCutout, - Background, - Overlay, - TreeOpaque, - TreeTransparentCutout, - TreeBillboard, - Grass, - GrassBillboard, - Custom - } - - public enum RenderQueue - { - Background, - Geometry, - AlphaTest, - Transparent, - Overlay - } - - public enum RenderPlatforms - { - d3d9, - d3d11, - glcore, - gles, - gles3, - metal, - d3d11_9x, - xbox360, - xboxone, - ps4, - psp2, - n3ds, - wiiu, - vulkan, - all - } - - [Serializable] - public class NodeCache - { - public int TargetNodeId = -1; - public int TargetPortId = -1; - - public NodeCache( int targetNodeId, int targetPortId ) - { - SetData( targetNodeId, targetPortId ); - } - - public void SetData( int targetNodeId, int targetPortId ) - { - TargetNodeId = targetNodeId; - TargetPortId = targetPortId; - } - - public void Invalidate() - { - TargetNodeId = -1; - TargetPortId = -1; - } - - public bool IsValid - { - get { return ( TargetNodeId >= 0 ); } - } - - public override string ToString() - { - return "TargetNodeId " + TargetNodeId + " TargetPortId " + TargetPortId; - } - } - - [Serializable] - public class CacheNodeConnections - { - public Dictionary<string, List<NodeCache>> NodeCacheArray; - - public CacheNodeConnections() - { - NodeCacheArray = new Dictionary<string, List<NodeCache>>(); - } - - public void Add( string key, NodeCache value ) - { - if( NodeCacheArray.ContainsKey( key ) ) - { - NodeCacheArray[ key ].Add( value ); - } - else - { - NodeCacheArray.Add( key, new List<NodeCache>() ); - NodeCacheArray[ key ].Add( value ); - } - } - - public NodeCache Get( string key, int idx = 0 ) - { - if( NodeCacheArray.ContainsKey( key ) ) - { - if( idx < NodeCacheArray[ key ].Count ) - return NodeCacheArray[ key ][ idx ]; - } - return null; - } - - public List<NodeCache> GetList( string key ) - { - if( NodeCacheArray.ContainsKey( key ) ) - { - return NodeCacheArray[ key ]; - } - return null; - } - - public void Clear() - { - foreach( KeyValuePair<string, List<NodeCache>> kvp in NodeCacheArray ) - { - kvp.Value.Clear(); - } - NodeCacheArray.Clear(); - } - } - - [Serializable] - [NodeAttributes( "Standard Surface Output", "Master", "Surface shader generator output", null, KeyCode.None, false )] - public sealed class StandardSurfaceOutputNode : MasterNode, ISerializationCallbackReceiver - { - private readonly static string[] VertexLitFunc = { "\t\tinline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )", - "\t\t{", - "\t\t\treturn half4 ( 0, 0, 0, s.Alpha );", - "\t\t}\n"}; - - private readonly static string[] FadeModeOptions = { "Opaque", "Masked", "Transparent", "Translucent", "Alpha Premultipled", "Custom" }; - private const string VertexModeStr = "Vertex Output"; - private readonly static GUIContent RenderPathContent = new GUIContent( "Render Path", "Selects and generates passes for the supported rendering paths\nDefault: All" ); - private const string ShaderModelStr = "Shader Model"; - private readonly static GUIContent LightModelContent = new GUIContent( "Light Model", "Surface shader lighting model defines how the surface reflects light\nDefault: Standard" ); - private readonly static GUIContent ShaderLODContent = new GUIContent( "Shader LOD", "Shader LOD" ); - private readonly static GUIContent CullModeContent = new GUIContent( "Cull Mode", "Polygon culling mode prevents rendering of either back-facing or front-facing polygons to save performance, turn it off if you want to render both sides\nDefault: Back" ); - - private const string ChromaticAberrationStr = "Chromatic Aberration"; - private const string DiscardStr = "Opacity Mask"; - private const string VertexDisplacementStr = "Local Vertex Offset"; - private const string VertexPositionStr = "Local Vertex Position"; - private const string VertexDataStr = "VertexData"; - private const string VertexNormalStr = "Local Vertex Normal"; - private const string CustomLightingStr = "Custom Lighting"; - private const string AlbedoStr = "Albedo"; - private const string NormalStr = "Normal"; - private const string EmissionStr = "Emission"; - private const string MetallicStr = "Metallic"; - private const string SmoothnessStr = "Smoothness"; - private const string OcclusionDataStr = "Occlusion"; - private const string OcclusionLabelStr = "Ambient Occlusion"; - private const string TransmissionStr = "Transmission"; - private const string TranslucencyStr = "Translucency"; - private const string RefractionStr = "Refraction"; - private const string AlphaStr = "Opacity"; - private const string AlphaDataStr = "Alpha"; - private const string DebugStr = "Debug"; - private const string SpecularStr = "Specular"; - private const string GlossStr = "Gloss"; - private const string CustomRenderTypeStr = "Custom Type"; - private readonly static GUIContent AlphaModeContent = new GUIContent( " Blend Mode", "Defines how the surface blends with the background\nDefault: Opaque" ); - private const string OpacityMaskClipValueStr = "Mask Clip Value"; - private readonly static GUIContent OpacityMaskClipValueContent = new GUIContent( "Mask Clip Value", "Default clip value to be compared with opacity alpha ( 0 = fully Opaque, 1 = fully Masked )\nDefault: 0.5" ); - private readonly static GUIContent CastShadowsContent = new GUIContent( "Cast Shadows", "Generates a shadow caster pass for vertex modifications and point lights in forward rendering\nDefault: ON" ); - private readonly static GUIContent ReceiveShadowsContent = new GUIContent( "Receive Shadows", "Untick it to disable shadow receiving, this includes self-shadowing (only for forward rendering) \nDefault: ON" ); - private readonly static GUIContent QueueIndexContent = new GUIContent( "Queue Index", "Value to offset the render queue, accepts both positive values to render later and negative values to render sooner\nDefault: 0" ); - private readonly static GUIContent RefractionLayerStr = new GUIContent( "Refraction Layer", "Use it to group or ungroup different refraction shaders into the same or different grabpass (only for forward rendering) \nDefault: 0" ); - private readonly static GUIContent AlphaToCoverageStr = new GUIContent( "Alpha To Coverage", "" ); - private readonly static GUIContent RenderQueueContent = new GUIContent( "Render Queue", "Base rendering queue index\n(Background = 1000, Geometry = 2000, AlphaTest = 2450, Transparent = 3000, Overlay = 4000)\nDefault: Geometry" ); - private readonly static GUIContent RenderTypeContent = new GUIContent( "Render Type", "Categorizes shaders into several predefined groups, usually to be used with screen shader effects\nDefault: Opaque" ); - - private const string ShaderInputOrderStr = "Shader Input Order"; - - - [SerializeField] - private BlendOpsHelper m_blendOpsHelper = new BlendOpsHelper(); - - [SerializeField] - private StencilBufferOpHelper m_stencilBufferHelper = new StencilBufferOpHelper(); - - [SerializeField] - private ZBufferOpHelper m_zBufferHelper = new ZBufferOpHelper(); - - [SerializeField] - private OutlineOpHelper m_outlineHelper = new OutlineOpHelper(); - - [SerializeField] - private TessellationOpHelper m_tessOpHelper = new TessellationOpHelper(); - - [SerializeField] - private ColorMaskHelper m_colorMaskHelper = new ColorMaskHelper(); - - [SerializeField] - private RenderingPlatformOpHelper m_renderingPlatformOpHelper = new RenderingPlatformOpHelper(); - - [SerializeField] - private RenderingOptionsOpHelper m_renderingOptionsOpHelper = new RenderingOptionsOpHelper(); - - [SerializeField] - private BillboardOpHelper m_billboardOpHelper = new BillboardOpHelper(); - - [SerializeField] - private FallbackPickerHelper m_fallbackHelper = null; - - [SerializeField] - private TerrainDrawInstancedHelper m_drawInstancedHelper = new TerrainDrawInstancedHelper(); - - //legacy - [SerializeField] - private AdditionalIncludesHelper m_additionalIncludes = new AdditionalIncludesHelper(); - //legacy - [SerializeField] - private AdditionalPragmasHelper m_additionalPragmas = new AdditionalPragmasHelper(); - //legacy - [SerializeField] - private AdditionalDefinesHelper m_additionalDefines = new AdditionalDefinesHelper(); - - [SerializeField] - private TemplateAdditionalDirectivesHelper m_additionalDirectives = new TemplateAdditionalDirectivesHelper( " Additional Directives" ); - - [SerializeField] - private AdditionalSurfaceOptionsHelper m_additionalSurfaceOptions = new AdditionalSurfaceOptionsHelper(); - - [SerializeField] - private UsePassHelper m_usePass; - - [SerializeField] - private CustomTagsHelper m_customTagsHelper = new CustomTagsHelper(); - - [SerializeField] - private DependenciesHelper m_dependenciesHelper = new DependenciesHelper(); - - [SerializeField] - private StandardShaderLightModel m_currentLightModel; - - [SerializeField] - private StandardShaderLightModel m_lastLightModel; - - [SerializeField] - private CullMode m_cullMode = CullMode.Back; - - [SerializeField] - private InlineProperty m_inlineCullMode = new InlineProperty(); - - [SerializeField] - private InlineProperty m_inlineChromaticAberration = new InlineProperty(0.1f); - - [SerializeField] - private AlphaMode m_alphaMode = AlphaMode.Opaque; - - [SerializeField] - private RenderType m_renderType = RenderType.Opaque; - - [SerializeField] - private string m_customRenderType = string.Empty; - - [SerializeField] - private RenderQueue m_renderQueue = RenderQueue.Geometry; - - [SerializeField] - private RenderPath m_renderPath = RenderPath.All; - - [SerializeField] - private VertexMode m_vertexMode = VertexMode.Relative; - - [SerializeField] - private bool m_customBlendMode = false; - - [SerializeField] - private float m_opacityMaskClipValue = 0.5f; - - [SerializeField] - private InlineProperty m_inlineOpacityMaskClipValue = new InlineProperty(); - - [SerializeField] - private InlineProperty m_inlineAlphaToCoverage = new InlineProperty(); - - [SerializeField] - private int m_customLightingPortId = -1; - - [SerializeField] - private int m_emissionPortId = -1; - - [SerializeField] - private int m_discardPortId = -1; - - [SerializeField] - private int m_opacityPortId = -1; - - [SerializeField] - private int m_vertexPortId = -1; - - [SerializeField] - private bool m_keepAlpha = true; - - [SerializeField] - private bool m_castShadows = true; - - //[SerializeField] - private bool m_customShadowCaster = false; - - [SerializeField] - private bool m_receiveShadows = true; - - [SerializeField] - private int m_queueOrder = 0; - - [SerializeField] - private int m_grabOrder = 0; - - [SerializeField] - private bool m_alphaToCoverage = false; - - private InputPort m_transmissionPort; - private InputPort m_translucencyPort; - private InputPort m_tessellationPort; - private bool m_previousTranslucencyOn = false; - private bool m_previousRefractionOn = false; - - [SerializeField] - private CacheNodeConnections m_cacheNodeConnections = new CacheNodeConnections(); - - - private bool m_usingProSkin = false; - private GUIStyle m_inspectorFoldoutStyle; - private GUIStyle m_inspectorToolbarStyle; - private GUIStyle m_inspectorTooldropdownStyle; - - - private bool m_customBlendAvailable = false; - - private Color m_cachedColor = Color.white; - private float m_titleOpacity = 0.5f; - private float m_boxOpacity = 0.5f; - - private InputPort m_refractionPort; - private InputPort m_normalPort; - - - private GUIStyle m_inspectorDefaultStyle; - - [SerializeField] - private ReordenatorNode m_specColorReorder = null; - - [SerializeField] - private int m_specColorOrderIndex = -1; - - [SerializeField] - private ReordenatorNode m_maskClipReorder = null; - - [SerializeField] - private int m_maskClipOrderIndex = -1; - - [SerializeField] - private ReordenatorNode m_translucencyReorder = null; - - [SerializeField] - private int m_translucencyOrderIndex = -1; - - [SerializeField] - private ReordenatorNode m_refractionReorder = null; - - [SerializeField] - private int m_refractionOrderIndex = -1; - - [SerializeField] - private ReordenatorNode m_tessellationReorder = null; - - [SerializeField] - private int m_tessellationOrderIndex = -1; - - private bool m_previousTessellationOn = false; - private bool m_initialize = true; - private bool m_checkChanges = true; - private bool m_lightModelChanged = true; - - private PropertyNode m_dummyProperty = null; - - protected override void CommonInit( int uniqueId ) - { - m_currentLightModel = m_lastLightModel = StandardShaderLightModel.Standard; - m_textLabelWidth = 120; - m_autoDrawInternalPortData = false; - base.CommonInit( uniqueId ); - m_zBufferHelper.ParentSurface = this; - m_tessOpHelper.ParentSurface = this; - m_customPrecision = true; - } - - public override void OnEnable() - { - base.OnEnable(); - if( m_usePass == null ) - { - m_usePass = ScriptableObject.CreateInstance<UsePassHelper>(); - m_usePass.Init( " Additional Use Passes" ); - } - - if( m_fallbackHelper == null ) - { - m_fallbackHelper = ScriptableObject.CreateInstance<FallbackPickerHelper>(); - m_fallbackHelper.Init(); - } - } - - public override void AddMasterPorts() - { - int vertexCorrection = 2; - int index = vertexCorrection + 2; - base.AddMasterPorts(); - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, MetallicStr, index++, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, false, SmoothnessStr, index++, MasterNodePortCategory.Fragment, 4 ); - AddInputPort( WirePortDataType.FLOAT, false, OcclusionLabelStr, OcclusionDataStr, index++, MasterNodePortCategory.Fragment, 5 ); - } - break; - case StandardShaderLightModel.StandardSpecular: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT3, false, SpecularStr, index++, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, false, SmoothnessStr, index++, MasterNodePortCategory.Fragment, 4 ); - AddInputPort( WirePortDataType.FLOAT, false, OcclusionLabelStr, OcclusionDataStr, index++, MasterNodePortCategory.Fragment, 5 ); - } - break; - case StandardShaderLightModel.CustomLighting: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, SpecularStr, index++, MasterNodePortCategory.Fragment, 3 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - AddInputPort( WirePortDataType.FLOAT, false, GlossStr, index++, MasterNodePortCategory.Fragment, 4 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - } - break; - case StandardShaderLightModel.Unlit: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, SpecularStr, index++, MasterNodePortCategory.Fragment, 3 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - AddInputPort( WirePortDataType.FLOAT, false, GlossStr, index++, MasterNodePortCategory.Fragment, 4 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true; - } - break; - case StandardShaderLightModel.Lambert: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, SpecularStr, index++, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, false, GlossStr, index++, MasterNodePortCategory.Fragment, 4 ); - } - break; - case StandardShaderLightModel.BlinnPhong: - { - AddInputPort( WirePortDataType.FLOAT3, false, AlbedoStr, vertexCorrection + 1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, NormalStr, vertexCorrection + 0, MasterNodePortCategory.Fragment, 1 ); - m_normalPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - AddInputPort( WirePortDataType.FLOAT3, false, EmissionStr, index++, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, SpecularStr, index++, MasterNodePortCategory.Fragment, 3 ); - AddInputPort( WirePortDataType.FLOAT, false, GlossStr, index++, MasterNodePortCategory.Fragment, 4 ); - } - break; - } - - // instead of setting in the switch emission port is always at position 2; - m_emissionPortId = 2; - - AddInputPort( WirePortDataType.FLOAT3, false, TransmissionStr, index++, MasterNodePortCategory.Fragment, 6 ); - m_transmissionPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_currentLightModel == StandardShaderLightModel.Standard ) || ( m_currentLightModel == StandardShaderLightModel.StandardSpecular ) ? false : true; - - AddInputPort( WirePortDataType.FLOAT3, false, TranslucencyStr, index++, MasterNodePortCategory.Fragment, 7 ); - m_translucencyPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_currentLightModel == StandardShaderLightModel.Standard ) || ( m_currentLightModel == StandardShaderLightModel.StandardSpecular ) ? false : true; - - AddInputPort( WirePortDataType.FLOAT, false, RefractionStr, index + 2, MasterNodePortCategory.Fragment, 8 ); - m_refractionPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_alphaMode == AlphaMode.Opaque || m_alphaMode == AlphaMode.Masked || m_currentLightModel == StandardShaderLightModel.Unlit || m_currentLightModel == StandardShaderLightModel.CustomLighting ); - - AddInputPort( WirePortDataType.FLOAT, false, AlphaStr, index++, MasterNodePortCategory.Fragment, 9 ); - m_inputPorts[ m_inputPorts.Count - 1 ].DataName = AlphaDataStr; - m_opacityPortId = m_inputPorts.Count - 1; - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_alphaMode == AlphaMode.Opaque || m_alphaMode == AlphaMode.Masked ); - - AddInputPort( WirePortDataType.FLOAT, false, DiscardStr, index++, MasterNodePortCategory.Fragment, 10 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_alphaMode != AlphaMode.Masked && m_alphaMode != AlphaMode.Custom ); - m_discardPortId = m_inputPorts.Count - 1; - - // This is done to take the index + 2 from refraction port into account and not overlap indexes - index++; - - AddInputPort( WirePortDataType.FLOAT3, false, CustomLightingStr, index++, MasterNodePortCategory.Fragment, 13 ); - m_inputPorts[ m_inputPorts.Count - 1 ].Locked = ( m_currentLightModel != StandardShaderLightModel.CustomLighting ); - m_inputPorts[ m_inputPorts.Count - 1 ].GenType = PortGenType.CustomLighting; - m_customLightingPortId = m_inputPorts.Count - 1; - - //////////////////////////////////////////////////////////////////////////////////////////////// - // Vertex functions - Adding ordex index in order to force these to be the last ones - // Well now they have been moved to be the first ones so operations on vertex are to be taken into account - // by dither, screen position and similar nodes - //////////////////////////////////////////////////////////////////////////////////////////////// - m_vertexPortId = m_inputPorts.Count; - m_tessOpHelper.VertexOffsetIndexPort = m_vertexPortId; - AddInputPort( WirePortDataType.FLOAT3, false, ( m_vertexMode == VertexMode.Relative ? VertexDisplacementStr : VertexPositionStr ), VertexDataStr, 0/*index++*/, MasterNodePortCategory.Vertex, 11 ); - AddInputPort( WirePortDataType.FLOAT3, false, VertexNormalStr, 1/*index++*/, MasterNodePortCategory.Vertex, 12 ); - - //AddInputPort( WirePortDataType.FLOAT3, false, CustomLightModelStr, index++, MasterNodePortCategory.Fragment, 13 ); - //m_inputPorts[ m_inputPorts.Count - 1 ].Locked = true;// !(m_currentLightModel == StandardShaderLightModel.CustomLighting); - - AddInputPort( WirePortDataType.FLOAT4, false, TessellationOpHelper.TessellationPortStr, index++, MasterNodePortCategory.Tessellation, 14 ); - m_tessellationPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_tessOpHelper.MasterNodeIndexPort = m_tessellationPort.PortId; - - //////////////////////////////////////////////////////////////////////////////////// - AddInputPort( WirePortDataType.FLOAT3, false, DebugStr, index++, MasterNodePortCategory.Debug, 15 ); - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].CustomColor = Color.white; - } - m_sizeIsDirty = true; - } - - public override void ForcePortType() - { - int portId = 0; - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - { - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - } - break; - case StandardShaderLightModel.StandardSpecular: - { - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - } - break; - case StandardShaderLightModel.CustomLighting: - { - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - } - break; - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - { - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - } - break; - case StandardShaderLightModel.BlinnPhong: - { - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - } - break; - } - - //Transmission - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - //Translucency - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - //Refraction - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - //Alpha - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - //Discard - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT, false ); - //Custom Lighting - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - //Vertex Offset - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - //Vertex Normal - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - //Tessellation - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT4, false ); - //Debug - m_inputPorts[ portId++ ].ChangeType( WirePortDataType.FLOAT3, false ); - } - - public override void SetName( string name ) - { - ShaderName = name; - } - - public void DrawInspectorProperty() - { - if( m_inspectorDefaultStyle == null ) - { - m_inspectorDefaultStyle = UIUtils.GetCustomStyle( CustomStyle.ResetToDefaultInspectorButton ); - } - - DrawCustomInspector( false ); - } - - private void RecursiveLog() - { - List<PropertyNode> nodes = UIUtils.PropertyNodesList(); - nodes.Sort( ( x, y ) => { return x.OrderIndex.CompareTo( y.OrderIndex ); } ); - for( int i = 0; i < nodes.Count; i++ ) - { - if( ( nodes[ i ] is ReordenatorNode ) ) - ( nodes[ i ] as ReordenatorNode ).RecursiveLog(); - else - Debug.Log( nodes[ i ].OrderIndex + " " + nodes[ i ].PropertyName ); - } - } - - public void DrawGeneralOptions() - { - DrawShaderName(); - DrawCurrentShaderType(); - - EditorGUI.BeginChangeCheck(); - m_currentLightModel = (StandardShaderLightModel)EditorGUILayoutEnumPopup( LightModelContent, m_currentLightModel ); - if( EditorGUI.EndChangeCheck() ) - { - ContainerGraph.ChangedLightingModel = true; - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - ContainerGraph.ParentWindow.CurrentNodeAvailability = NodeAvailability.CustomLighting; - //ContainerGraph.CurrentCanvasMode = NodeAvailability.CustomLighting; - } - else - { - ContainerGraph.ParentWindow.CurrentNodeAvailability = NodeAvailability.SurfaceShader; - //ContainerGraph.CurrentCanvasMode = NodeAvailability.SurfaceShader; - } - } - - m_shaderModelIdx = EditorGUILayoutPopup( ShaderModelStr, m_shaderModelIdx, ShaderModelTypeArr ); - - EditorGUI.BeginChangeCheck(); - DrawPrecisionProperty( false ); - if( EditorGUI.EndChangeCheck() ) - ContainerGraph.CurrentPrecision = m_currentPrecisionType; - //m_cullMode = (CullMode)EditorGUILayoutEnumPopup( CullModeContent, m_cullMode ); - UndoParentNode inst = this; - m_inlineCullMode.CustomDrawer( ref inst, ( x ) => { m_cullMode = (CullMode)EditorGUILayoutEnumPopup( CullModeContent, m_cullMode ); }, CullModeContent.text ); - //m_inlineCullMode.Value = (int)m_cullMode; - //m_inlineCullMode.EnumTypePopup( ref inst, CullModeContent.text, Enum.GetNames( typeof( CullMode ) ) ); - //m_cullMode = (CullMode) m_inlineCullMode.Value; - - m_renderPath = (RenderPath)EditorGUILayoutEnumPopup( RenderPathContent, m_renderPath ); - - m_castShadows = EditorGUILayoutToggle( CastShadowsContent, m_castShadows ); - - m_receiveShadows = EditorGUILayoutToggle( ReceiveShadowsContent, m_receiveShadows ); - - m_drawInstancedHelper.Draw( this ); - - m_queueOrder = EditorGUILayoutIntField( QueueIndexContent, m_queueOrder ); - EditorGUI.BeginChangeCheck(); - m_vertexMode = (VertexMode)EditorGUILayoutEnumPopup( VertexModeStr, m_vertexMode ); - if( EditorGUI.EndChangeCheck() ) - { - m_inputPorts[ m_vertexPortId ].Name = m_vertexMode == VertexMode.Relative ? VertexDisplacementStr : VertexPositionStr; - m_sizeIsDirty = true; - } - - ShaderLOD = Mathf.Clamp( EditorGUILayoutIntField( ShaderLODContent, ShaderLOD ), 0, Shader.globalMaximumLOD ); - ////m_lodCrossfade = EditorGUILayoutToggle( LODCrossfadeContent, m_lodCrossfade ); - m_fallbackHelper.Draw( this ); - DrawInspectorProperty(); - - } - - public void ShowOpacityMaskValueUI() - { - EditorGUI.BeginChangeCheck(); - UndoParentNode inst = this; - m_inlineOpacityMaskClipValue.CustomDrawer( ref inst, ( x ) => { m_opacityMaskClipValue = EditorGUILayoutFloatField( OpacityMaskClipValueContent, m_opacityMaskClipValue ); }, OpacityMaskClipValueContent.text ); - if( EditorGUI.EndChangeCheck() ) - { - m_checkChanges = true; - if( m_currentMaterial != null && m_currentMaterial.HasProperty( IOUtils.MaskClipValueName ) ) - { - m_currentMaterial.SetFloat( IOUtils.MaskClipValueName, m_opacityMaskClipValue ); - } - } - } - - public override void DrawProperties() - { - if( m_inspectorFoldoutStyle == null || EditorGUIUtility.isProSkin != m_usingProSkin ) - m_inspectorFoldoutStyle = new GUIStyle( GUI.skin.GetStyle( "foldout" ) ); - - if( m_inspectorToolbarStyle == null || EditorGUIUtility.isProSkin != m_usingProSkin ) - { - m_inspectorToolbarStyle = new GUIStyle( GUI.skin.GetStyle( "toolbarbutton" ) ) - { - fixedHeight = 20 - }; - } - - if( m_inspectorTooldropdownStyle == null || EditorGUIUtility.isProSkin != m_usingProSkin ) - { - m_inspectorTooldropdownStyle = new GUIStyle( GUI.skin.GetStyle( "toolbardropdown" ) ) - { - fixedHeight = 20 - }; - m_inspectorTooldropdownStyle.margin.bottom = 2; - } - - if( EditorGUIUtility.isProSkin != m_usingProSkin ) - m_usingProSkin = EditorGUIUtility.isProSkin; - - base.DrawProperties(); - - EditorGUILayout.BeginVertical(); - { - EditorGUILayout.Separator(); - - m_titleOpacity = 0.5f; - m_boxOpacity = ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ); - m_cachedColor = GUI.color; - - // General - bool generalIsVisible = ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions; - NodeUtils.DrawPropertyGroup( ref generalIsVisible, GeneralFoldoutStr, DrawGeneralOptions ); - ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions = generalIsVisible; - - //Blend Mode - GUI.color = new Color( m_cachedColor.r, m_cachedColor.g, m_cachedColor.b, m_titleOpacity ); - EditorGUILayout.BeginHorizontal( m_inspectorToolbarStyle ); - GUI.color = m_cachedColor; - - bool blendOptionsVisible = GUILayout.Toggle( ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedBlendOptions, AlphaModeContent, UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth( true ) ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedBlendOptions = blendOptionsVisible; - } - - - if( !EditorGUIUtility.isProSkin ) - GUI.color = new Color( 0.25f, 0.25f, 0.25f, 1f ); - - float boxSize = 60; - switch( m_alphaMode ) - { - case AlphaMode.Transparent: - boxSize = 85; - break; - case AlphaMode.Translucent: - boxSize = 80; - break; - case AlphaMode.Premultiply: - boxSize = 120; - break; - } - EditorGUI.BeginChangeCheck(); - m_alphaMode = (AlphaMode)EditorGUILayoutPopup( string.Empty, (int)m_alphaMode, FadeModeOptions, UIUtils.InspectorPopdropdownStyle, GUILayout.Width( boxSize ), GUILayout.Height( 19 ) ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromBlendMode(); - } - - GUI.color = m_cachedColor; - EditorGUILayout.EndHorizontal(); - - m_customBlendAvailable = ( m_alphaMode == AlphaMode.Custom || m_alphaMode == AlphaMode.Opaque ); - - if( ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedBlendOptions ) - { - GUI.color = new Color( m_cachedColor.r, m_cachedColor.g, m_cachedColor.b, m_boxOpacity ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = m_cachedColor; - EditorGUI.indentLevel++; - EditorGUILayout.Separator(); - EditorGUI.BeginChangeCheck(); - - - m_renderType = (RenderType)EditorGUILayoutEnumPopup( RenderTypeContent, m_renderType ); - if( m_renderType == RenderType.Custom ) - { - EditorGUI.BeginChangeCheck(); - m_customRenderType = EditorGUILayoutTextField( CustomRenderTypeStr, m_customRenderType ); - if( EditorGUI.EndChangeCheck() ) - { - m_customRenderType = UIUtils.RemoveInvalidCharacters( m_customRenderType ); - } - } - - m_renderQueue = (RenderQueue)EditorGUILayoutEnumPopup( RenderQueueContent, m_renderQueue ); - - if( EditorGUI.EndChangeCheck() ) - { - if( m_renderType == RenderType.Opaque && m_renderQueue == RenderQueue.Geometry ) - m_alphaMode = AlphaMode.Opaque; - else if( m_renderType == RenderType.TransparentCutout && m_renderQueue == RenderQueue.AlphaTest ) - m_alphaMode = AlphaMode.Masked; - else if( m_renderType == RenderType.Transparent && m_renderQueue == RenderQueue.Transparent ) - m_alphaMode = AlphaMode.Transparent; - else if( m_renderType == RenderType.Opaque && m_renderQueue == RenderQueue.Transparent ) - m_alphaMode = AlphaMode.Translucent; - else - m_alphaMode = AlphaMode.Custom; - - - UpdateFromBlendMode(); - } - - bool bufferedEnabled = GUI.enabled; - - GUI.enabled = ( m_alphaMode == AlphaMode.Masked || m_alphaMode == AlphaMode.Custom ); - m_inputPorts[ m_discardPortId ].Locked = !GUI.enabled; - ShowOpacityMaskValueUI(); - - GUI.enabled = bufferedEnabled; - - EditorGUI.BeginDisabledGroup( !( m_alphaMode == AlphaMode.Transparent || m_alphaMode == AlphaMode.Premultiply || m_alphaMode == AlphaMode.Translucent || m_alphaMode == AlphaMode.Custom ) ); - m_grabOrder = EditorGUILayoutIntField( RefractionLayerStr, m_grabOrder ); - float cachedLabelWidth = EditorGUIUtility.labelWidth; - UndoParentNode inst = this; - if( m_refractionPort.IsConnected ) - { - EditorGUIUtility.labelWidth = 145; - EditorGUI.BeginChangeCheck(); - m_inlineChromaticAberration.RangedFloatField( ref inst, ChromaticAberrationStr, 0.0f,0.3f ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_currentMaterial != null && m_currentMaterial.HasProperty( IOUtils.ChromaticAberrationProperty ) ) - { - m_currentMaterial.SetFloat( IOUtils.ChromaticAberrationProperty, m_inlineChromaticAberration.FloatValue ); - } - } - } - - EditorGUIUtility.labelWidth = 130; - m_inlineAlphaToCoverage.CustomDrawer( ref inst, ( x ) => { m_alphaToCoverage = EditorGUILayoutToggle( AlphaToCoverageStr, m_alphaToCoverage ); }, AlphaToCoverageStr.text ); - EditorGUIUtility.labelWidth = cachedLabelWidth; - EditorGUI.EndDisabledGroup(); - - EditorGUILayout.Separator(); - - if( !m_customBlendAvailable ) - { - EditorGUILayout.HelpBox( "Advanced options are only available for Custom blend modes", MessageType.Warning ); - } - - EditorGUI.BeginDisabledGroup( !m_customBlendAvailable ); - m_blendOpsHelper.Draw( this, m_customBlendAvailable ); - m_colorMaskHelper.Draw( this ); - - EditorGUI.EndDisabledGroup(); - EditorGUILayout.Separator(); - EditorGUI.indentLevel--; - EditorGUILayout.EndVertical(); - } - - m_stencilBufferHelper.Draw( this ); - m_tessOpHelper.Draw( this, m_inspectorToolbarStyle, m_currentMaterial, m_tessellationPort.IsConnected ); - m_outlineHelper.Draw( this, m_inspectorToolbarStyle, m_currentMaterial ); - m_billboardOpHelper.Draw( this ); - m_zBufferHelper.Draw( this, m_inspectorToolbarStyle, m_customBlendAvailable ); - m_renderingOptionsOpHelper.Draw( this ); - m_renderingPlatformOpHelper.Draw( this ); - //m_additionalDefines.Draw( this ); - //m_additionalIncludes.Draw( this ); - //m_additionalPragmas.Draw( this ); - m_additionalSurfaceOptions.Draw( this ); - m_usePass.Draw( this ); - m_additionalDirectives.Draw( this ); - m_customTagsHelper.Draw( this ); - m_dependenciesHelper.Draw( this ); - DrawMaterialInputs( m_inspectorToolbarStyle ); - } - - EditorGUILayout.EndVertical(); - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - - if( m_initialize ) - { - m_initialize = false; - - if( m_dummyProperty == null ) - { - m_dummyProperty = ScriptableObject.CreateInstance<PropertyNode>(); - m_dummyProperty.ContainerGraph = ContainerGraph; - } - } - - if( m_currentLightModel != m_lastLightModel ) - m_lightModelChanged = true; - - if( m_lightModelChanged ) - { - m_lightModelChanged = false; - if( m_currentLightModel == StandardShaderLightModel.BlinnPhong ) - { - if( m_specColorReorder == null ) - { - m_specColorReorder = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_specColorReorder.ContainerGraph = ContainerGraph; - m_specColorReorder.OrderIndex = m_specColorOrderIndex; - m_specColorReorder.Init( "_SpecColor", "Specular Color", null ); - } - - UIUtils.RegisterPropertyNode( m_specColorReorder ); - } - else - { - if( m_specColorReorder != null ) - UIUtils.UnregisterPropertyNode( m_specColorReorder ); - } - - if( m_currentLightModel == StandardShaderLightModel.CustomLighting && m_masterNodeCategory == 0 ) - ContainerGraph.CurrentCanvasMode = NodeAvailability.CustomLighting; - else if( m_masterNodeCategory == 0 ) - ContainerGraph.CurrentCanvasMode = NodeAvailability.SurfaceShader; - CacheCurrentSettings(); - m_lastLightModel = m_currentLightModel; - DeleteAllInputConnections( true, true ); - AddMasterPorts(); - ConnectFromCache(); - } - - if( drawInfo.CurrentEventType != EventType.Layout ) - return; - - if( m_transmissionPort != null && m_transmissionPort.IsConnected && m_renderPath != RenderPath.ForwardOnly ) - { - m_renderPath = RenderPath.ForwardOnly; - UIUtils.ShowMessage( "Render Path changed to Forward Only since transmission only works in forward rendering" ); - } - - if( m_translucencyPort != null && m_translucencyPort.IsConnected && m_renderPath != RenderPath.ForwardOnly ) - { - m_renderPath = RenderPath.ForwardOnly; - UIUtils.ShowMessage( "Render Path changed to Forward Only since translucency only works in forward rendering" ); - } - - if( m_translucencyPort.IsConnected != m_previousTranslucencyOn ) - m_checkChanges = true; - - if( m_refractionPort.IsConnected != m_previousRefractionOn ) - m_checkChanges = true; - - if( ( m_tessOpHelper.EnableTesselation && !m_tessellationPort.IsConnected ) != m_previousTessellationOn ) - m_checkChanges = true; - - m_previousTranslucencyOn = m_translucencyPort.IsConnected; - - m_previousRefractionOn = m_refractionPort.IsConnected; - - m_previousTessellationOn = ( m_tessOpHelper.EnableTesselation && !m_tessellationPort.IsConnected ); - - if( m_checkChanges ) - { - if( m_translucencyPort.IsConnected ) - { - if( m_translucencyReorder == null ) - { - List<PropertyNode> translucencyList = new List<PropertyNode>(); - for( int i = 0; i < 7; i++ ) - { - translucencyList.Add( m_dummyProperty ); - } - - m_translucencyReorder = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_translucencyReorder.ContainerGraph = ContainerGraph; - m_translucencyReorder.OrderIndex = m_translucencyOrderIndex; - m_translucencyReorder.Init( "_TranslucencyGroup", "Translucency", translucencyList ); - } - - UIUtils.RegisterPropertyNode( m_translucencyReorder ); - } - else - { - if( m_translucencyReorder != null ) - UIUtils.UnregisterPropertyNode( m_translucencyReorder ); - } - - if( m_refractionPort.IsConnected ) - { - if( m_refractionReorder == null ) - { - List<PropertyNode> refractionList = new List<PropertyNode>(); - for( int i = 0; i < 2; i++ ) - { - refractionList.Add( m_dummyProperty ); - } - - m_refractionReorder = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_refractionReorder.ContainerGraph = ContainerGraph; - m_refractionReorder.OrderIndex = m_refractionOrderIndex; - m_refractionReorder.Init( "_RefractionGroup", "Refraction", refractionList ); - } - - UIUtils.RegisterPropertyNode( m_refractionReorder ); - } - else - { - if( m_refractionReorder != null ) - UIUtils.UnregisterPropertyNode( m_refractionReorder ); - } - - if( m_tessOpHelper.EnableTesselation && !m_tessellationPort.IsConnected ) - { - if( m_tessellationReorder == null ) - { - List<PropertyNode> tessellationList = new List<PropertyNode>(); - for( int i = 0; i < 4; i++ ) - { - tessellationList.Add( m_dummyProperty ); - } - - m_tessellationReorder = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_tessellationReorder.ContainerGraph = ContainerGraph; - m_tessellationReorder.OrderIndex = m_tessellationOrderIndex; - m_tessellationReorder.Init( "_TessellationGroup", "Tessellation", tessellationList ); - m_tessellationReorder.HeaderTitle = "Tesselation"; - } - - UIUtils.RegisterPropertyNode( m_tessellationReorder ); - } - else - { - if( m_tessellationReorder != null ) - UIUtils.UnregisterPropertyNode( m_tessellationReorder ); - } - - if( m_inputPorts[ m_discardPortId ].Available && !m_inlineOpacityMaskClipValue.IsValid ) - { - if( m_maskClipReorder == null ) - { - // Create dragable clip material property - m_maskClipReorder = ScriptableObject.CreateInstance<ReordenatorNode>(); - m_maskClipReorder.ContainerGraph = ContainerGraph; - m_maskClipReorder.OrderIndex = m_maskClipOrderIndex; - m_maskClipReorder.Init( "_Cutoff", "Mask Clip Value", null ); - } - - UIUtils.RegisterPropertyNode( m_maskClipReorder ); - } - else - { - if( m_maskClipReorder != null ) - UIUtils.UnregisterPropertyNode( m_maskClipReorder ); - } - - m_checkChanges = false; - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( m_containerGraph.IsInstancedShader || m_renderingOptionsOpHelper.ForceEnableInstancing ) - { - DrawInstancedIcon( drawInfo ); - } - } - - private void CacheCurrentSettings() - { - m_cacheNodeConnections.Clear(); - for( int portId = 0; portId < m_inputPorts.Count; portId++ ) - { - if( m_inputPorts[ portId ].IsConnected ) - { - WireReference connection = m_inputPorts[ portId ].GetConnection(); - m_cacheNodeConnections.Add( m_inputPorts[ portId ].Name, new NodeCache( connection.NodeId, connection.PortId ) ); - } - } - } - - private void ConnectFromCache() - { - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - NodeCache cache = m_cacheNodeConnections.Get( m_inputPorts[ i ].Name ); - if( cache != null ) - { - UIUtils.SetConnection( UniqueId, m_inputPorts[ i ].PortId, cache.TargetNodeId, cache.TargetPortId ); - } - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( m_alphaMode == AlphaMode.Masked || m_alphaMode == AlphaMode.Custom ) - { - if( mat.HasProperty( IOUtils.MaskClipValueName ) ) - mat.SetFloat( IOUtils.MaskClipValueName, m_opacityMaskClipValue ); - } - - if( m_refractionPort.IsConnected && !m_inlineChromaticAberration.Active ) - { - if( mat.HasProperty( IOUtils.ChromaticAberrationProperty ) ) - mat.SetFloat( IOUtils.ChromaticAberrationProperty, m_inlineChromaticAberration.FloatValue ); - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( m_alphaMode == AlphaMode.Masked || m_alphaMode == AlphaMode.Custom ) - { - if( fetchMaterialValues && m_materialMode && mat.HasProperty( IOUtils.MaskClipValueName ) ) - { - m_opacityMaskClipValue = mat.GetFloat( IOUtils.MaskClipValueName ); - } - } - - if( m_refractionPort.IsConnected && !m_inlineChromaticAberration.Active ) - { - if( fetchMaterialValues && m_materialMode && mat.HasProperty( IOUtils.ChromaticAberrationProperty ) ) - m_inlineChromaticAberration.FloatValue = mat.GetFloat( IOUtils.ChromaticAberrationProperty); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - m_tessOpHelper.UpdateFromMaterial( material ); - m_outlineHelper.UpdateFromMaterial( material ); - - if( m_alphaMode == AlphaMode.Masked || m_alphaMode == AlphaMode.Custom ) - { - if( material.HasProperty( IOUtils.MaskClipValueName ) ) - m_opacityMaskClipValue = material.GetFloat( IOUtils.MaskClipValueName ); - } - - if( m_refractionPort.IsConnected && !m_inlineChromaticAberration.Active ) - { - if( material.HasProperty( IOUtils.ChromaticAberrationProperty ) ) - m_inlineChromaticAberration.FloatValue = material.GetFloat( IOUtils.ChromaticAberrationProperty ); - } - } - - public override void UpdateMasterNodeMaterial( Material material ) - { - m_currentMaterial = material; - UpdateMaterialEditor(); - } - - void UpdateMaterialEditor() - { - FireMaterialChangedEvt(); - } - - public string CreateInstructionsForVertexPort( InputPort port ) - { - //Vertex displacement and per vertex custom data - WireReference connection = port.GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - string vertexInstructions = node.GetValueFromOutputStr( connection.PortId, port.DataType, ref m_currentDataCollector, false ); - - if( m_currentDataCollector.DirtySpecialLocalVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.SpecialLocalVariables, UniqueId, false ); - m_currentDataCollector.ClearSpecialLocalVariables(); - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, UniqueId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - return vertexInstructions; - } - - public void CreateInstructionsForPort( InputPort port, string portName, bool addCustomDelimiters = false, string customDelimiterIn = null, string customDelimiterOut = null, bool ignoreLocalVar = false, bool normalIsConnected = false , bool isDebugPort = false ) - { - WireReference connection = port.GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - string newInstruction = node.GetValueFromOutputStr( connection.PortId, port.DataType, ref m_currentDataCollector, ignoreLocalVar ); - - if( m_currentDataCollector.DirtySpecialLocalVariables ) - { - m_currentDataCollector.AddInstructions( m_currentDataCollector.SpecialLocalVariables ); - m_currentDataCollector.ClearSpecialLocalVariables(); - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, port.NodeId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - if( m_currentDataCollector.ForceNormal && !normalIsConnected ) - { - m_currentDataCollector.AddToStartInstructions( "\t\t\t" + Constants.OutputVarStr + ".Normal = float3(0,0,1);\n" ); - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = false; - } - - m_currentDataCollector.AddInstructions( addCustomDelimiters ? customDelimiterIn : ( "\t\t\t" + portName + " = " ) ); - m_currentDataCollector.AddInstructions( newInstruction ); - m_currentDataCollector.AddInstructions( addCustomDelimiters ? customDelimiterOut :((isDebugPort)?" + 1E-5;\n":";\n") ); - } - - public string CreateInstructionStringForPort( InputPort port, bool ignoreLocalVar = false ) - { - WireReference connection = port.GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - string newInstruction = node.GetValueFromOutputStr( connection.PortId, port.DataType, ref m_currentDataCollector, ignoreLocalVar ); - - if( m_currentDataCollector.DirtySpecialLocalVariables ) - { - m_currentDataCollector.AddInstructions( m_currentDataCollector.SpecialLocalVariables ); - m_currentDataCollector.ClearSpecialLocalVariables(); - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, port.NodeId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - if( m_currentDataCollector.ForceNormal ) - { - m_currentDataCollector.AddToStartInstructions( "\t\t\t" + Constants.OutputVarStr + ".Normal = float3(0,0,1);\n" ); - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = false; - } - - return newInstruction; - } - - public override Shader Execute( string pathname, bool isFullPath ) - { - ForcePortType(); - ForceReordering(); - UpdateFromBlendMode(); - base.Execute( pathname, isFullPath ); - RegisterStandaloneFuntions(); - - bool isInstancedShader = m_renderingOptionsOpHelper.ForceEnableInstancing || UIUtils.IsInstancedShader(); - bool hasVirtualTexture = UIUtils.HasVirtualTexture(); - bool hasTranslucency = false; - bool hasTransmission = false; - bool hasEmission = false; - bool hasOpacity = false; - bool hasOpacityMask = false; - bool hasRefraction = false; - //bool hasVertexOffset = false; - //bool hasCustomLightingAlpha = false; - bool hasCustomLightingMask = false; - - string customLightingCode = string.Empty; - string customLightingAlphaCode = string.Empty; - string customLightingMaskCode = string.Empty; - string customLightingInstructions = string.Empty; - - string refractionCode = string.Empty; - string refractionInstructions = string.Empty; - string refractionFix = string.Empty; - - string aboveUsePasses = string.Empty; - string bellowUsePasses = string.Empty; - - - m_currentDataCollector.TesselationActive = m_tessOpHelper.EnableTesselation; - m_currentDataCollector.CurrentRenderPath = m_renderPath; - - StandardShaderLightModel cachedLightModel = m_currentLightModel; - NodeAvailability cachedAvailability = ContainerGraph.CurrentCanvasMode; - - bool debugIsUsingCustomLighting = false; - bool usingDebugPort = false; - if( m_inputPorts[ m_inputPorts.Count - 1 ].IsConnected ) - { - usingDebugPort = true; - debugIsUsingCustomLighting = m_currentLightModel == StandardShaderLightModel.CustomLighting; - - m_currentDataCollector.GenType = PortGenType.CustomLighting; - m_currentLightModel = StandardShaderLightModel.CustomLighting; - ContainerGraph.CurrentCanvasMode = NodeAvailability.CustomLighting; - } - - if( isInstancedShader ) - { - m_currentDataCollector.AddToPragmas( UniqueId, IOUtils.InstancedPropertiesHeader ); - } - - if( m_renderingOptionsOpHelper.SpecularHighlightToggle || m_renderingOptionsOpHelper.ReflectionsToggle ) - m_currentDataCollector.AddToProperties( UniqueId, "[Header(Forward Rendering Options)]", 10001 ); - if( m_renderingOptionsOpHelper.SpecularHighlightToggle ) - { - m_currentDataCollector.AddToProperties( UniqueId, "[ToggleOff] _SpecularHighlights(\"Specular Highlights\", Float) = 1.0", 10002 ); - m_currentDataCollector.AddToPragmas( UniqueId, "shader_feature _SPECULARHIGHLIGHTS_OFF" ); - } - if( m_renderingOptionsOpHelper.ReflectionsToggle ) - { - m_currentDataCollector.AddToProperties( UniqueId, "[ToggleOff] _GlossyReflections(\"Reflections\", Float) = 1.0", 10003 ); - m_currentDataCollector.AddToPragmas( UniqueId, "shader_feature _GLOSSYREFLECTIONS_OFF" ); - } - - - // See if each node is being used on frag and/or vert ports - SetupNodeCategories(); - m_containerGraph.CheckPropertiesAutoRegister( ref m_currentDataCollector ); - - if( m_refractionPort.IsConnected || m_inputPorts[ m_inputPorts.Count - 1 ].IsConnected ) - { - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = true; - } - //this.PropagateNodeData( nodeData ); - - string tags = "\"RenderType\" = \"{0}\" \"Queue\" = \"{1}\""; - string finalRenderType = ( m_renderType == RenderType.Custom && m_customRenderType.Length > 0 ) ? m_customRenderType : m_renderType.ToString(); - tags = string.Format( tags, finalRenderType, ( m_renderQueue + ( ( m_queueOrder >= 0 ) ? "+" : string.Empty ) + m_queueOrder ) ); - //if ( !m_customBlendMode ) - { - if( m_alphaMode == AlphaMode.Transparent || m_alphaMode == AlphaMode.Premultiply ) - { - //tags += " \"IgnoreProjector\" = \"True\""; - if( !m_renderingOptionsOpHelper.IgnoreProjectorValue ) - { - Debug.Log( string.Format( "Setting Ignore Projector to True since it's requires by Blend Mode {0}.", m_alphaMode ) ); - m_renderingOptionsOpHelper.IgnoreProjectorValue = true; - } - } - } - - tags += m_renderingOptionsOpHelper.IgnoreProjectorTag; - tags += m_renderingOptionsOpHelper.ForceNoShadowCastingTag; - tags += m_renderingOptionsOpHelper.DisableBatchingTag; - - //add virtual texture support - if( hasVirtualTexture ) - { - tags += " \"Amplify\" = \"True\" "; - } - - //tags = "Tags{ " + tags + " }"; - - string outputStruct = ""; - switch( m_currentLightModel ) - { - case StandardShaderLightModel.CustomLighting: outputStruct = "SurfaceOutputCustomLightingCustom"; break; - case StandardShaderLightModel.Standard: outputStruct = "SurfaceOutputStandard"; break; - case StandardShaderLightModel.StandardSpecular: outputStruct = "SurfaceOutputStandardSpecular"; break; - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: outputStruct = "SurfaceOutput"; break; - } - - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - m_currentDataCollector.AddToIncludes( UniqueId, Constants.UnityPBSLightingLib ); - - m_currentDataCollector.ChangeCustomInputHeader( m_currentLightModel.ToString() + Constants.CustomLightStructStr ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Albedo", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Normal", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Emission", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Metallic", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Smoothness", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Occlusion", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Alpha", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "Input SurfInput", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "UnityGIInput GIData", true ); - } - - //Terrain Draw Instanced - if( m_drawInstancedHelper.Enabled ) - { - if( !m_currentDataCollector.DirtyPerVertexData ) - { - m_currentDataCollector.OpenPerVertexHeader( !m_tessOpHelper.EnableTesselation ); - } - m_drawInstancedHelper.UpdateDataCollectorForStandard( ref m_currentDataCollector ); - } - - // Need to sort before creating local vars so they can inspect the normal port correctly - SortedList<int, InputPort> sortedPorts = new SortedList<int, InputPort>(); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - sortedPorts.Add( m_inputPorts[ i ].OrderId, m_inputPorts[ i ] ); - } - - bool normalIsConnected = m_normalPort.IsConnected; - m_tessOpHelper.Reset(); - if( m_inputPorts[ m_inputPorts.Count - 1 ].IsConnected ) - { - //Debug Port active - InputPort debugPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_currentDataCollector.PortCategory = debugPort.Category; - if( debugIsUsingCustomLighting ) - { - m_currentDataCollector.UsingCustomOutput = true; - WireReference connection = m_inputPorts[ m_inputPorts.Count - 1 ].GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - customLightingCode = node.GetValueFromOutputStr( connection.PortId, WirePortDataType.FLOAT3, ref m_currentDataCollector, false ); - customLightingInstructions = m_currentDataCollector.CustomOutput; - - if( m_currentDataCollector.ForceNormal ) - { - m_currentDataCollector.AddToStartInstructions( "\t\t\t" + Constants.OutputVarStr + ".Normal = float3(0,0,1);\n" ); - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = false; - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, UniqueId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - m_currentDataCollector.UsingCustomOutput = false; - } - else - { - CreateInstructionsForPort( debugPort, Constants.OutputVarStr + ".Emission", false, null, null, false, false,true ); - } - } - else - { - MasterNodePortCategory currentCategory = sortedPorts[ 0 ].Category; - //Collect data from standard nodes - for( int i = 0; i < sortedPorts.Count; i++ ) - { - // prepare ports for custom lighting - m_currentDataCollector.GenType = sortedPorts[ i ].GenType; - if( m_currentLightModel == StandardShaderLightModel.CustomLighting && sortedPorts[ i ].Name.Equals( AlphaStr ) ) - ContainerGraph.ResetNodesLocalVariablesIfNot( MasterNodePortCategory.Vertex ); - - if( sortedPorts[ i ].IsConnected ) - { - m_currentDataCollector.PortCategory = sortedPorts[ i ].Category; - - if( sortedPorts[ i ].Name.Equals( NormalStr ) )// Normal Map is Connected - { - m_currentDataCollector.DirtyNormal = true; - } - if( sortedPorts[ i ].Name.Equals( TranslucencyStr ) ) - { - hasTranslucency = true; - } - if( sortedPorts[ i ].Name.Equals( TransmissionStr ) ) - { - hasTransmission = true; - } - if( sortedPorts[ i ].Name.Equals( EmissionStr ) ) - { - hasEmission = true; - } - - if( sortedPorts[ i ].Name.Equals( RefractionStr ) ) - { - hasRefraction = true; - } - - if( sortedPorts[ i ].Name.Equals( AlphaStr ) ) - { - hasOpacity = true; - } - - if( sortedPorts[ i ].Name.Equals( DiscardStr ) ) - { - hasOpacityMask = true; - } - - if( hasRefraction ) - { - m_currentDataCollector.AddToInput( UniqueId, SurfaceInputs.SCREEN_POS ); - m_currentDataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - - //not necessary, just being safe - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = true; - - if( m_grabOrder != 0 ) - { - m_currentDataCollector.AddGrabPass( "RefractionGrab" + m_grabOrder ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform sampler2D RefractionGrab" + m_grabOrder + ";" ); - } - else - { - m_currentDataCollector.AddGrabPass( "" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform sampler2D _GrabTexture;" ); - } - - if( !m_inlineChromaticAberration.Active ) - { - m_currentDataCollector.AddToUniforms( UniqueId, "uniform float _ChromaticAberration;" ); - - m_currentDataCollector.AddToProperties( UniqueId, "[Header(Refraction)]", m_refractionReorder.OrderIndex ); - m_currentDataCollector.AddToProperties( UniqueId, "_ChromaticAberration(\"Chromatic Aberration\", Range( 0 , 0.3)) = 0.1", m_refractionReorder.OrderIndex + 1 ); - } - - m_currentDataCollector.AddToPragmas( UniqueId, "multi_compile _ALPHAPREMULTIPLY_ON" ); - } - - if( hasTranslucency || hasTransmission ) - { - //Translucency and Transmission Generation - - //Add properties and uniforms - m_currentDataCollector.AddToIncludes( UniqueId, Constants.UnityPBSLightingLib ); - - if( hasTranslucency ) - { - m_currentDataCollector.AddToProperties( UniqueId, "[Header(Translucency)]", m_translucencyReorder.OrderIndex ); - m_currentDataCollector.AddToProperties( UniqueId, "_Translucency(\"Strength\", Range( 0 , 50)) = 1", m_translucencyReorder.OrderIndex + 1 ); - m_currentDataCollector.AddToProperties( UniqueId, "_TransNormalDistortion(\"Normal Distortion\", Range( 0 , 1)) = 0.1", m_translucencyReorder.OrderIndex + 2 ); - m_currentDataCollector.AddToProperties( UniqueId, "_TransScattering(\"Scaterring Falloff\", Range( 1 , 50)) = 2", m_translucencyReorder.OrderIndex + 3 ); - m_currentDataCollector.AddToProperties( UniqueId, "_TransDirect(\"Direct\", Range( 0 , 1)) = 1", m_translucencyReorder.OrderIndex + 4 ); - m_currentDataCollector.AddToProperties( UniqueId, "_TransAmbient(\"Ambient\", Range( 0 , 1)) = 0.2", m_translucencyReorder.OrderIndex + 5 ); - m_currentDataCollector.AddToProperties( UniqueId, "_TransShadow(\"Shadow\", Range( 0 , 1)) = 0.9", m_translucencyReorder.OrderIndex + 6 ); - - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _Translucency;" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _TransNormalDistortion;" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _TransScattering;" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _TransDirect;" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _TransAmbient;" ); - m_currentDataCollector.AddToUniforms( UniqueId, "uniform half _TransShadow;" ); - } - - //Add custom struct - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - outputStruct = "SurfaceOutput" + m_currentLightModel.ToString() + Constants.CustomLightStructStr; break; - } - - m_currentDataCollector.ChangeCustomInputHeader( m_currentLightModel.ToString() + Constants.CustomLightStructStr ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Albedo", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Normal", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Emission", true ); - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - m_currentDataCollector.AddToCustomInput( UniqueId, "half Metallic", true ); - break; - case StandardShaderLightModel.StandardSpecular: - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Specular", true ); - break; - } - m_currentDataCollector.AddToCustomInput( UniqueId, "half Smoothness", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Occlusion", true ); - m_currentDataCollector.AddToCustomInput( UniqueId, "half Alpha", true ); - if( hasTranslucency ) - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Translucency", true ); - - if( hasTransmission ) - m_currentDataCollector.AddToCustomInput( UniqueId, "half3 Transmission", true ); - } - - if( sortedPorts[ i ].Name.Equals( DiscardStr ) ) - { - //Discard Op Node - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - hasCustomLightingMask = true; - m_currentDataCollector.UsingCustomOutput = true; - m_currentDataCollector.GenType = PortGenType.CustomLighting; - WireReference connection = sortedPorts[ i ].GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - customLightingMaskCode = node.GetValueFromOutputStr( connection.PortId, WirePortDataType.FLOAT, ref m_currentDataCollector, false ); - customLightingMaskCode = "clip( " + customLightingMaskCode + " - " + m_inlineOpacityMaskClipValue.GetValueOrProperty( IOUtils.MaskClipValueName, false ) + " )"; - customLightingInstructions = m_currentDataCollector.CustomOutput; - - m_currentDataCollector.GenType = PortGenType.NonCustomLighting; - m_currentDataCollector.UsingCustomOutput = false; - continue; - } - else - { - string clipIn = "\t\t\tclip( "; - string clipOut = " - " + m_inlineOpacityMaskClipValue.GetValueOrProperty( IOUtils.MaskClipValueName, false ) + " );\n"; - //if( ( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) && m_castShadows ) - //{ - // clipIn = "\t\t\t#if UNITY_PASS_SHADOWCASTER\n" + clipIn; - // clipOut = clipOut + "\t\t\t#endif\n"; - //} - CreateInstructionsForPort( sortedPorts[ i ], Constants.OutputVarStr + "." + sortedPorts[ i ].DataName, true, clipIn, clipOut, false, normalIsConnected ); - } - } - else if( sortedPorts[ i ].DataName.Equals( VertexDataStr ) ) - { - string vertexInstructions = CreateInstructionsForVertexPort( sortedPorts[ i ] ); - m_currentDataCollector.AddToVertexDisplacement( vertexInstructions, m_vertexMode ); - } - else if( sortedPorts[ i ].DataName.Equals( VertexNormalStr ) ) - { - string vertexInstructions = CreateInstructionsForVertexPort( sortedPorts[ i ] ); - m_currentDataCollector.AddToVertexNormal( vertexInstructions ); - } - else if( m_tessOpHelper.IsTessellationPort( sortedPorts[ i ].PortId ) && sortedPorts[ i ].IsConnected /* && m_tessOpHelper.EnableTesselation*/) - { - //Vertex displacement and per vertex custom data - WireReference connection = sortedPorts[ i ].GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - string vertexInstructions = node.GetValueFromOutputStr( connection.PortId, sortedPorts[ i ].DataType, ref m_currentDataCollector, false ); - - if( m_currentDataCollector.DirtySpecialLocalVariables ) - { - m_tessOpHelper.AddAdditionalData( m_currentDataCollector.SpecialLocalVariables ); - m_currentDataCollector.ClearSpecialLocalVariables(); - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_tessOpHelper.AddAdditionalData( m_currentDataCollector.VertexLocalVariables ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - m_tessOpHelper.AddCustomFunction( vertexInstructions ); - } - else if( sortedPorts[ i ].Name.Equals( RefractionStr ) ) - { - ContainerGraph.ResetNodesLocalVariables(); - m_currentDataCollector.UsingCustomOutput = true; - - refractionFix = " + 0.00001 * i.screenPos * i.worldPos"; - m_currentDataCollector.AddInstructions( "\t\t\to.Normal = o.Normal" + refractionFix + ";\n" ); - refractionCode = CreateInstructionStringForPort( sortedPorts[ i ], false ); - refractionInstructions = m_currentDataCollector.CustomOutput; - - m_currentDataCollector.UsingCustomOutput = false; - } - else if( sortedPorts[ i ].Name.Equals( CustomLightingStr ) ) - { - m_currentDataCollector.UsingCustomOutput = true; - WireReference connection = sortedPorts[ i ].GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - customLightingCode = node.GetValueFromOutputStr( connection.PortId, WirePortDataType.FLOAT3, ref m_currentDataCollector, false ); - customLightingInstructions = m_currentDataCollector.CustomOutput; - - if( m_currentDataCollector.ForceNormal ) - { - m_currentDataCollector.AddToStartInstructions( "\t\t\t" + Constants.OutputVarStr + ".Normal = float3(0,0,1);\n" ); - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = false; - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, UniqueId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - m_currentDataCollector.UsingCustomOutput = false; - - } - else if( sortedPorts[ i ].Name.Equals( AlphaStr ) && m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - m_currentDataCollector.UsingCustomOutput = true; - m_currentDataCollector.GenType = PortGenType.CustomLighting; - - WireReference connection = sortedPorts[ i ].GetConnection(); - ParentNode node = UIUtils.GetNode( connection.NodeId ); - - customLightingAlphaCode = node.GetValueFromOutputStr( connection.PortId, WirePortDataType.FLOAT, ref m_currentDataCollector, false ); - customLightingInstructions = m_currentDataCollector.CustomOutput; - - if( m_currentDataCollector.ForceNormal ) - { - m_currentDataCollector.AddToStartInstructions( "\t\t\t" + Constants.OutputVarStr + ".Normal = float3(0,0,1);\n" ); - m_currentDataCollector.DirtyNormal = true; - m_currentDataCollector.ForceNormal = false; - } - - if( m_currentDataCollector.DirtyVertexVariables ) - { - m_currentDataCollector.AddVertexInstruction( m_currentDataCollector.VertexLocalVariables, UniqueId, false ); - m_currentDataCollector.ClearVertexLocalVariables(); - } - - m_currentDataCollector.GenType = PortGenType.NonCustomLighting; - m_currentDataCollector.UsingCustomOutput = false; - } - else - { - // Surface shader instruccions - // if working on normals and have normal dependent node then ignore local var generation - CreateInstructionsForPort( sortedPorts[ i ], Constants.OutputVarStr + "." + sortedPorts[ i ].DataName, false, null, null, false, normalIsConnected ); - } - } - else if( sortedPorts[ i ].Name.Equals( AlphaStr ) ) - { - if( m_currentLightModel != StandardShaderLightModel.CustomLighting ) - { - m_currentDataCollector.AddInstructions( string.Format( "\t\t\t{0}.{1} = 1;\n", Constants.OutputVarStr, sortedPorts[ i ].DataName ) ); - } - } - } - - m_billboardOpHelper.FillDataCollectorWithInternalData( ref m_currentDataCollector ); - } - - - if( !m_renderingOptionsOpHelper.UseDefaultShadowCaster && - ( ( m_castShadows && ( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) ) || - ( m_castShadows && hasOpacity ) || - ( m_castShadows && ( m_currentDataCollector.UsingWorldNormal || m_currentDataCollector.UsingWorldReflection || m_currentDataCollector.UsingViewDirection ) ) || - ( m_castShadows && m_inputPorts[ m_discardPortId ].Available && m_inputPorts[ m_discardPortId ].IsConnected && m_currentLightModel == StandardShaderLightModel.CustomLighting ) )) - m_customShadowCaster = true; - else - m_customShadowCaster = false; - - //m_customShadowCaster = true; - - for( int i = 0; i < 4; i++ ) - { - if( m_currentDataCollector.GetChannelUsage( i ) == TextureChannelUsage.Required ) - { - string channelName = UIUtils.GetChannelName( i ); - m_currentDataCollector.AddToProperties( -1, UIUtils.GetTex2DProperty( channelName, TexturePropertyValues.white ), -1 ); - } - } - - m_currentDataCollector.AddToProperties( -1, IOUtils.DefaultASEDirtyCheckProperty, 10000 ); - if( m_inputPorts[ m_discardPortId ].Available && m_inputPorts[ m_discardPortId ].IsConnected ) - { - if( m_inlineOpacityMaskClipValue.IsValid ) - { - RangedFloatNode fnode = UIUtils.GetNode( m_inlineOpacityMaskClipValue.NodeId ) as RangedFloatNode; - if( fnode != null ) - { - m_currentDataCollector.AddToProperties( fnode.UniqueId, fnode.GetPropertyValue(), fnode.OrderIndex ); - m_currentDataCollector.AddToUniforms( fnode.UniqueId, fnode.GetUniformValue() ); - } - else - { - IntNode inode = UIUtils.GetNode( m_inlineOpacityMaskClipValue.NodeId ) as IntNode; - m_currentDataCollector.AddToProperties( inode.UniqueId, inode.GetPropertyValue(), inode.OrderIndex ); - m_currentDataCollector.AddToUniforms( inode.UniqueId, inode.GetUniformValue() ); - } - } - else - { - m_currentDataCollector.AddToProperties( -1, string.Format( IOUtils.MaskClipValueProperty, OpacityMaskClipValueStr, m_opacityMaskClipValue ), ( m_maskClipReorder != null ) ? m_maskClipReorder.OrderIndex : -1 ); - m_currentDataCollector.AddToUniforms( -1, string.Format( IOUtils.MaskClipValueUniform, m_opacityMaskClipValue ) ); - } - } - - if( !m_currentDataCollector.DirtyInputs ) - m_currentDataCollector.AddToInput( UniqueId, "half filler", true ); - - if( m_currentLightModel == StandardShaderLightModel.BlinnPhong ) - m_currentDataCollector.AddToProperties( -1, "_SpecColor(\"Specular Color\",Color)=(1,1,1,1)", m_specColorReorder.OrderIndex ); - - //Tesselation - if( m_tessOpHelper.EnableTesselation ) - { - m_tessOpHelper.AddToDataCollector( ref m_currentDataCollector, m_tessellationReorder != null ? m_tessellationReorder.OrderIndex : -1 ); - if( !m_currentDataCollector.DirtyPerVertexData ) - { - m_currentDataCollector.OpenPerVertexHeader( false ); - } - } - - - if( m_outlineHelper.EnableOutline || ( m_currentDataCollector.UsingCustomOutlineColor || m_currentDataCollector.CustomOutlineSelectedAlpha > 0 || m_currentDataCollector.UsingCustomOutlineWidth ) ) - { - m_outlineHelper.AddToDataCollector( ref m_currentDataCollector ); - } - -#if !UNITY_2017_1_OR_NEWER - if( m_renderingOptionsOpHelper.LodCrossfade ) - { - m_currentDataCollector.AddToPragmas( UniqueId, "multi_compile _ LOD_FADE_CROSSFADE" ); - m_currentDataCollector.AddToStartInstructions( "\t\t\tUNITY_APPLY_DITHER_CROSSFADE(i);\n" ); - m_currentDataCollector.AddToInput( UniqueId, "UNITY_DITHER_CROSSFADE_COORDS", false ); - m_currentDataCollector.AddVertexInstruction( "UNITY_TRANSFER_DITHER_CROSSFADE( " + Constants.VertexShaderOutputStr + ", " + Constants.VertexShaderInputStr + ".vertex )", UniqueId, true ); - } -#endif - //m_additionalIncludes.AddToDataCollector( ref m_currentDataCollector ); - //m_additionalPragmas.AddToDataCollector( ref m_currentDataCollector ); - //m_additionalDefines.AddToDataCollector( ref m_currentDataCollector ); - m_additionalDirectives.AddAllToDataCollector( ref m_currentDataCollector ); - - //m_currentDataCollector.CloseInputs(); - m_currentDataCollector.CloseCustomInputs(); - m_currentDataCollector.CloseProperties(); - m_currentDataCollector.ClosePerVertexHeader(); - - //build Shader Body - string ShaderBody = string.Empty; - OpenShaderBody( ref ShaderBody, m_shaderName ); - { - //set properties - if( m_currentDataCollector.DirtyProperties ) - { - ShaderBody += m_currentDataCollector.BuildPropertiesString(); - } - //set subshader - OpenSubShaderBody( ref ShaderBody ); - { - - // Add extra depth pass - m_zBufferHelper.DrawExtraDepthPass( ref ShaderBody ); - - // Add optionalPasses - if( m_outlineHelper.EnableOutline || ( m_currentDataCollector.UsingCustomOutlineColor || m_currentDataCollector.CustomOutlineSelectedAlpha > 0 || m_currentDataCollector.UsingCustomOutlineWidth ) ) - { - if( !usingDebugPort ) - AddMultilineBody( ref ShaderBody, m_outlineHelper.OutlineFunctionBody( ref m_currentDataCollector, isInstancedShader, m_customShadowCaster, UIUtils.RemoveInvalidCharacters( ShaderName ), ( m_billboardOpHelper.IsBillboard && !usingDebugPort ? m_billboardOpHelper.GetInternalMultilineInstructions() : null ), ref m_tessOpHelper, ShaderModelTypeArr[ m_shaderModelIdx ], CurrentPrecisionType ) ); - } - - //Add SubShader tags - if( hasEmission ) - { - tags += " \"IsEmissive\" = \"true\" "; - } - - tags += m_customTagsHelper.GenerateCustomTags(); - - tags = "Tags{ " + tags + " }"; - m_usePass.BuildUsePassInfo( m_currentDataCollector, ref aboveUsePasses, ref bellowUsePasses, "\t\t" ); - if( !string.IsNullOrEmpty( aboveUsePasses ) ) - { - ShaderBody += aboveUsePasses; - } - - AddRenderTags( ref ShaderBody, tags ); - AddShaderLOD( ref ShaderBody, ShaderLOD ); - AddRenderState( ref ShaderBody, "Cull", m_inlineCullMode.GetValueOrProperty( m_cullMode.ToString() ) ); - m_customBlendAvailable = ( m_alphaMode == AlphaMode.Custom || m_alphaMode == AlphaMode.Opaque ); - if( ( m_zBufferHelper.IsActive && m_customBlendAvailable ) || m_outlineHelper.UsingZWrite || m_outlineHelper.UsingZTest ) - { - ShaderBody += m_zBufferHelper.CreateDepthInfo( m_outlineHelper.UsingZWrite, m_outlineHelper.UsingZTest ); - } - if( m_stencilBufferHelper.Active ) - { - ShaderBody += m_stencilBufferHelper.CreateStencilOp( this ); - } - - if( m_blendOpsHelper.Active ) - { - ShaderBody += m_blendOpsHelper.CreateBlendOps(); - } - - if( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) - { - ShaderBody += "\t\tAlphaToMask "+ m_inlineAlphaToCoverage.GetValueOrProperty( "On" )+"\n"; - } - - // Build Color Mask - m_colorMaskHelper.BuildColorMask( ref ShaderBody, m_customBlendAvailable ); - - //ShaderBody += "\t\tZWrite " + _zWriteMode + '\n'; - //ShaderBody += "\t\tZTest " + _zTestMode + '\n'; - - //Add GrabPass - if( m_currentDataCollector.DirtyGrabPass ) - { - ShaderBody += m_currentDataCollector.GrabPass; - } - - // build optional parameters - string OptionalParameters = string.Empty; - - // addword standard to custom lighting to accepts standard lighting models - string standardCustomLighting = string.Empty; - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - standardCustomLighting = "Standard"; - - //add cg program - if( m_customShadowCaster ) - OpenCGInclude( ref ShaderBody ); - else - OpenCGProgram( ref ShaderBody ); - { - //Add Defines - if( m_currentDataCollector.DirtyDefines ) - ShaderBody += m_currentDataCollector.Defines; - - //Add Includes - if( m_customShadowCaster ) - { - m_currentDataCollector.AddToIncludes( UniqueId, Constants.UnityPBSLightingLib ); - m_currentDataCollector.AddToIncludes( UniqueId, "Lighting.cginc" ); - } - if( m_currentDataCollector.DirtyIncludes ) - ShaderBody += m_currentDataCollector.Includes; - - //define as surface shader and specify lighting model - if( UIUtils.GetTextureArrayNodeAmount() > 0 && m_shaderModelIdx < 3 ) - { - UIUtils.ShowMessage( "Automatically changing Shader Model to 3.5 since\nit's the minimum required by texture arrays." ); - m_shaderModelIdx = 3; - } - - // if tessellation is active then we need be at least using shader model 4.6 - if( m_tessOpHelper.EnableTesselation && m_shaderModelIdx < 6 ) - { - UIUtils.ShowMessage( "Automatically changing Shader Model to 4.6 since\nit's the minimum required by tessellation." ); - m_shaderModelIdx = 6; - } - - // if translucency is ON change render path - if( hasTranslucency && m_renderPath != RenderPath.ForwardOnly ) - { - UIUtils.ShowMessage( "Automatically changing Render Path to Forward Only since\ntranslucency only works in forward rendering." ); - m_renderPath = RenderPath.ForwardOnly; - } - - // if outline is ON change render path - if( m_outlineHelper.EnableOutline && m_renderPath != RenderPath.ForwardOnly ) - { - UIUtils.ShowMessage( "Automatically changing Render Path to Forward Only since\noutline only works in forward rendering." ); - m_renderPath = RenderPath.ForwardOnly; - } - - // if transmission is ON change render path - if( hasTransmission && m_renderPath != RenderPath.ForwardOnly ) - { - UIUtils.ShowMessage( "Automatically changing Render Path to Forward Only since\ntransmission only works in forward rendering." ); - m_renderPath = RenderPath.ForwardOnly; - } - - // if refraction is ON change render path - if( hasRefraction && m_renderPath != RenderPath.ForwardOnly ) - { - UIUtils.ShowMessage( "Automatically changing Render Path to Forward Only since\nrefraction only works in forward rendering." ); - m_renderPath = RenderPath.ForwardOnly; - } - - ShaderBody += string.Format( IOUtils.PragmaTargetHeader, ShaderModelTypeArr[ m_shaderModelIdx ] ); - - - //Add pragmas (needs check to see if all pragmas work with custom shadow caster) - if( m_currentDataCollector.DirtyPragmas/* && !m_customShadowCaster */) - ShaderBody += m_currentDataCollector.Pragmas; - - if( m_currentDataCollector.DirtyAdditionalDirectives ) - ShaderBody += m_currentDataCollector.StandardAdditionalDirectives; - - //if ( !m_customBlendMode ) - { - switch( m_alphaMode ) - { - case AlphaMode.Opaque: - case AlphaMode.Masked: break; - case AlphaMode.Transparent: - { - OptionalParameters += "alpha:fade" + Constants.OptionalParametersSep; - } - break; - case AlphaMode.Premultiply: - { - OptionalParameters += "alpha:premul" + Constants.OptionalParametersSep; - } - break; - } - } - - if( m_keepAlpha ) - { - OptionalParameters += "keepalpha" + Constants.OptionalParametersSep; - } - - if( hasRefraction ) - { - OptionalParameters += "finalcolor:RefractionF" + Constants.OptionalParametersSep; - } - - if( !m_customShadowCaster && m_castShadows ) - { - OptionalParameters += "addshadow" + Constants.OptionalParametersSep; - } - - if( m_castShadows ) - { - OptionalParameters += "fullforwardshadows" + Constants.OptionalParametersSep; - } - - if( !m_receiveShadows ) - { - OptionalParameters += "noshadow" + Constants.OptionalParametersSep; - } - - if( m_renderingOptionsOpHelper.IsOptionActive( " Add Pass" ) && usingDebugPort ) - { - OptionalParameters += "noforwardadd" + Constants.OptionalParametersSep; - } - - if( m_renderingOptionsOpHelper.ForceDisableInstancing ) - { - OptionalParameters += "noinstancing" + Constants.OptionalParametersSep; - } - - switch( m_renderPath ) - { - case RenderPath.All: break; - case RenderPath.DeferredOnly: OptionalParameters += "exclude_path:forward" + Constants.OptionalParametersSep; break; - case RenderPath.ForwardOnly: OptionalParameters += "exclude_path:deferred" + Constants.OptionalParametersSep; break; - } - - //Add code generation options - m_renderingOptionsOpHelper.Build( ref OptionalParameters ); - - if( !m_customShadowCaster ) - { - string customLightSurface = string.Empty; - if( hasTranslucency || hasTransmission ) - customLightSurface = "Custom"; - m_renderingPlatformOpHelper.SetRenderingPlatforms( ref ShaderBody ); - - //Check if Custom Vertex is being used and add tag - if( m_currentDataCollector.DirtyPerVertexData ) - OptionalParameters += "vertex:" + Constants.VertexDataFunc + Constants.OptionalParametersSep; - - if( m_tessOpHelper.EnableTesselation && !usingDebugPort ) - { - m_tessOpHelper.WriteToOptionalParams( ref OptionalParameters ); - } - - m_additionalSurfaceOptions.WriteToOptionalSurfaceOptions( ref OptionalParameters ); - - AddShaderPragma( ref ShaderBody, "surface surf " + standardCustomLighting + m_currentLightModel.ToString() + customLightSurface + Constants.OptionalParametersSep + OptionalParameters ); - } - else - { - if( /*m_currentDataCollector.UsingWorldNormal ||*/ m_currentDataCollector.UsingInternalData ) - { - ShaderBody += "\t\t#ifdef UNITY_PASS_SHADOWCASTER\n"; - ShaderBody += "\t\t\t#undef INTERNAL_DATA\n"; - ShaderBody += "\t\t\t#undef WorldReflectionVector\n"; - ShaderBody += "\t\t\t#undef WorldNormalVector\n"; - ShaderBody += "\t\t\t#define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;\n"; - ShaderBody += "\t\t\t#define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))\n"; - ShaderBody += "\t\t\t#define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))\n"; - ShaderBody += "\t\t#endif\n"; - } - } - - if( m_currentDataCollector.UsingHigherSizeTexcoords ) - { - ShaderBody += "\t\t#undef TRANSFORM_TEX\n"; - ShaderBody += "\t\t#define TRANSFORM_TEX(tex,name) float4(tex.xy * name##_ST.xy + name##_ST.zw, tex.z, tex.w)\n"; - } - - if( m_currentDataCollector.DirtyAppData ) - ShaderBody += m_currentDataCollector.CustomAppData; - - // Add Input struct - if( m_currentDataCollector.DirtyInputs ) - ShaderBody += "\t\t" + m_currentDataCollector.Inputs + "\t\t};" + "\n\n"; - - // Add Custom Lighting struct - if( m_currentDataCollector.DirtyCustomInput ) - ShaderBody += m_currentDataCollector.CustomInput + "\n\n"; - - //Add Uniforms - if( m_currentDataCollector.DirtyUniforms ) - ShaderBody += m_currentDataCollector.Uniforms + "\n"; - - // Add Array Derivatives Macros - //if( m_currentDataCollector.UsingArrayDerivatives ) - //{ - // ShaderBody += "\t\t#if defined(UNITY_COMPILER_HLSL2GLSL) || defined(SHADER_TARGET_SURFACE_ANALYSIS)\n"; - // ShaderBody += "\t\t\t#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) UNITY_SAMPLE_TEX2DARRAY (tex,coord)\n"; - // ShaderBody += "\t\t#else\n"; - // ShaderBody += "\t\t\t#define ASE_SAMPLE_TEX2DARRAY_GRAD(tex,coord,dx,dy) tex.SampleGrad (sampler##tex,coord,dx,dy)\n"; - // ShaderBody += "\t\t#endif\n\n"; - //} - - //Add Instanced Properties - if( isInstancedShader && m_currentDataCollector.DirtyInstancedProperties ) - { - m_currentDataCollector.SetupInstancePropertiesBlock( UIUtils.RemoveInvalidCharacters( ShaderName ) ); - ShaderBody += m_currentDataCollector.InstancedProperties + "\n"; - } - - if( m_currentDataCollector.DirtyFunctions ) - ShaderBody += m_currentDataCollector.Functions + "\n"; - - - //Tesselation - if( m_tessOpHelper.EnableTesselation && !usingDebugPort ) - { - ShaderBody += m_tessOpHelper.GetCurrentTessellationFunction + "\n"; - } - - //Add Custom Vertex Data - if( m_currentDataCollector.DirtyPerVertexData ) - { - ShaderBody += m_currentDataCollector.VertexData; - } - - if( m_currentLightModel == StandardShaderLightModel.Unlit ) - { - for( int i = 0; i < VertexLitFunc.Length; i++ ) - { - ShaderBody += VertexLitFunc[ i ] + "\n"; - } - } - - //Add custom lighting - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - ShaderBody += "\t\tinline half4 LightingStandard" + m_currentLightModel.ToString() + "( inout " + outputStruct + " " + Constants.CustomLightOutputVarStr + ", half3 viewDir, UnityGI gi )\n\t\t{\n"; - ShaderBody += "\t\t\tUnityGIInput data = s.GIData;\n"; - ShaderBody += "\t\t\tInput i = s.SurfInput;\n"; - ShaderBody += "\t\t\thalf4 c = 0;\n"; - if( m_currentDataCollector.UsingLightAttenuation ) - { - ShaderBody += "\t\t\t#ifdef UNITY_PASS_FORWARDBASE\n"; - ShaderBody += "\t\t\tfloat ase_lightAtten = data.atten;\n"; - ShaderBody += "\t\t\tif( _LightColor0.a == 0)\n"; - ShaderBody += "\t\t\tase_lightAtten = 0;\n"; - ShaderBody += "\t\t\t#else\n"; - ShaderBody += "\t\t\tfloat3 ase_lightAttenRGB = gi.light.color / ( ( _LightColor0.rgb ) + 0.000001 );\n"; - ShaderBody += "\t\t\tfloat ase_lightAtten = max( max( ase_lightAttenRGB.r, ase_lightAttenRGB.g ), ase_lightAttenRGB.b );\n"; - ShaderBody += "\t\t\t#endif\n"; - - ShaderBody += "\t\t\t#if defined(HANDLE_SHADOWS_BLENDING_IN_GI)\n"; - ShaderBody += "\t\t\thalf bakedAtten = UnitySampleBakedOcclusion(data.lightmapUV.xy, data.worldPos);\n"; - ShaderBody += "\t\t\tfloat zDist = dot(_WorldSpaceCameraPos - data.worldPos, UNITY_MATRIX_V[2].xyz);\n"; - ShaderBody += "\t\t\tfloat fadeDist = UnityComputeShadowFadeDistance(data.worldPos, zDist);\n"; - ShaderBody += "\t\t\tase_lightAtten = UnityMixRealtimeAndBakedShadows(data.atten, bakedAtten, UnityComputeShadowFade(fadeDist));\n"; - ShaderBody += "\t\t\t#endif\n"; - } - - //if( m_currentDataCollector.dirtyc ) - ShaderBody += customLightingInstructions; - ShaderBody += "\t\t\tc.rgb = " + ( !string.IsNullOrEmpty( customLightingCode ) ? customLightingCode : "0" ) + ";\n"; - ShaderBody += "\t\t\tc.a = " + ( !string.IsNullOrEmpty( customLightingAlphaCode ) ? customLightingAlphaCode : "1" ) + ";\n"; - if( m_alphaMode == AlphaMode.Premultiply || ( ( m_alphaMode == AlphaMode.Custom || m_alphaMode == AlphaMode.Opaque ) && m_blendOpsHelper.CurrentBlendRGB.IndexOf( "Premultiplied" ) > -1 ) ) - ShaderBody += "\t\t\tc.rgb *= c.a;\n"; - if( hasCustomLightingMask ) - ShaderBody += "\t\t\t" + customLightingMaskCode + ";\n"; - ShaderBody += "\t\t\treturn c;\n"; - ShaderBody += "\t\t}\n\n"; - - //Add GI function - ShaderBody += "\t\tinline void LightingStandard" + m_currentLightModel.ToString() + "_GI( inout " + outputStruct + " " + Constants.CustomLightOutputVarStr + ", UnityGIInput data, inout UnityGI gi )\n\t\t{\n"; - ShaderBody += "\t\t\ts.GIData = data;\n"; - //ShaderBody += "\t\t\tUNITY_GI(gi, " + Constants.CustomLightOutputVarStr + ", data);\n"; - ShaderBody += "\t\t}\n\n"; - } - - //Add custom lighting function - if( hasTranslucency || hasTransmission ) - { - ShaderBody += "\t\tinline half4 Lighting" + m_currentLightModel.ToString() + Constants.CustomLightStructStr + "(" + outputStruct + " " + Constants.CustomLightOutputVarStr + ", half3 viewDir, UnityGI gi )\n\t\t{\n"; - if( hasTranslucency ) - { - ShaderBody += "\t\t\t#if !DIRECTIONAL\n"; - ShaderBody += "\t\t\tfloat3 lightAtten = gi.light.color;\n"; - ShaderBody += "\t\t\t#else\n"; - ShaderBody += "\t\t\tfloat3 lightAtten = lerp( _LightColor0.rgb, gi.light.color, _TransShadow );\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t\thalf3 lightDir = gi.light.dir + " + Constants.CustomLightOutputVarStr + ".Normal * _TransNormalDistortion;\n"; - ShaderBody += "\t\t\thalf transVdotL = pow( saturate( dot( viewDir, -lightDir ) ), _TransScattering );\n"; - ShaderBody += "\t\t\thalf3 translucency = lightAtten * (transVdotL * _TransDirect + gi.indirect.diffuse * _TransAmbient) * " + Constants.CustomLightOutputVarStr + ".Translucency;\n"; - ShaderBody += "\t\t\thalf4 c = half4( " + Constants.CustomLightOutputVarStr + ".Albedo * translucency * _Translucency, 0 );\n\n"; - } - - if( hasTransmission ) - { - ShaderBody += "\t\t\thalf3 transmission = max(0 , -dot(" + Constants.CustomLightOutputVarStr + ".Normal, gi.light.dir)) * gi.light.color * " + Constants.CustomLightOutputVarStr + ".Transmission;\n"; - ShaderBody += "\t\t\thalf4 d = half4(" + Constants.CustomLightOutputVarStr + ".Albedo * transmission , 0);\n\n"; - } - - ShaderBody += "\t\t\tSurfaceOutput" + m_currentLightModel.ToString() + " r;\n"; - ShaderBody += "\t\t\tr.Albedo = " + Constants.CustomLightOutputVarStr + ".Albedo;\n"; - ShaderBody += "\t\t\tr.Normal = " + Constants.CustomLightOutputVarStr + ".Normal;\n"; - ShaderBody += "\t\t\tr.Emission = " + Constants.CustomLightOutputVarStr + ".Emission;\n"; - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - ShaderBody += "\t\t\tr.Metallic = " + Constants.CustomLightOutputVarStr + ".Metallic;\n"; - break; - case StandardShaderLightModel.StandardSpecular: - ShaderBody += "\t\t\tr.Specular = " + Constants.CustomLightOutputVarStr + ".Specular;\n"; - break; - } - ShaderBody += "\t\t\tr.Smoothness = " + Constants.CustomLightOutputVarStr + ".Smoothness;\n"; - ShaderBody += "\t\t\tr.Occlusion = " + Constants.CustomLightOutputVarStr + ".Occlusion;\n"; - ShaderBody += "\t\t\tr.Alpha = " + Constants.CustomLightOutputVarStr + ".Alpha;\n"; - ShaderBody += "\t\t\treturn Lighting" + m_currentLightModel.ToString() + " (r, viewDir, gi)" + ( hasTranslucency ? " + c" : "" ) + ( hasTransmission ? " + d" : "" ) + ";\n"; - ShaderBody += "\t\t}\n\n"; - - //Add GI function - ShaderBody += "\t\tinline void Lighting" + m_currentLightModel.ToString() + Constants.CustomLightStructStr + "_GI(" + outputStruct + " " + Constants.CustomLightOutputVarStr + ", UnityGIInput data, inout UnityGI gi )\n\t\t{\n"; - - ShaderBody += "\t\t\t#if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS\n"; - ShaderBody += "\t\t\t\tgi = UnityGlobalIllumination(data, " + Constants.CustomLightOutputVarStr + ".Occlusion, " + Constants.CustomLightOutputVarStr + ".Normal);\n"; - ShaderBody += "\t\t\t#else\n"; - ShaderBody += "\t\t\t\tUNITY_GLOSSY_ENV_FROM_SURFACE( g, " + Constants.CustomLightOutputVarStr + ", data );\n"; - ShaderBody += "\t\t\t\tgi = UnityGlobalIllumination( data, " + Constants.CustomLightOutputVarStr + ".Occlusion, " + Constants.CustomLightOutputVarStr + ".Normal, g );\n"; - ShaderBody += "\t\t\t#endif\n"; - - //ShaderBody += "\t\t\tUNITY_GI(gi, " + Constants.CustomLightOutputVarStr + ", data);\n"; - ShaderBody += "\t\t}\n\n"; - } - - if( hasRefraction ) - { - ShaderBody += "\t\tinline float4 Refraction( Input " + Constants.InputVarStr + ", " + outputStruct + " " + Constants.OutputVarStr + ", float indexOfRefraction, float chomaticAberration ) {\n"; - ShaderBody += "\t\t\tfloat3 worldNormal = " + Constants.OutputVarStr + ".Normal;\n"; - ShaderBody += "\t\t\tfloat4 screenPos = " + Constants.InputVarStr + ".screenPos;\n"; - ShaderBody += "\t\t\t#if UNITY_UV_STARTS_AT_TOP\n"; - ShaderBody += "\t\t\t\tfloat scale = -1.0;\n"; - ShaderBody += "\t\t\t#else\n"; - ShaderBody += "\t\t\t\tfloat scale = 1.0;\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t\tfloat halfPosW = screenPos.w * 0.5;\n"; - ShaderBody += "\t\t\tscreenPos.y = ( screenPos.y - halfPosW ) * _ProjectionParams.x * scale + halfPosW;\n"; - ShaderBody += "\t\t\t#if SHADER_API_D3D9 || SHADER_API_D3D11\n"; - ShaderBody += "\t\t\t\tscreenPos.w += 0.00000000001;\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t\tfloat2 projScreenPos = ( screenPos / screenPos.w ).xy;\n"; - ShaderBody += "\t\t\tfloat3 worldViewDir = normalize( UnityWorldSpaceViewDir( " + Constants.InputVarStr + ".worldPos ) );\n"; - ShaderBody += "\t\t\tfloat3 refractionOffset = ( indexOfRefraction - 1.0 ) * mul( UNITY_MATRIX_V, float4( worldNormal, 0.0 ) ) * ( 1.0 - dot( worldNormal, worldViewDir ) );\n"; - ShaderBody += "\t\t\tfloat2 cameraRefraction = float2( refractionOffset.x, refractionOffset.y );\n"; - - string grabpass = "_GrabTexture"; - if( m_grabOrder != 0 ) - grabpass = "RefractionGrab" + m_grabOrder; - ShaderBody += "\t\t\tfloat4 redAlpha = tex2D( " + grabpass + ", ( projScreenPos + cameraRefraction ) );\n"; - ShaderBody += "\t\t\tfloat green = tex2D( " + grabpass + ", ( projScreenPos + ( cameraRefraction * ( 1.0 - chomaticAberration ) ) ) ).g;\n"; - ShaderBody += "\t\t\tfloat blue = tex2D( " + grabpass + ", ( projScreenPos + ( cameraRefraction * ( 1.0 + chomaticAberration ) ) ) ).b;\n"; - ShaderBody += "\t\t\treturn float4( redAlpha.r, green, blue, redAlpha.a );\n"; - ShaderBody += "\t\t}\n\n"; - - ShaderBody += "\t\tvoid RefractionF( Input " + Constants.InputVarStr + ", " + outputStruct + " " + Constants.OutputVarStr + ", inout half4 color )\n"; - ShaderBody += "\t\t{\n"; - ShaderBody += "\t\t\t#ifdef UNITY_PASS_FORWARDBASE\n"; - ShaderBody += refractionInstructions; - if( m_inlineChromaticAberration.Active ) - { - ShaderBody += "\t\t\tcolor.rgb = color.rgb + Refraction( " + Constants.InputVarStr + ", " + Constants.OutputVarStr + ", " + refractionCode + ", " + m_inlineChromaticAberration.GetValueOrProperty(false) + " ) * ( 1 - color.a );\n"; - } - else - { - ShaderBody += "\t\t\tcolor.rgb = color.rgb + Refraction( " + Constants.InputVarStr + ", " + Constants.OutputVarStr + ", " + refractionCode + ", _ChromaticAberration ) * ( 1 - color.a );\n"; - } - ShaderBody += "\t\t\tcolor.a = 1;\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t}\n\n"; - } - - //Add Surface Shader body - ShaderBody += "\t\tvoid surf( Input " + Constants.InputVarStr + " , inout " + outputStruct + " " + Constants.OutputVarStr + " )\n\t\t{\n"; - { - // Pass input information to custom lighting function - if( m_currentLightModel == StandardShaderLightModel.CustomLighting ) - ShaderBody += "\t\t\t" + Constants.OutputVarStr + ".SurfInput = " + Constants.InputVarStr + ";\n"; - - //add local vars - if( m_currentDataCollector.DirtyLocalVariables ) - ShaderBody += m_currentDataCollector.LocalVariables; - - //add nodes ops - if( m_currentDataCollector.DirtyInstructions ) - ShaderBody += m_currentDataCollector.Instructions; - } - ShaderBody += "\t\t}\n"; - } - CloseCGProgram( ref ShaderBody ); - - - //Add custom Shadow Caster - if( m_customShadowCaster ) - { - OpenCGProgram( ref ShaderBody ); - string customLightSurface = hasTranslucency || hasTransmission ? "Custom" : ""; - m_renderingPlatformOpHelper.SetRenderingPlatforms( ref ShaderBody ); - - //Check if Custom Vertex is being used and add tag - if( m_currentDataCollector.DirtyPerVertexData ) - OptionalParameters += "vertex:" + Constants.VertexDataFunc + Constants.OptionalParametersSep; - - if( m_tessOpHelper.EnableTesselation && !usingDebugPort ) - { - m_tessOpHelper.WriteToOptionalParams( ref OptionalParameters ); - } - //if ( hasRefraction ) - // ShaderBody += "\t\t#pragma multi_compile _ALPHAPREMULTIPLY_ON\n"; - - m_additionalSurfaceOptions.WriteToOptionalSurfaceOptions( ref OptionalParameters ); - - AddShaderPragma( ref ShaderBody, "surface surf " + standardCustomLighting + m_currentLightModel.ToString() + customLightSurface + Constants.OptionalParametersSep + OptionalParameters ); - CloseCGProgram( ref ShaderBody ); - - ShaderBody += "\t\tPass\n"; - ShaderBody += "\t\t{\n"; - ShaderBody += "\t\t\tName \"ShadowCaster\"\n"; - ShaderBody += "\t\t\tTags{ \"LightMode\" = \"ShadowCaster\" }\n"; - ShaderBody += "\t\t\tZWrite On\n"; - if( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) - ShaderBody += "\t\t\tAlphaToMask Off\n"; - ShaderBody += "\t\t\tCGPROGRAM\n"; - ShaderBody += "\t\t\t#pragma vertex vert\n"; - ShaderBody += "\t\t\t#pragma fragment frag\n"; - ShaderBody += "\t\t\t#pragma target " + ShaderModelTypeArr[ m_shaderModelIdx ] + "\n"; - //ShaderBody += "\t\t\t#pragma multi_compile_instancing\n"; - ShaderBody += "\t\t\t#pragma multi_compile_shadowcaster\n"; - ShaderBody += "\t\t\t#pragma multi_compile UNITY_PASS_SHADOWCASTER\n"; - ShaderBody += "\t\t\t#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2\n"; - ShaderBody += "\t\t\t#include \"HLSLSupport.cginc\"\n"; -#if UNITY_2018_3_OR_NEWER - //Preventing WebGL to throw error Duplicate system value semantic definition: input semantic 'SV_POSITION' and input semantic 'VPOS' - ShaderBody += "\t\t\t#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )\n"; -#else - ShaderBody += "\t\t\t#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )\n"; -#endif - ShaderBody += "\t\t\t\t#define CAN_SKIP_VPOS\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t\t#include \"UnityCG.cginc\"\n"; - ShaderBody += "\t\t\t#include \"Lighting.cginc\"\n"; - ShaderBody += "\t\t\t#include \"UnityPBSLighting.cginc\"\n"; - - if( !( ( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) && hasOpacity && hasOpacityMask ) ) - if( hasOpacity ) - ShaderBody += "\t\t\tsampler3D _DitherMaskLOD;\n"; - - //ShaderBody += "\t\t\tsampler3D _DitherMaskLOD;\n"; - - ShaderBody += "\t\t\tstruct v2f\n"; - ShaderBody += "\t\t\t{\n"; - ShaderBody += "\t\t\t\tV2F_SHADOW_CASTER;\n"; - int texcoordIndex = 1; - for( int i = 0; i < m_currentDataCollector.PackSlotsList.Count; i++ ) - { - int size = 4 - m_currentDataCollector.PackSlotsList[ i ]; - if( size > 0 ) - { - ShaderBody += "\t\t\t\tfloat" + size + " customPack" + ( i + 1 ) + " : TEXCOORD" + ( i + 1 ) + ";\n"; - } - texcoordIndex++; - } - - if( !m_currentDataCollector.UsingInternalData ) - ShaderBody += "\t\t\t\tfloat3 worldPos : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - if( m_currentDataCollector.UsingScreenPos ) - ShaderBody += "\t\t\t\tfloat4 screenPos : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - if( /*m_currentDataCollector.UsingWorldNormal || m_currentDataCollector.UsingWorldPosition ||*/ m_currentDataCollector.UsingInternalData || m_currentDataCollector.DirtyNormal ) - { - ShaderBody += "\t\t\t\tfloat4 tSpace0 : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - ShaderBody += "\t\t\t\tfloat4 tSpace1 : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - ShaderBody += "\t\t\t\tfloat4 tSpace2 : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - } - else if( !m_currentDataCollector.UsingInternalData && m_currentDataCollector.UsingWorldNormal ) - { - ShaderBody += "\t\t\t\tfloat3 worldNormal : TEXCOORD" + ( texcoordIndex++ ) + ";\n"; - } - - if( m_currentDataCollector.UsingVertexColor ) - ShaderBody += "\t\t\t\thalf4 color : COLOR0;\n"; - ShaderBody += "\t\t\t\tUNITY_VERTEX_INPUT_INSTANCE_ID\n"; - ShaderBody += "\t\t\t\tUNITY_VERTEX_OUTPUT_STEREO\n"; - ShaderBody += "\t\t\t};\n"; - - ShaderBody += "\t\t\tv2f vert( " + m_currentDataCollector.CustomAppDataName + " v )\n"; - ShaderBody += "\t\t\t{\n"; - ShaderBody += "\t\t\t\tv2f o;\n"; - - ShaderBody += "\t\t\t\tUNITY_SETUP_INSTANCE_ID( v );\n"; - ShaderBody += "\t\t\t\tUNITY_INITIALIZE_OUTPUT( v2f, o );\n"; - ShaderBody += "\t\t\t\tUNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );\n"; - ShaderBody += "\t\t\t\tUNITY_TRANSFER_INSTANCE_ID( v, o );\n"; - - if( m_currentDataCollector.DirtyPerVertexData || m_currentDataCollector.CustomShadowCoordsList.Count > 0 ) - ShaderBody += "\t\t\t\tInput customInputData;\n"; - if( m_currentDataCollector.DirtyPerVertexData ) - { - ShaderBody += "\t\t\t\tvertexDataFunc( v" + ( m_currentDataCollector.TesselationActive ? "" : ", customInputData" ) + " );\n"; - } - - ShaderBody += "\t\t\t\tfloat3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;\n"; - ShaderBody += "\t\t\t\thalf3 worldNormal = UnityObjectToWorldNormal( v.normal );\n"; - if( m_currentDataCollector.UsingInternalData || m_currentDataCollector.DirtyNormal ) - { - ShaderBody += "\t\t\t\thalf3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );\n"; - ShaderBody += "\t\t\t\thalf tangentSign = v.tangent.w * unity_WorldTransformParams.w;\n"; - ShaderBody += "\t\t\t\thalf3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;\n"; - ShaderBody += "\t\t\t\to.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );\n"; - ShaderBody += "\t\t\t\to.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );\n"; - ShaderBody += "\t\t\t\to.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );\n"; - } - else if( !m_currentDataCollector.UsingInternalData && m_currentDataCollector.UsingWorldNormal ) - { - ShaderBody += "\t\t\t\to.worldNormal = worldNormal;\n"; - } - - for( int i = 0; i < m_currentDataCollector.CustomShadowCoordsList.Count; i++ ) - { - int size = UIUtils.GetChannelsAmount( m_currentDataCollector.CustomShadowCoordsList[ i ].DataType ); - string channels = string.Empty; - for( int j = 0; j < size; j++ ) - { - channels += Convert.ToChar( 120 + m_currentDataCollector.CustomShadowCoordsList[ i ].TextureIndex + j ); - } - channels = channels.Replace( '{', 'w' ); - ShaderBody += "\t\t\t\to.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + " = customInputData." + m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName + ";\n"; - - //TODO: TEMPORARY SOLUTION, this needs to go somewhere else, there's no need for these comparisons - if( m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName.StartsWith( "uv_" ) ) - { - ShaderBody += "\t\t\t\to.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + " = v.texcoord;\n"; - } - else if( m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName.StartsWith( "uv2_" ) ) - { - ShaderBody += "\t\t\t\to.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + " = v.texcoord1;\n"; - } - else if( m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName.StartsWith( "uv3_" ) ) - { - ShaderBody += "\t\t\t\to.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + " = v.texcoord2;\n"; - } - else if( m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName.StartsWith( "uv4_" ) ) - { - ShaderBody += "\t\t\t\to.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + " = v.texcoord3;\n"; - } - } - - if( !m_currentDataCollector.UsingInternalData ) - ShaderBody += "\t\t\t\to.worldPos = worldPos;\n"; - ShaderBody += "\t\t\t\tTRANSFER_SHADOW_CASTER_NORMALOFFSET( o )\n"; - if( m_currentDataCollector.UsingScreenPos ) - ShaderBody += "\t\t\t\to.screenPos = ComputeScreenPos( o.pos );\n"; - if( m_currentDataCollector.UsingVertexColor ) - ShaderBody += "\t\t\t\to.color = v.color;\n"; - ShaderBody += "\t\t\t\treturn o;\n"; - ShaderBody += "\t\t\t}\n"; - - ShaderBody += "\t\t\thalf4 frag( v2f IN\n"; - ShaderBody += "\t\t\t#if !defined( CAN_SKIP_VPOS )\n"; - ShaderBody += "\t\t\t, UNITY_VPOS_TYPE vpos : VPOS\n"; - ShaderBody += "\t\t\t#endif\n"; - ShaderBody += "\t\t\t) : SV_Target\n"; - ShaderBody += "\t\t\t{\n"; - ShaderBody += "\t\t\t\tUNITY_SETUP_INSTANCE_ID( IN );\n"; - ShaderBody += "\t\t\t\tInput surfIN;\n"; - ShaderBody += "\t\t\t\tUNITY_INITIALIZE_OUTPUT( Input, surfIN );\n"; - - for( int i = 0; i < m_currentDataCollector.CustomShadowCoordsList.Count; i++ ) - { - int size = UIUtils.GetChannelsAmount( m_currentDataCollector.CustomShadowCoordsList[ i ].DataType ); - string channels = string.Empty; - for( int j = 0; j < size; j++ ) - { - channels += Convert.ToChar( 120 + m_currentDataCollector.CustomShadowCoordsList[ i ].TextureIndex + j ); - } - channels = channels.Replace( '{', 'w' ); - ShaderBody += "\t\t\t\tsurfIN." + m_currentDataCollector.CustomShadowCoordsList[ i ].CoordName + " = IN.customPack" + ( m_currentDataCollector.CustomShadowCoordsList[ i ].TextureSlot + 1 ) + "." + channels + ";\n"; - } - - if( m_currentDataCollector.UsingInternalData ) - ShaderBody += "\t\t\t\tfloat3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );\n"; - else - ShaderBody += "\t\t\t\tfloat3 worldPos = IN.worldPos;\n"; - ShaderBody += "\t\t\t\thalf3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );\n"; - - if( m_currentDataCollector.UsingViewDirection && !m_currentDataCollector.DirtyNormal ) - ShaderBody += "\t\t\t\tsurfIN.viewDir = worldViewDir;\n"; - else if( m_currentDataCollector.UsingViewDirection ) - ShaderBody += "\t\t\t\tsurfIN.viewDir = IN.tSpace0.xyz * worldViewDir.x + IN.tSpace1.xyz * worldViewDir.y + IN.tSpace2.xyz * worldViewDir.z;\n"; - - if( m_currentDataCollector.UsingWorldPosition ) - ShaderBody += "\t\t\t\tsurfIN.worldPos = worldPos;\n"; - - if( m_currentDataCollector.UsingWorldNormal && m_currentDataCollector.UsingInternalData ) - ShaderBody += "\t\t\t\tsurfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );\n"; - else if( !m_currentDataCollector.UsingInternalData && m_currentDataCollector.UsingWorldNormal ) - ShaderBody += "\t\t\t\tsurfIN.worldNormal = IN.worldNormal;\n"; - - if( m_currentDataCollector.UsingWorldReflection ) - ShaderBody += "\t\t\t\tsurfIN.worldRefl = -worldViewDir;\n"; - - if( m_currentDataCollector.UsingInternalData ) - { - ShaderBody += "\t\t\t\tsurfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;\n"; - ShaderBody += "\t\t\t\tsurfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;\n"; - ShaderBody += "\t\t\t\tsurfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;\n"; - } - - if( m_currentDataCollector.UsingScreenPos ) - ShaderBody += "\t\t\t\tsurfIN.screenPos = IN.screenPos;\n"; - - if( m_currentDataCollector.UsingVertexColor ) - ShaderBody += "\t\t\t\tsurfIN.vertexColor = IN.color;\n"; - - ShaderBody += "\t\t\t\t" + outputStruct + " o;\n"; - ShaderBody += "\t\t\t\tUNITY_INITIALIZE_OUTPUT( " + outputStruct + ", o )\n"; - ShaderBody += "\t\t\t\tsurf( surfIN, o );\n"; - if( ( hasOpacity || hasOpacityMask ) && m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - ShaderBody += "\t\t\t\tUnityGI gi;\n"; - ShaderBody += "\t\t\t\tUNITY_INITIALIZE_OUTPUT( UnityGI, gi );\n"; - ShaderBody += "\t\t\t\to.Alpha = LightingStandardCustomLighting( o, worldViewDir, gi ).a;\n"; - } - ShaderBody += "\t\t\t\t#if defined( CAN_SKIP_VPOS )\n"; - ShaderBody += "\t\t\t\tfloat2 vpos = IN.pos;\n"; - ShaderBody += "\t\t\t\t#endif\n"; - - /*if( ( ( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) && hasOpacity && m_inputPorts[ m_discardPortId ].IsConnected ) ) - { - - } - else*/ if(!( ( m_alphaToCoverage || m_inlineAlphaToCoverage.Active ) && hasOpacity && m_inputPorts[ m_discardPortId ].IsConnected ) && hasOpacity ) - { - ShaderBody += "\t\t\t\thalf alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a;\n"; - ShaderBody += "\t\t\t\tclip( alphaRef - 0.01 );\n"; - } - - ShaderBody += "\t\t\t\tSHADOW_CASTER_FRAGMENT( IN )\n"; - ShaderBody += "\t\t\t}\n"; - - ShaderBody += "\t\t\tENDCG\n"; - - ShaderBody += "\t\t}\n"; - } - - } - - if( !string.IsNullOrEmpty( bellowUsePasses ) ) - { - ShaderBody += bellowUsePasses; - } - - CloseSubShaderBody( ref ShaderBody ); - - if( m_dependenciesHelper.HasDependencies ) - { - ShaderBody += m_dependenciesHelper.GenerateDependencies(); - } - - if( m_fallbackHelper.Active ) - { - ShaderBody += m_fallbackHelper.TabbedFallbackShader; - } - else if( m_castShadows || m_receiveShadows ) - { - AddShaderProperty( ref ShaderBody, "Fallback", "Diffuse" ); - } - - if( !string.IsNullOrEmpty( m_customInspectorName ) ) - { - AddShaderProperty( ref ShaderBody, "CustomEditor", m_customInspectorName ); - } - } - CloseShaderBody( ref ShaderBody ); - - if( usingDebugPort ) - { - m_currentLightModel = cachedLightModel; - ContainerGraph.CurrentCanvasMode = cachedAvailability; - } - - // Generate Graph info - ShaderBody += ContainerGraph.ParentWindow.GenerateGraphInfo(); - - //TODO: Remove current SaveDebugShader and uncomment SaveToDisk as soon as pathname is editable - if( !String.IsNullOrEmpty( pathname ) ) - { - IOUtils.StartSaveThread( ShaderBody, ( isFullPath ? pathname : ( IOUtils.dataPath + pathname ) ) ); - } - else - { - IOUtils.StartSaveThread( ShaderBody, Application.dataPath + "/AmplifyShaderEditor/Samples/Shaders/" + m_shaderName + ".shader" ); - } - - // Load new shader into material - - if( CurrentShader == null ) - { - AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate ); - CurrentShader = Shader.Find( ShaderName ); - } - //else - //{ - // // need to always get asset datapath because a user can change and asset location from the project window - // AssetDatabase.ImportAsset( AssetDatabase.GetAssetPath( m_currentShader ) ); - // //ShaderUtil.UpdateShaderAsset( m_currentShader, ShaderBody ); - //} - - if( m_currentShader != null ) - { - m_currentDataCollector.UpdateShaderImporter( ref m_currentShader ); - if( m_currentMaterial != null ) - { - if( m_currentShader != m_currentMaterial.shader ) - m_currentMaterial.shader = m_currentShader; -#if UNITY_5_6_OR_NEWER - if ( isInstancedShader ) - { - m_currentMaterial.enableInstancing = true; - } -#endif - m_currentDataCollector.UpdateMaterialOnPropertyNodes( m_currentMaterial ); - UpdateMaterialEditor(); - // need to always get asset datapath because a user can change and asset location from the project window - //AssetDatabase.ImportAsset( AssetDatabase.GetAssetPath( m_currentMaterial ) ); - } - } - - m_currentDataCollector.Destroy(); - m_currentDataCollector = null; - - return m_currentShader; - } - - public override void UpdateFromShader( Shader newShader ) - { - if( m_currentMaterial != null && m_currentMaterial.shader != newShader ) - { - m_currentMaterial.shader = newShader; - } - CurrentShader = newShader; - } - - public override void Destroy() - { - base.Destroy(); - - if( m_dummyProperty != null ) - { - m_dummyProperty.Destroy(); - GameObject.DestroyImmediate( m_dummyProperty ); - m_dummyProperty = null; - } - - m_drawInstancedHelper = null; - - m_translucencyPort = null; - m_transmissionPort = null; - m_refractionPort = null; - m_normalPort = null; - - m_renderingOptionsOpHelper.Destroy(); - m_renderingOptionsOpHelper = null; - - m_additionalIncludes.Destroy(); - m_additionalIncludes = null; - - m_additionalPragmas.Destroy(); - m_additionalPragmas = null; - - m_additionalDefines.Destroy(); - m_additionalDefines = null; - - m_additionalSurfaceOptions.Destroy(); - m_additionalSurfaceOptions = null; - - m_additionalDirectives.Destroy(); - m_additionalDirectives = null; - - m_customTagsHelper.Destroy(); - m_customTagsHelper = null; - - m_dependenciesHelper.Destroy(); - m_dependenciesHelper = null; - - m_renderingPlatformOpHelper = null; - m_inspectorDefaultStyle = null; - m_inspectorFoldoutStyle = null; - - m_zBufferHelper = null; - m_stencilBufferHelper = null; - m_blendOpsHelper = null; - m_tessOpHelper.Destroy(); - m_tessOpHelper = null; - m_outlineHelper.Destroy(); - m_outlineHelper = null; - m_colorMaskHelper.Destroy(); - m_colorMaskHelper = null; - m_billboardOpHelper = null; - - m_fallbackHelper.Destroy(); - GameObject.DestroyImmediate( m_fallbackHelper ); - m_fallbackHelper = null; - - m_usePass.Destroy(); - GameObject.DestroyImmediate( m_usePass ); - m_usePass = null; - } - - public override int VersionConvertInputPortId( int portId ) - { - int newPort = portId; - - //added translucency input after occlusion - if( UIUtils.CurrentShaderVersion() <= 2404 ) - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 6 ) - newPort += 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 5 ) - newPort += 1; - break; - } - } - - portId = newPort; - - //added transmission input after occlusion - if( UIUtils.CurrentShaderVersion() < 2407 ) - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 6 ) - newPort += 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 5 ) - newPort += 1; - break; - } - } - - portId = newPort; - - //added tessellation ports - if( UIUtils.CurrentShaderVersion() < 3002 ) - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 13 ) - newPort += 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 10 ) - newPort += 1; - break; - } - } - - portId = newPort; - - //added refraction after translucency - if( UIUtils.CurrentShaderVersion() < 3204 ) - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 8 ) - newPort += 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 7 ) - newPort += 1; - break; - } - } - - portId = newPort; - - //removed custom lighting port - //if ( UIUtils.CurrentShaderVersion() < 10003 ) //runs everytime because this system is only used after 5000 version - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 13 ) - newPort -= 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 12 ) - newPort -= 1; - break; - } - } - - portId = newPort; - - //if( UIUtils.CurrentShaderVersion() < 13802 ) //runs everytime because this system is only used after 5000 version - { - switch( m_currentLightModel ) - { - case StandardShaderLightModel.Standard: - case StandardShaderLightModel.StandardSpecular: - if( portId >= 11 ) - newPort += 1; - break; - case StandardShaderLightModel.CustomLighting: - case StandardShaderLightModel.Unlit: - case StandardShaderLightModel.Lambert: - case StandardShaderLightModel.BlinnPhong: - if( portId >= 10 ) - newPort += 1; - break; - } - } - - portId = newPort; - return newPort; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - try - { - base.ReadFromString( ref nodeParams ); - m_currentLightModel = (StandardShaderLightModel)Enum.Parse( typeof( StandardShaderLightModel ), GetCurrentParam( ref nodeParams ) ); - - if( CurrentMasterNodeCategory == AvailableShaderTypes.SurfaceShader && m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - ContainerGraph.CurrentCanvasMode = NodeAvailability.CustomLighting; - ContainerGraph.ParentWindow.CurrentNodeAvailability = NodeAvailability.CustomLighting; - } - else if( CurrentMasterNodeCategory == AvailableShaderTypes.SurfaceShader ) - { - ContainerGraph.CurrentCanvasMode = NodeAvailability.SurfaceShader; - ContainerGraph.ParentWindow.CurrentNodeAvailability = NodeAvailability.SurfaceShader; - } - //if ( _shaderCategory.Length > 0 ) - // _shaderCategory = UIUtils.RemoveInvalidCharacters( _shaderCategory ); - ShaderName = GetCurrentParam( ref nodeParams ); - if( m_shaderName.Length > 0 ) - ShaderName = UIUtils.RemoveShaderInvalidCharacters( ShaderName ); - - m_renderingOptionsOpHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - - m_cullMode = (CullMode)Enum.Parse( typeof( CullMode ), GetCurrentParam( ref nodeParams ) ); - m_zBufferHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - - string alphaMode = GetCurrentParam( ref nodeParams ); - - if( UIUtils.CurrentShaderVersion() < 4003 ) - { - if( alphaMode.Equals( "Fade" ) ) - { - alphaMode = "Transparent"; - } - else if( alphaMode.Equals( "Transparent" ) ) - { - alphaMode = "Premultiply"; - } - } - - m_alphaMode = (AlphaMode)Enum.Parse( typeof( AlphaMode ), alphaMode ); - m_opacityMaskClipValue = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_keepAlpha = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_keepAlpha = true; - m_castShadows = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_queueOrder = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 11 ) - { - m_customBlendMode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_renderType = (RenderType)Enum.Parse( typeof( RenderType ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14305 ) - { - m_customRenderType = GetCurrentParam( ref nodeParams ); - } - m_renderQueue = (RenderQueue)Enum.Parse( typeof( RenderQueue ), GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 2402 ) - { - m_renderPath = (RenderPath)Enum.Parse( typeof( RenderPath ), GetCurrentParam( ref nodeParams ) ); - } - if( UIUtils.CurrentShaderVersion() > 2405 ) - { - m_renderingPlatformOpHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 2500 ) - { - m_colorMaskHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 2501 ) - { - m_stencilBufferHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 2504 ) - { - m_tessOpHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 2505 ) - { - m_receiveShadows = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 3202 ) - { - m_blendOpsHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 3203 ) - { - m_grabOrder = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 5003 ) - { - m_outlineHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 5110 ) - { - m_billboardOpHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 6101 ) - { - m_vertexMode = (VertexMode)Enum.Parse( typeof( VertexMode ), GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 6102 ) - { - ShaderLOD = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_fallbackHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 7102 ) - { - m_maskClipOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_translucencyOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_refractionOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_tessellationOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 10010 && UIUtils.CurrentShaderVersion() < 15312 ) - { - m_additionalIncludes.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 11006 ) - { - m_customTagsHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 13102 && UIUtils.CurrentShaderVersion() < 15312 ) - { - m_additionalPragmas.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 13205 ) - { - m_alphaToCoverage = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 13903 ) - { - m_dependenciesHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 14005 && UIUtils.CurrentShaderVersion() < 15312 ) - { - m_additionalDefines.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 14501 ) - { - m_inlineCullMode.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 14502 ) - { - m_specColorOrderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15204 ) - { - m_inlineOpacityMaskClipValue.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 15311 ) - { - m_additionalDirectives.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - m_additionalSurfaceOptions.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - else - { - m_additionalDirectives.AddItems( AdditionalLineType.Define, m_additionalDefines.DefineList ); - m_additionalDirectives.AddItems( AdditionalLineType.Include, m_additionalIncludes.IncludeList ); - m_additionalDirectives.AddItems( AdditionalLineType.Pragma, m_additionalPragmas.PragmaList ); - } - - if( UIUtils.CurrentShaderVersion() > 15402 ) - { - m_usePass.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 16203 ) - { - m_drawInstancedHelper.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - } - - if( UIUtils.CurrentShaderVersion() > 16204 ) - m_inlineChromaticAberration.ReadFromString( ref m_currentReadParamIdx, ref nodeParams , false ); - - if( UIUtils.CurrentShaderVersion() > 16207 ) - m_inlineAlphaToCoverage.ReadFromString( ref m_currentReadParamIdx, ref nodeParams ); - - m_lightModelChanged = true; - m_lastLightModel = m_currentLightModel; - DeleteAllInputConnections( true ); - AddMasterPorts(); - UpdateFromBlendMode(); - m_customBlendMode = TestCustomBlendMode(); - - ContainerGraph.CurrentPrecision = m_currentPrecisionType; - } - catch( Exception e ) - { - Debug.Log( e ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - - // change port connection from emission to the new custom lighting port - if( m_currentLightModel == StandardShaderLightModel.CustomLighting && m_inputPorts[ m_emissionPortId ].IsConnected && UIUtils.CurrentShaderVersion() < 13802 ) - { - OutputPort port = m_inputPorts[ m_emissionPortId ].GetOutputConnection( 0 ); - m_inputPorts[ m_emissionPortId ].FullDeleteConnections(); - UIUtils.SetConnection( m_inputPorts[ m_customLightingPortId ].NodeId, m_inputPorts[ m_customLightingPortId ].PortId, port.NodeId, port.PortId ); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentLightModel ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_shaderName ); - m_renderingOptionsOpHelper.WriteToString( ref nodeInfo ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_cullMode ); - m_zBufferHelper.WriteToString( ref nodeInfo ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_alphaMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_opacityMaskClipValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_keepAlpha ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_castShadows ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_queueOrder ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_customBlendMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_renderType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_customRenderType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_renderQueue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_renderPath ); - m_renderingPlatformOpHelper.WriteToString( ref nodeInfo ); - m_colorMaskHelper.WriteToString( ref nodeInfo ); - m_stencilBufferHelper.WriteToString( ref nodeInfo ); - m_tessOpHelper.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_receiveShadows ); - m_blendOpsHelper.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_grabOrder ); - m_outlineHelper.WriteToString( ref nodeInfo ); - m_billboardOpHelper.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_vertexMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, ShaderLOD ); - m_fallbackHelper.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_maskClipReorder != null ) ? m_maskClipReorder.OrderIndex : -1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_translucencyReorder != null ) ? m_translucencyReorder.OrderIndex : -1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_refractionReorder != null ) ? m_refractionReorder.OrderIndex : -1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_tessellationReorder != null ) ? m_tessellationReorder.OrderIndex : -1 ); - //m_additionalIncludes.WriteToString( ref nodeInfo ); - m_customTagsHelper.WriteToString( ref nodeInfo ); - //m_additionalPragmas.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_alphaToCoverage ); - m_dependenciesHelper.WriteToString( ref nodeInfo ); - //m_additionalDefines.WriteToString( ref nodeInfo ); - m_inlineCullMode.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_specColorReorder != null ) ? m_specColorReorder.OrderIndex : -1 ); - m_inlineOpacityMaskClipValue.WriteToString( ref nodeInfo ); - m_additionalDirectives.WriteToString( ref nodeInfo ); - m_additionalSurfaceOptions.WriteToString( ref nodeInfo ); - m_usePass.WriteToString( ref nodeInfo ); - m_drawInstancedHelper.WriteToString( ref nodeInfo ); - m_inlineChromaticAberration.WriteToString( ref nodeInfo ); - m_inlineAlphaToCoverage.WriteToString( ref nodeInfo ); - } - - private bool TestCustomBlendMode() - { - switch( m_alphaMode ) - { - case AlphaMode.Opaque: - { - if( m_renderType == RenderType.Opaque && m_renderQueue == RenderQueue.Geometry ) - return false; - } - break; - case AlphaMode.Masked: - { - if( m_renderType == RenderType.TransparentCutout && m_renderQueue == RenderQueue.AlphaTest ) - return false; - } - break; - case AlphaMode.Transparent: - case AlphaMode.Premultiply: - { - if( m_renderType == RenderType.Transparent && m_renderQueue == RenderQueue.Transparent ) - return false; - } - break; - case AlphaMode.Translucent: - { - if( m_renderType == RenderType.Opaque && m_renderQueue == RenderQueue.Transparent ) - return false; - } - break; - } - return true; - } - - private void UpdateFromBlendMode() - { - m_checkChanges = true; - bool lockRefractionPort = false; - if( m_currentLightModel == StandardShaderLightModel.Unlit || m_currentLightModel == StandardShaderLightModel.CustomLighting ) - { - lockRefractionPort = true; - } - - switch( m_alphaMode ) - { - case AlphaMode.Opaque: - { - m_renderType = RenderType.Opaque; - m_renderQueue = RenderQueue.Geometry; - m_keepAlpha = true; - m_refractionPort.Locked = true; - m_inputPorts[ m_opacityPortId ].Locked = true; - m_inputPorts[ m_discardPortId ].Locked = true; - } - break; - case AlphaMode.Masked: - { - m_renderType = RenderType.TransparentCutout; - m_renderQueue = RenderQueue.AlphaTest; - m_keepAlpha = true; - m_refractionPort.Locked = true; - m_inputPorts[ m_opacityPortId ].Locked = true; - m_inputPorts[ m_discardPortId ].Locked = false; - } - break; - case AlphaMode.Transparent: - case AlphaMode.Premultiply: - { - m_renderType = RenderType.Transparent; - m_renderQueue = RenderQueue.Transparent; - m_refractionPort.Locked = false || lockRefractionPort; - m_inputPorts[ m_opacityPortId ].Locked = false; - m_inputPorts[ m_discardPortId ].Locked = true; - } - break; - case AlphaMode.Translucent: - { - m_renderType = RenderType.Opaque; - m_renderQueue = RenderQueue.Transparent; - m_refractionPort.Locked = false || lockRefractionPort; - m_inputPorts[ m_opacityPortId ].Locked = false; - m_inputPorts[ m_discardPortId ].Locked = true; - } - break; - case AlphaMode.Custom: - { - m_refractionPort.Locked = false || lockRefractionPort; - m_inputPorts[ m_opacityPortId ].Locked = false; - m_inputPorts[ m_discardPortId ].Locked = false; - } - break; - } - - m_blendOpsHelper.SetBlendOpsFromBlendMode( m_alphaMode, ( m_alphaMode == AlphaMode.Custom || m_alphaMode == AlphaMode.Opaque ) ); - } - - public bool CastShadows { get { return m_castShadows; } } - public StandardShaderLightModel CurrentLightingModel { get { return m_currentLightModel; } } - public CullMode CurrentCullMode { get { return m_cullMode; } } - //public AdditionalIncludesHelper AdditionalIncludes { get { return m_additionalIncludes; } set { m_additionalIncludes = value; } } - //public AdditionalPragmasHelper AdditionalPragmas { get { return m_additionalPragmas; } set { m_additionalPragmas = value; } } - //public AdditionalDefinesHelper AdditionalDefines { get { return m_additionalDefines; } set { m_additionalDefines = value; } } - public TemplateAdditionalDirectivesHelper AdditionalDirectives { get { return m_additionalDirectives; } } - public OutlineOpHelper OutlineHelper { get { return m_outlineHelper; } } - public float OpacityMaskClipValue { get { return m_opacityMaskClipValue; } } - public InlineProperty InlineOpacityMaskClipValue { get { return m_inlineOpacityMaskClipValue; } set { m_inlineOpacityMaskClipValue = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs.meta deleted file mode 100644 index 0515f8ca..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StandardSurface.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 59e61f9559385a94a87d4d37dbd556f0 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs deleted file mode 100644 index b613f0f1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs +++ /dev/null @@ -1,304 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - - [Serializable] - public class StencilBufferOpHelper - { - public static readonly string[] StencilComparisonValues = - { - "<Default>", - "Greater" , - "GEqual" , - "Less" , - "LEqual" , - "Equal" , - "NotEqual" , - "Always" , - "Never" - }; - - public static readonly Dictionary<string,int> StencilComparisonValuesDict = new Dictionary<string, int>() - { - {"Greater" , 1}, - {"GEqual" , 2}, - {"Less" , 3}, - {"LEqual" , 4}, - {"Equal" , 5}, - {"NotEqual", 6}, - {"Always" , 7}, - {"Never" , 8}, - }; - - public static readonly string[] StencilComparisonLabels = - { - "<Default>", - "Greater" , - "Greater or Equal" , - "Less" , - "Less or Equal" , - "Equal" , - "Not Equal" , - "Always" , - "Never" - }; - - - public static readonly string[] StencilOpsValues = - { - "<Default>", - "Keep", - "Zero", - "Replace", - "IncrSat", - "DecrSat", - "Invert", - "IncrWrap", - "DecrWrap" - }; - - public static readonly Dictionary<string,int> StencilOpsValuesDict = new Dictionary<string, int>() - { - {"Keep", 1}, - {"Zero", 2}, - {"Replace", 3}, - {"IncrSat", 4}, - {"DecrSat", 5}, - {"Invert", 6}, - {"IncrWrap",7}, - {"DecrWrap",8}, - }; - - public static readonly string[] StencilOpsLabels = - { - "<Default>", - "Keep", - "Zero", - "Replace", - "IncrSat", - "DecrSat", - "Invert", - "IncrWrap", - "DecrWrap" - }; - - - private const string FoldoutLabelStr = " Stencil Buffer"; - private GUIContent ReferenceValueContent = new GUIContent( "Reference", "The value to be compared against (if Comparison is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace)" ); - private GUIContent ReadMaskContent = new GUIContent( "Read Mask", "An 8 bit mask as an 0-255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask)" ); - private GUIContent WriteMaskContent = new GUIContent( "Write Mask", "An 8 bit mask as an 0-255 integer, used when writing to the buffer" ); - private const string ComparisonStr = "Comparison"; - private const string PassStr = "Pass"; - private const string FailStr = "Fail"; - private const string ZFailStr = "ZFail"; - - private const string ComparisonFrontStr = "Comp. Front"; - private const string PassFrontStr = "Pass Front"; - private const string FailFrontStr = "Fail Front"; - private const string ZFailFrontStr = "ZFail Front"; - - private const string ComparisonBackStr = "Comp. Back"; - private const string PassBackStr = "Pass Back"; - private const string FailBackStr = "Fail Back"; - private const string ZFailBackStr = "ZFail Back"; - - private const int ReadMaskDefaultValue = 255; - private const int WriteMaskDefaultValue = 255; - private const int ComparisonDefaultValue = 0; - private const int PassStencilOpDefaultValue = 0; - private const int FailStencilOpDefaultValue = 0; - private const int ZFailStencilOpDefaultValue = 0; - - [SerializeField] - private bool m_active; - - [SerializeField] - private InlineProperty m_refValue = new InlineProperty(); - [SerializeField] - private InlineProperty m_readMask = new InlineProperty( ReadMaskDefaultValue ); - [SerializeField] - private InlineProperty m_writeMask = new InlineProperty( WriteMaskDefaultValue ); - - //Comparison Function - [SerializeField] - private InlineProperty m_comparisonFunctionIdx = new InlineProperty( ComparisonDefaultValue ); - [SerializeField] - private InlineProperty m_comparisonFunctionBackIdx = new InlineProperty( ComparisonDefaultValue ); - - //Pass Stencil Op - [SerializeField] - private InlineProperty m_passStencilOpIdx = new InlineProperty( PassStencilOpDefaultValue ); - [SerializeField] - private InlineProperty m_passStencilOpBackIdx = new InlineProperty( PassStencilOpDefaultValue ); - - //Fail Stencil Op - [SerializeField] - private InlineProperty m_failStencilOpIdx = new InlineProperty( FailStencilOpDefaultValue ); - [SerializeField] - private InlineProperty m_failStencilOpBackIdx = new InlineProperty( FailStencilOpDefaultValue ); - - //ZFail Stencil Op - [SerializeField] - private InlineProperty m_zFailStencilOpIdx = new InlineProperty( ZFailStencilOpDefaultValue ); - [SerializeField] - private InlineProperty m_zFailStencilOpBackIdx = new InlineProperty( ZFailStencilOpDefaultValue ); - - public string CreateStencilOp( UndoParentNode owner ) - { - string result = "\t\tStencil\n\t\t{\n"; - result += string.Format( "\t\t\tRef {0}\n", m_refValue.GetValueOrProperty() ); - if( m_readMask.Active || m_readMask.IntValue != ReadMaskDefaultValue ) - { - result += string.Format( "\t\t\tReadMask {0}\n", m_readMask.GetValueOrProperty() ); - } - - if( m_writeMask.Active || m_writeMask.IntValue != WriteMaskDefaultValue ) - { - result += string.Format( "\t\t\tWriteMask {0}\n", m_writeMask.GetValueOrProperty() ); - } - - if( ( owner as StandardSurfaceOutputNode ).CurrentCullMode == CullMode.Off ) - { - if( m_comparisonFunctionIdx.IntValue != ComparisonDefaultValue || m_comparisonFunctionIdx.Active ) - result += string.Format( "\t\t\tCompFront {0}\n", m_comparisonFunctionIdx.GetValueOrProperty( StencilComparisonValues[ m_comparisonFunctionIdx.IntValue ] ) ); - if( m_passStencilOpIdx.IntValue != PassStencilOpDefaultValue || m_passStencilOpIdx.Active ) - result += string.Format( "\t\t\tPassFront {0}\n", m_passStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_passStencilOpIdx.IntValue ] ) ); - if( m_failStencilOpIdx.IntValue != FailStencilOpDefaultValue || m_failStencilOpIdx.Active ) - result += string.Format( "\t\t\tFailFront {0}\n", m_failStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_failStencilOpIdx.IntValue ] ) ); - if( m_zFailStencilOpIdx.IntValue != ZFailStencilOpDefaultValue || m_zFailStencilOpIdx.Active ) - result += string.Format( "\t\t\tZFailFront {0}\n", m_zFailStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_zFailStencilOpIdx.IntValue ] ) ); - - if( m_comparisonFunctionBackIdx.IntValue != ComparisonDefaultValue || m_comparisonFunctionBackIdx.Active ) - result += string.Format( "\t\t\tCompBack {0}\n", m_comparisonFunctionBackIdx.GetValueOrProperty( StencilComparisonValues[ m_comparisonFunctionBackIdx.IntValue ] ) ); - if( m_passStencilOpBackIdx.IntValue != PassStencilOpDefaultValue || m_passStencilOpBackIdx.Active ) - result += string.Format( "\t\t\tPassBack {0}\n", m_passStencilOpBackIdx.GetValueOrProperty( StencilOpsValues[ m_passStencilOpBackIdx.IntValue ] ) ); - if( m_failStencilOpBackIdx.IntValue != FailStencilOpDefaultValue || m_failStencilOpBackIdx.Active ) - result += string.Format( "\t\t\tFailBack {0}\n", m_failStencilOpBackIdx.GetValueOrProperty( StencilOpsValues[ m_failStencilOpBackIdx.IntValue ] ) ); - if( m_zFailStencilOpBackIdx.IntValue != ZFailStencilOpDefaultValue || m_zFailStencilOpBackIdx.Active ) - result += string.Format( "\t\t\tZFailBack {0}\n", m_zFailStencilOpBackIdx.GetValueOrProperty( StencilOpsValues[ m_zFailStencilOpBackIdx.IntValue ] ) ); - } - else - { - if( m_comparisonFunctionIdx.IntValue != ComparisonDefaultValue || m_comparisonFunctionIdx.Active ) - result += string.Format( "\t\t\tComp {0}\n", m_comparisonFunctionIdx.GetValueOrProperty( StencilComparisonValues[ m_comparisonFunctionIdx.IntValue ] ) ); - if( m_passStencilOpIdx.IntValue != PassStencilOpDefaultValue || m_passStencilOpIdx.Active ) - result += string.Format( "\t\t\tPass {0}\n", m_passStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_passStencilOpIdx.IntValue ] ) ); - if( m_failStencilOpIdx.IntValue != FailStencilOpDefaultValue || m_failStencilOpIdx.Active ) - result += string.Format( "\t\t\tFail {0}\n", m_failStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_failStencilOpIdx.IntValue ] ) ); - if( m_zFailStencilOpIdx.IntValue != ZFailStencilOpDefaultValue || m_zFailStencilOpIdx.Active ) - result += string.Format( "\t\t\tZFail {0}\n", m_zFailStencilOpIdx.GetValueOrProperty( StencilOpsValues[ m_zFailStencilOpIdx.IntValue ] ) ); - } - - - result += "\t\t}\n"; - return result; - } - - public void Draw( UndoParentNode owner ) - { - bool foldoutValue = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions; - NodeUtils.DrawPropertyGroup( owner, ref foldoutValue, ref m_active, FoldoutLabelStr, () => - { - float cache = EditorGUIUtility.labelWidth; - float cache2 = EditorGUIUtility.fieldWidth; - EditorGUIUtility.labelWidth = 110; - EditorGUIUtility.fieldWidth = 30; - m_refValue.IntSlider( ref owner, ReferenceValueContent, 0, 255 ); - m_readMask.IntSlider( ref owner, ReadMaskContent, 0, 255 ); - m_writeMask.IntSlider( ref owner, WriteMaskContent, 0, 255 ); - //EditorGUIUtility.labelWidth = cache; - EditorGUIUtility.fieldWidth = cache2; - if( ( owner as StandardSurfaceOutputNode ).CurrentCullMode == CullMode.Off ) - { - m_comparisonFunctionIdx.EnumTypePopup( ref owner, ComparisonFrontStr, StencilComparisonLabels ); - m_passStencilOpIdx.EnumTypePopup( ref owner, PassFrontStr, StencilOpsLabels ); - m_failStencilOpIdx.EnumTypePopup( ref owner, FailFrontStr, StencilOpsLabels ); - m_zFailStencilOpIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilOpsLabels ); - EditorGUILayout.Separator(); - m_comparisonFunctionBackIdx.EnumTypePopup( ref owner, ComparisonBackStr, StencilComparisonLabels ); - m_passStencilOpBackIdx.EnumTypePopup( ref owner, PassBackStr, StencilOpsLabels ); - m_failStencilOpBackIdx.EnumTypePopup( ref owner, FailBackStr, StencilOpsLabels ); - m_zFailStencilOpBackIdx.EnumTypePopup( ref owner, ZFailBackStr, StencilOpsLabels ); - } - else - { - m_comparisonFunctionIdx.EnumTypePopup( ref owner, ComparisonStr, StencilComparisonLabels ); - m_passStencilOpIdx.EnumTypePopup( ref owner, PassFrontStr, StencilOpsLabels ); - m_failStencilOpIdx.EnumTypePopup( ref owner, FailFrontStr, StencilOpsLabels ); - m_zFailStencilOpIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilOpsLabels ); - } - EditorGUIUtility.labelWidth = cache; - } ); - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions = foldoutValue; - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_active = Convert.ToBoolean( nodeParams[ index++ ] ); - if( UIUtils.CurrentShaderVersion() > 14501 ) - { - m_refValue.ReadFromString( ref index, ref nodeParams ); - m_readMask.ReadFromString( ref index, ref nodeParams ); - m_writeMask.ReadFromString( ref index, ref nodeParams ); - m_comparisonFunctionIdx.ReadFromString( ref index, ref nodeParams ); - m_passStencilOpIdx.ReadFromString( ref index, ref nodeParams ); - m_failStencilOpIdx.ReadFromString( ref index, ref nodeParams ); - m_zFailStencilOpIdx.ReadFromString( ref index, ref nodeParams ); - } - else - { - m_refValue.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_readMask.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_writeMask.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_comparisonFunctionIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_passStencilOpIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_failStencilOpIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_zFailStencilOpIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 13203 ) - { - if( UIUtils.CurrentShaderVersion() > 14501 ) - { - m_comparisonFunctionBackIdx.ReadFromString( ref index, ref nodeParams ); - m_passStencilOpBackIdx.ReadFromString( ref index, ref nodeParams ); - m_failStencilOpBackIdx.ReadFromString( ref index, ref nodeParams ); - m_zFailStencilOpBackIdx.ReadFromString( ref index, ref nodeParams ); - } - else - { - m_comparisonFunctionBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_passStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_failStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_zFailStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - } - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_active ); - m_refValue.WriteToString( ref nodeInfo ); - m_readMask.WriteToString( ref nodeInfo ); - m_writeMask.WriteToString( ref nodeInfo ); - m_comparisonFunctionIdx.WriteToString( ref nodeInfo ); - m_passStencilOpIdx.WriteToString( ref nodeInfo ); - m_failStencilOpIdx.WriteToString( ref nodeInfo ); - m_zFailStencilOpIdx.WriteToString( ref nodeInfo ); - m_comparisonFunctionBackIdx.WriteToString( ref nodeInfo ); - m_passStencilOpBackIdx.WriteToString( ref nodeInfo ); - m_failStencilOpBackIdx.WriteToString( ref nodeInfo ); - m_zFailStencilOpBackIdx.WriteToString( ref nodeInfo ); - } - - public bool Active - { - get { return m_active; } - set { m_active = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs.meta deleted file mode 100644 index 6dc55180..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/StencilBufferOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0111d524dc809f14aa95e4e1ab93d37b -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs deleted file mode 100644 index 751317d1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs +++ /dev/null @@ -1,374 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; - -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class TerrainDrawInstancedHelper - { -#if UNITY_2018_1_OR_NEWER - private readonly string[] InstancedPragmas = - { - "multi_compile_instancing", - "instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd" - }; - - private readonly string[] InstancedGlobalsSRP = - { - "#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing", - "\tTEXTURE2D(_TerrainHeightmapTexture);//ASE Terrain Instancing", - "\tTEXTURE2D( _TerrainNormalmapTexture);//ASE Terrain Instancing", - "#endif//ASE Terrain Instancing", - "UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing", - "\tUNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing", - "UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing", - "CBUFFER_START( UnityTerrain)//ASE Terrain Instancing", - "\t#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing", - "\t\tfloat4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing", - "\t\tfloat4 _TerrainHeightmapScale;//ASE Terrain Instancing", - "\t#endif//ASE Terrain Instancing", - "CBUFFER_END//ASE Terrain Instancing" - }; - - private readonly string[] InstancedGlobalsDefault = - { - "#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing", - "\tsampler2D _TerrainHeightmapTexture;//ASE Terrain Instancing", - "\tsampler2D _TerrainNormalmapTexture;//ASE Terrain Instancing", - "#endif//ASE Terrain Instancing", - "UNITY_INSTANCING_BUFFER_START( Terrain )//ASE Terrain Instancing", - "\tUNITY_DEFINE_INSTANCED_PROP( float4, _TerrainPatchInstanceData )//ASE Terrain Instancing", - "UNITY_INSTANCING_BUFFER_END( Terrain)//ASE Terrain Instancing", - "CBUFFER_START( UnityTerrain)//ASE Terrain Instancing", - "\t#ifdef UNITY_INSTANCING_ENABLED//ASE Terrain Instancing", - "\t\tfloat4 _TerrainHeightmapRecipSize;//ASE Terrain Instancing", - "\t\tfloat4 _TerrainHeightmapScale;//ASE Terrain Instancing", - "\t#endif//ASE Terrain Instancing", - "CBUFFER_END//ASE Terrain Instancing" - }; - - - private readonly string ApplyMeshModificationInstruction = "{0} = ApplyMeshModification({0});"; - - private readonly string[] ApplyMeshModificationFunctionSRP = - { - /*0 - struct name 1 - var name*/"{0} ApplyMeshModification( {0} {1} )\n", - "{\n", - "#ifdef UNITY_INSTANCING_ENABLED\n", - /* 0 vertex position*/"\tfloat2 patchVertex = {0}.xy;\n", - "\tfloat4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );\n", - "\tfloat2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;\n", - "\tfloat height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );\n", - /*0 - vertex position*/"\t{0}.xz = sampleCoords* _TerrainHeightmapScale.xz;\n", - /*0 - vertex position*/"\t{0}.y = height* _TerrainHeightmapScale.y;\n", - "\t#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL\n", - /* 0 - vertex normal*/"\t\t{0} = float3(0, 1, 0);\n", - "\t#else\n", - /* 0 - vertex normal*/"\t\t{0} = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;\n", - "\t#endif\n", - "#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL\n", - /* 0 - tex coord*/"\t{0}.xy = sampleCoords;\n", - "#else\n", - /* 0 - tex coord*/"\t{0}.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;\n", - "#endif\n", - "#endif\n", - /* 0 - var name*/"\treturn {0};\n", - "}\n" - }; - //{ - // /*0 - struct name 1 - var name*/"{0} ApplyMeshModification( {0} {1} )\n", - // "{\n", - // "#ifdef UNITY_INSTANCING_ENABLED\n", - // /* 0 vertex position*/"\tfloat2 patchVertex = {0}.xy;\n", - // "\t\tfloat4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );\n", - // "\t\tfloat2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;\n", - // "\t\tfloat height = UnpackHeightmap( _TerrainHeightmapTexture.Load( int3( sampleCoords, 0 ) ) );\n", - // /*0 - vertex position*/"\t\t{0}.xz = sampleCoords* _TerrainHeightmapScale.xz;\n", - // /*0 - vertex position*/"\t\t{0}.y = height* _TerrainHeightmapScale.y;\n", - // "# ifdef ATTRIBUTES_NEED_NORMAL\n", - // /* 0 - vertex normal*/"\t\t{0} = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb* 2 - 1;\n", - // "\t#endif\n", - // "\t#if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)\n", - // "\t\t#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL\n", - // /* 0 - tex coord*/"\t\t\t{0} = sampleCoords;\n", - // "\t\t#else\n", - // /* 0 - tex coord*/"\t\t\t{0}.xy = sampleCoords* _TerrainHeightmapRecipSize.zw;\n", - // "\t\t#endif\n", - // "\t#endif\n", - // "#endif\n", - // "#ifdef ATTRIBUTES_NEED_TANGENT\n", - // /* 0 - tangent 1 - normal*/"\t\t{0}.xyz = cross( {1}, float3(0, 0, 1));\n", - // /*0 - tangent*/"\t{0}.w = -1;\n", - // "#endif\n", - // /* 0 - var name*/"\treturn {0};\n", - // "}\n" - //}; - - - - private readonly string[] ApplyMeshModificationFunctionDefaultTemplate = - { - /* 0 vertex struct */"{0} ApplyMeshModification( {0} {1} )", - "{\n", - "#ifdef UNITY_INSTANCING_ENABLED\n", - /*0 - vertex pos*/"\tfloat2 patchVertex = {0}.xy;\n", - "\tfloat4 instanceData = UNITY_ACCESS_INSTANCED_PROP( Terrain, _TerrainPatchInstanceData );\n", - "\tfloat2 sampleCoords = ( patchVertex.xy + instanceData.xy ) * instanceData.z;\n", - /* 0 - tex coords*/"\t{0} = float4( sampleCoords.xy * _TerrainHeightmapRecipSize.z, 0, 0 );\n", - /* 0 - tex coords*/"\tfloat height = UnpackHeightmap( tex2Dlod( _TerrainHeightmapTexture, {0} ) );\n", - /* 0 - vertex pos*/"\t{0}.xz = sampleCoords * _TerrainHeightmapScale.xz;\n", - /* 0 - vertex pos*/"\t{0}.y = height * _TerrainHeightmapScale.y;\n", - /* 0 - normal 1 - tex coord*/"\t{0} = tex2Dlod( _TerrainNormalmapTexture, {1} ).rgb * 2 - 1;\n", - "#endif\n", - /* var name*/"return {0};\n", - "}\n" - }; - - private readonly string ApplyMeshModificationInstructionStandard = "ApplyMeshModification({0});"; - private readonly string[] ApplyMeshModificationFunctionStandard = - { - "void ApplyMeshModification( inout {0} v )", - "#if defined(UNITY_INSTANCING_ENABLED) && !defined(SHADER_API_D3D11_9X)", - "\tfloat2 patchVertex = v.vertex.xy;", - "\tfloat4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);", - "\t", - "\tfloat4 uvscale = instanceData.z * _TerrainHeightmapRecipSize;", - "\tfloat4 uvoffset = instanceData.xyxy * uvscale;", - "\tuvoffset.xy += 0.5f * _TerrainHeightmapRecipSize.xy;", - "\tfloat2 sampleCoords = (patchVertex.xy * uvscale.xy + uvoffset.xy);", - "\t", - "\tfloat hm = UnpackHeightmap(tex2Dlod(_TerrainHeightmapTexture, float4(sampleCoords, 0, 0)));", - "\tv.vertex.xz = (patchVertex.xy + instanceData.xy) * _TerrainHeightmapScale.xz * instanceData.z;", - "\tv.vertex.y = hm * _TerrainHeightmapScale.y;", - "\tv.vertex.w = 1.0f;", - "\t", - "\tv.texcoord.xy = (patchVertex.xy * uvscale.zw + uvoffset.zw);", - "\tv.texcoord3 = v.texcoord2 = v.texcoord1 = v.texcoord;", - "\t", - "\t#ifdef TERRAIN_INSTANCED_PERPIXEL_NORMAL", - "\t\tv.normal = float3(0, 1, 0);", - "\t\t//data.tc.zw = sampleCoords;", - "\t#else", - "\t\tfloat3 nor = tex2Dlod(_TerrainNormalmapTexture, float4(sampleCoords, 0, 0)).xyz;", - "\t\tv.normal = 2.0f * nor - 1.0f;", - "\t#endif", - "#endif", - }; - private readonly string[] AdditionalUsePasses = - { - "Hidden/Nature/Terrain/Utilities/PICKING", - "Hidden/Nature/Terrain/Utilities/SELECTION" - }; - private readonly string DrawInstancedLabel = "Instanced Terrain"; -#endif - [SerializeField] - private bool m_enable = false; - - public void Draw( UndoParentNode owner ) - { -#if UNITY_2018_1_OR_NEWER - m_enable = owner.EditorGUILayoutToggle( DrawInstancedLabel, m_enable ); -#endif - } - - public void UpdateDataCollectorForTemplates( ref MasterNodeDataCollector dataCollector, ref List<string> vertexInstructions ) - { -#if UNITY_2018_1_OR_NEWER - if( m_enable ) - { - for( int i = 0; i < AdditionalUsePasses.Length; i++ ) - { - dataCollector.AddUsePass( AdditionalUsePasses[ i ], false ); - } - - for( int i = 0; i < InstancedPragmas.Length; i++ ) - { - dataCollector.AddToPragmas( -1, InstancedPragmas[ i ] ); - } - - if( dataCollector.IsSRP ) - { - - TemplateFunctionData functionData = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData; - string uvCoord = dataCollector.TemplateDataCollectorInstance.GetUV( 0, MasterNodePortCategory.Vertex ); - string vertexNormal = dataCollector.TemplateDataCollectorInstance.GetVertexNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - //string vertexTangent = dataCollector.TemplateDataCollectorInstance.GetVertexTangent( WirePortDataType.FLOAT4, PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - string vertexPos = dataCollector.TemplateDataCollectorInstance.GetVertexPosition( WirePortDataType.OBJECT, PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - - string functionHeader = string.Format( ApplyMeshModificationFunctionSRP[ 0 ], functionData.InVarType, functionData.InVarName ); - - //string functionBody = functionHeader + - // ApplyMeshModificationFunctionSRP[ 1 ] + - // ApplyMeshModificationFunctionSRP[ 2 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 3 ], vertexPos ) + - // ApplyMeshModificationFunctionSRP[ 4 ] + - // ApplyMeshModificationFunctionSRP[ 5 ] + - // ApplyMeshModificationFunctionSRP[ 6 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 7 ], vertexPos ) + - // string.Format( ApplyMeshModificationFunctionSRP[ 8 ], vertexPos ) + - // ApplyMeshModificationFunctionSRP[ 9 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 10 ], vertexNormal ) + - // ApplyMeshModificationFunctionSRP[ 11 ] + - // ApplyMeshModificationFunctionSRP[ 12 ] + - // ApplyMeshModificationFunctionSRP[ 13 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 14 ], uvCoord ) + - // ApplyMeshModificationFunctionSRP[ 15 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 16 ], uvCoord ) + - // ApplyMeshModificationFunctionSRP[ 17 ] + - // ApplyMeshModificationFunctionSRP[ 18 ] + - // ApplyMeshModificationFunctionSRP[ 19 ] + - // ApplyMeshModificationFunctionSRP[ 20 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 21 ], vertexTangent, vertexNormal ) + - // string.Format( ApplyMeshModificationFunctionSRP[ 22 ], vertexTangent ) + - // ApplyMeshModificationFunctionSRP[ 23 ] + - // string.Format( ApplyMeshModificationFunctionSRP[ 24 ], functionData.InVarName ) + - // ApplyMeshModificationFunctionSRP[ 25 ]; - string functionBody = functionHeader + - ApplyMeshModificationFunctionSRP[ 1 ] + - ApplyMeshModificationFunctionSRP[ 2 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 3 ], vertexPos ) + - ApplyMeshModificationFunctionSRP[ 4 ] + - ApplyMeshModificationFunctionSRP[ 5 ] + - ApplyMeshModificationFunctionSRP[ 6 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 7 ], vertexPos ) + - string.Format( ApplyMeshModificationFunctionSRP[ 8 ], vertexPos ) + - ApplyMeshModificationFunctionSRP[ 9 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 10 ], vertexNormal ) + - ApplyMeshModificationFunctionSRP[ 11 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 12 ], vertexNormal ) + - ApplyMeshModificationFunctionSRP[ 13 ] + - ApplyMeshModificationFunctionSRP[ 14 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 15 ], uvCoord ) + - ApplyMeshModificationFunctionSRP[ 16 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 17 ], uvCoord ) + - ApplyMeshModificationFunctionSRP[ 18 ] + - ApplyMeshModificationFunctionSRP[ 19 ] + - string.Format( ApplyMeshModificationFunctionSRP[ 20 ], functionData.InVarName ) + - ApplyMeshModificationFunctionSRP[ 21 ]; - dataCollector.AddFunction( functionHeader, functionBody ); - - for( int i = 0; i < InstancedGlobalsSRP.Length; i++ ) - { - dataCollector.AddToUniforms( -1, InstancedGlobalsSRP[ i ] ); - } - - - string vertexVarName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.InVarName; - vertexInstructions.Insert( 0, string.Format( ApplyMeshModificationInstruction, vertexVarName ) ); - } - else - { - TemplateFunctionData functionData = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData; - - string uvCoord = dataCollector.TemplateDataCollectorInstance.GetUV( 0, MasterNodePortCategory.Vertex ); - string vertexNormal = dataCollector.TemplateDataCollectorInstance.GetVertexNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - string vertexPos = dataCollector.TemplateDataCollectorInstance.GetVertexPosition( WirePortDataType.OBJECT, PrecisionType.Float, false, MasterNodePortCategory.Vertex ); - - string functionHeader = string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 0 ], functionData.InVarType, functionData.InVarName ); - string functionBody = functionHeader + - ApplyMeshModificationFunctionDefaultTemplate[ 1 ] + - ApplyMeshModificationFunctionDefaultTemplate[ 2 ] + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 3 ], vertexPos ) + - ApplyMeshModificationFunctionDefaultTemplate[ 4 ] + - ApplyMeshModificationFunctionDefaultTemplate[ 5 ] + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 6 ], uvCoord ) + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 7 ], uvCoord ) + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 8 ], vertexPos ) + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 9 ], vertexPos ) + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 10 ], vertexNormal, uvCoord ) + - ApplyMeshModificationFunctionDefaultTemplate[ 11 ] + - string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 12 ], functionData.InVarName ) + - ApplyMeshModificationFunctionDefaultTemplate[ 13 ]; - - - dataCollector.AddFunction( functionHeader, functionBody ); - for( int i = 0; i < InstancedGlobalsDefault.Length; i++ ) - { - dataCollector.AddToUniforms( -1, InstancedGlobalsDefault[ i ] ); - } - - - string vertexVarName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.InVarName; - vertexInstructions.Insert( 0, string.Format( ApplyMeshModificationInstruction, vertexVarName ) ); - - } - } -#endif - } - - public void UpdateDataCollectorForStandard( ref MasterNodeDataCollector dataCollector ) - { -#if UNITY_2018_1_OR_NEWER - if( m_enable ) - { - for( int i = 0; i < AdditionalUsePasses.Length; i++ ) - { - dataCollector.AddUsePass( AdditionalUsePasses[ i ], false ); - } - - for( int i = 0; i < InstancedPragmas.Length; i++ ) - { - dataCollector.AddToPragmas( -1, InstancedPragmas[ i ] ); - } - string functionBody = string.Empty; - - string functionHeader = string.Format( ApplyMeshModificationFunctionStandard[ 0 ], dataCollector.SurfaceVertexStructure ); - IOUtils.AddFunctionHeader( ref functionBody, functionHeader ); - for( int i = 1; i < ApplyMeshModificationFunctionStandard.Length; i++ ) - { - IOUtils.AddFunctionLine( ref functionBody, ApplyMeshModificationFunctionStandard[ i ] ); - } - IOUtils.CloseFunctionBody( ref functionBody ); - - //string inputName = "input"; - //string uvCoord = "input.texcoord"; - //string vertexNormal = "input.normal"; - //string vertexPos = "input.vertex"; - - //string functionHeader = string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 0 ], dataCollector.SurfaceVertexStructure, inputName ); - //IOUtils.AddFunctionHeader( ref functionBody, functionHeader ); - //IOUtils.AddFunctionLine( ref functionBody, ApplyMeshModificationFunctionDefaultTemplate[ 1 ] ); - //IOUtils.AddFunctionLine( ref functionBody,ApplyMeshModificationFunctionDefaultTemplate[ 2 ] ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 3 ], vertexPos ) ); - //IOUtils.AddFunctionLine( ref functionBody,ApplyMeshModificationFunctionDefaultTemplate[ 4 ] ); - //IOUtils.AddFunctionLine( ref functionBody,ApplyMeshModificationFunctionDefaultTemplate[ 5 ] ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 6 ], uvCoord ) ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 7 ], uvCoord ) ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 8 ], vertexPos ) ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 9 ], vertexPos ) ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 10 ], vertexNormal, uvCoord ) ); - //IOUtils.AddFunctionLine( ref functionBody,ApplyMeshModificationFunctionDefaultTemplate[ 11 ] ); - //IOUtils.AddFunctionLine( ref functionBody,string.Format( ApplyMeshModificationFunctionDefaultTemplate[ 12 ], inputName ) ); - //IOUtils.AddFunctionLine( ref functionBody, ApplyMeshModificationFunctionDefaultTemplate[ 13 ] ); - //IOUtils.CloseFunctionBody( ref functionBody ); - - dataCollector.AddFunction( functionHeader, functionBody ); - for( int i = 0; i < InstancedGlobalsDefault.Length; i++ ) - { - dataCollector.AddToUniforms( -1, InstancedGlobalsDefault[ i ] ); - } - - dataCollector.AddVertexInstruction( string.Format( ApplyMeshModificationInstructionStandard, "v" ) ); - } -#endif - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_enable = Convert.ToBoolean( nodeParams[ index++ ] ); - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_enable ); - } - - public bool Enabled { get { return m_enable; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs.meta deleted file mode 100644 index 9580ad09..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TerrainDrawInstancedHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 935c69709205e1c4dbd54da410518cc6 -timeCreated: 1548263010 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs deleted file mode 100644 index 38d38f09..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs +++ /dev/null @@ -1,642 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - public sealed class TessellationOpHelper - { - public const string TessellationPortStr = "Tessellation"; - - - public const string TessSurfParam = "tessellate:tessFunction"; - public const string TessInclude = "Tessellation.cginc"; - //public const string CustomAppData = "\t\tstruct appdata\n" + - // "\t\t{\n" + - // "\t\t\tfloat4 vertex : POSITION;\n" + - // "\t\t\tfloat4 tangent : TANGENT;\n" + - // "\t\t\tfloat3 normal : NORMAL;\n" + - // "\t\t\tfloat4 texcoord : TEXCOORD0;\n" + - // "\t\t\tfloat4 texcoord1 : TEXCOORD1;\n" + - // "\t\t\tfloat4 texcoord2 : TEXCOORD2;\n" + - // "\t\t\tfloat4 texcoord3 : TEXCOORD3;\n" + - // "\t\t\tfixed4 color : COLOR;\n" + - // "\t\t\tUNITY_VERTEX_INPUT_INSTANCE_ID\n" + - // "\t\t};\n\n"; - - - - private const string TessUniformName = "_TessValue"; - private const string TessMinUniformName = "_TessMin"; - private const string TessMaxUniformName = "_TessMax"; - - //private GUIContent EnableTessContent = new GUIContent( "Tessellation", "Activates the use of tessellation which subdivides polygons to increase geometry detail using a set of rules\nDefault: OFF" ); - private GUIContent TessFactorContent = new GUIContent( "Tess", "Tessellation factor\nDefault: 4" ); - private GUIContent TessMinDistanceContent = new GUIContent( "Min", "Minimum tessellation distance\nDefault: 10" ); - private GUIContent TessMaxDistanceContent = new GUIContent( "Max", "Maximum tessellation distance\nDefault: 25" ); - - - private readonly int[] TesselationTypeValues = { 0, 1, 2, 3 }; - private readonly string[] TesselationTypeLabels = { "Distance-based", "Fixed", "Edge Length", "Edge Length Cull" }; - private readonly string TesselationTypeStr = "Type"; - - private const string TessProperty = "_TessValue( \"Max Tessellation\", Range( 1, 32 ) ) = {0}"; - private const string TessMinProperty = "_TessMin( \"Tess Min Distance\", Float ) = {0}"; - private const string TessMaxProperty = "_TessMax( \"Tess Max Distance\", Float ) = {0}"; - - private const string TessFunctionOpen = "\t\tfloat4 tessFunction( appdata_full v0, appdata_full v1, appdata_full v2 )\n\t\t{\n"; - private const string TessFunctionClose = "\t\t}\n"; - - // Custom function - private const string CustomFunctionBody = "\t\t\treturn {0};\n"; - - // Distance based function - private const string DistBasedTessFunctionBody = "\t\t\treturn UnityDistanceBasedTess( v0.vertex, v1.vertex, v2.vertex, _TessMin, _TessMax, _TessValue );\n"; - - // Fixed amount function - private const string FixedAmountTessFunctionOpen = "\t\tfloat4 tessFunction( )\n\t\t{\n"; - private const string FixedAmountTessFunctionBody = "\t\t\treturn _TessValue;\n"; - - // Edge Length - private GUIContent EdgeLengthContent = new GUIContent( "Edge Length", "Tessellation levels ccomputed based on triangle edge length on the screen\nDefault: 4" ); - private const string EdgeLengthTessProperty = "_EdgeLength ( \"Edge length\", Range( 2, 50 ) ) = {0}"; - private const string EdgeLengthTessUniformName = "_EdgeLength"; - - private const string EdgeLengthTessFunctionBody = "\t\t\treturn UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength);\n"; - private const string EdgeLengthTessCullFunctionBody = "\t\t\treturn UnityEdgeLengthBasedTessCull (v0.vertex, v1.vertex, v2.vertex, _EdgeLength , _TessMaxDisp );\n"; - - - private const string EdgeLengthTessMaxDispProperty = "_TessMaxDisp( \"Max Displacement\", Float ) = {0}"; - private const string EdgeLengthTessMaxDispUniformName = "_TessMaxDisp"; - private GUIContent EdgeLengthTessMaxDisplacementContent = new GUIContent( "Max Disp.", "Max Displacement" ); - - // Phong - private GUIContent PhongEnableContent = new GUIContent( "Phong", "Modifies positions of the subdivided faces so that the resulting surface follows the mesh normals a bit\nDefault: OFF" ); - private GUIContent PhongStrengthContent = new GUIContent( "Strength", "Strength\nDefault: 0.5" ); - public const string PhongStrengthParam = "tessphong:_TessPhongStrength"; - - private const string PhongStrengthProperty = "_TessPhongStrength( \"Phong Tess Strength\", Range( 0, 1 ) ) = {0}"; - private const string PhongStrengthUniformName = "_TessPhongStrength"; - - [SerializeField] - private bool m_enabled = false; - - //private bool m_expanded = false; - - [SerializeField] - private int m_tessType = 2; - - [SerializeField] - private float m_tessMinDistance = 10f; - - [SerializeField] - private float m_tessMaxDistance = 25f; - - [SerializeField] - private float m_tessFactor = 15f; - - [SerializeField] - private float m_phongStrength = 0.5f; - - [SerializeField] - private bool m_phongEnabled = false; - - [SerializeField] - private string[] m_customData = { string.Empty, string.Empty, string.Empty }; - - [SerializeField] - private bool m_hasCustomFunction = false; - - [SerializeField] - private string m_customFunction = String.Empty; - - [SerializeField] - private string m_additionalData = string.Empty; - - [SerializeField] - private StandardSurfaceOutputNode m_parentSurface; - - private Dictionary<string, bool> m_additionalDataDict = new Dictionary<string, bool>(); - - private int m_masterNodeIndexPort = 0; - private int m_vertexOffsetIndexPort = 0; - //private int m_orderIndex = 1000; - - public void Draw( UndoParentNode owner, GUIStyle toolbarstyle, Material mat, bool connectedInput ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( toolbarstyle ); - GUI.color = cachedColor; - EditorGUI.BeginChangeCheck(); - m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedTesselation = GUILayout.Toggle( m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedTesselation, " Tessellation", UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth( true ) ); - if ( EditorGUI.EndChangeCheck() ) - { - EditorPrefs.SetBool( "ExpandedTesselation", m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedTesselation ); - } - - EditorGUI.BeginChangeCheck(); - m_enabled = owner.EditorGUILayoutToggle( string.Empty, m_enabled, UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ); - if ( EditorGUI.EndChangeCheck() ) - { - if ( m_enabled ) - UpdateToMaterial( mat, !connectedInput ); - - UIUtils.RequestSave(); - } - - EditorGUILayout.EndHorizontal(); - - m_enabled = m_enabled || connectedInput; - - if ( m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedTesselation ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - - EditorGUILayout.Separator(); - EditorGUI.BeginDisabledGroup( !m_enabled ); - - EditorGUI.indentLevel += 1; - - m_phongEnabled = owner.EditorGUILayoutToggle( PhongEnableContent, m_phongEnabled ); - if ( m_phongEnabled ) - { - EditorGUI.indentLevel += 1; - EditorGUI.BeginChangeCheck(); - m_phongStrength = owner.EditorGUILayoutSlider( PhongStrengthContent, m_phongStrength, 0.0f, 1.0f ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( PhongStrengthUniformName ) ) - mat.SetFloat( PhongStrengthUniformName, m_phongStrength ); - } - - EditorGUI.indentLevel -= 1; - } - - bool guiEnabled = GUI.enabled; - GUI.enabled = !connectedInput && m_enabled; - - m_tessType = owner.EditorGUILayoutIntPopup( TesselationTypeStr, m_tessType, TesselationTypeLabels, TesselationTypeValues ); - - switch ( m_tessType ) - { - case 0: - { - EditorGUI.BeginChangeCheck(); - m_tessFactor = owner.EditorGUILayoutSlider( TessFactorContent, m_tessFactor, 1, 32 ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( TessUniformName ) ) - mat.SetFloat( TessUniformName, m_tessFactor ); - } - - EditorGUI.BeginChangeCheck(); - m_tessMinDistance = owner.EditorGUILayoutFloatField( TessMinDistanceContent, m_tessMinDistance ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( TessMinUniformName ) ) - mat.SetFloat( TessMinUniformName, m_tessMinDistance ); - } - - EditorGUI.BeginChangeCheck(); - m_tessMaxDistance = owner.EditorGUILayoutFloatField( TessMaxDistanceContent, m_tessMaxDistance ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( TessMaxUniformName ) ) - mat.SetFloat( TessMaxUniformName, m_tessMaxDistance ); - } - } - break; - case 1: - { - EditorGUI.BeginChangeCheck(); - m_tessFactor = owner.EditorGUILayoutSlider( TessFactorContent, m_tessFactor, 1, 32 ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( TessUniformName ) ) - mat.SetFloat( TessUniformName, m_tessFactor ); - } - } - break; - case 2: - { - EditorGUI.BeginChangeCheck(); - m_tessFactor = owner.EditorGUILayoutSlider( EdgeLengthContent, m_tessFactor, 2, 50 ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - mat.SetFloat( EdgeLengthTessUniformName, m_tessFactor ); - } - } - break; - case 3: - { - EditorGUI.BeginChangeCheck(); - m_tessFactor = owner.EditorGUILayoutSlider( EdgeLengthContent, m_tessFactor, 2, 50 ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - mat.SetFloat( EdgeLengthTessUniformName, m_tessFactor ); - } - - EditorGUI.BeginChangeCheck(); - m_tessMaxDistance = owner.EditorGUILayoutFloatField( EdgeLengthTessMaxDisplacementContent, m_tessMaxDistance ); - if ( EditorGUI.EndChangeCheck() && mat != null ) - { - if ( mat.HasProperty( TessMinUniformName ) ) - mat.SetFloat( TessMinUniformName, m_tessMaxDistance ); - } - } - break; - } - GUI.enabled = guiEnabled; - EditorGUI.indentLevel -= 1; - EditorGUI.EndDisabledGroup(); - EditorGUILayout.Separator(); - EditorGUILayout.EndVertical(); - } - } - - public void UpdateToMaterial( Material mat, bool updateInternals ) - { - if ( mat == null ) - return; - - if ( m_phongEnabled ) - { - if ( mat.HasProperty( PhongStrengthUniformName ) ) - mat.SetFloat( PhongStrengthUniformName, m_phongStrength ); - } - - if ( updateInternals ) - { - switch ( m_tessType ) - { - case 0: - { - if ( mat.HasProperty( TessUniformName ) ) - mat.SetFloat( TessUniformName, m_tessFactor ); - - if ( mat.HasProperty( TessMinUniformName ) ) - mat.SetFloat( TessMinUniformName, m_tessMinDistance ); - - if ( mat.HasProperty( TessMaxUniformName ) ) - mat.SetFloat( TessMaxUniformName, m_tessMaxDistance ); - } - break; - case 1: - { - if ( mat.HasProperty( TessUniformName ) ) - mat.SetFloat( TessUniformName, m_tessFactor ); - } - break; - case 2: - { - - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - mat.SetFloat( EdgeLengthTessUniformName, m_tessFactor ); - } - break; - case 3: - { - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - mat.SetFloat( EdgeLengthTessUniformName, m_tessFactor ); - - if ( mat.HasProperty( TessMinUniformName ) ) - mat.SetFloat( TessMinUniformName, m_tessMaxDistance ); - } - break; - } - } - } - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - m_enabled = Convert.ToBoolean( nodeParams[ index++ ] ); - m_tessType = Convert.ToInt32( nodeParams[ index++ ] ); - m_tessFactor = Convert.ToSingle( nodeParams[ index++ ] ); - m_tessMinDistance = Convert.ToSingle( nodeParams[ index++ ] ); - m_tessMaxDistance = Convert.ToSingle( nodeParams[ index++ ] ); - if ( UIUtils.CurrentShaderVersion() > 3001 ) - { - m_phongEnabled = Convert.ToBoolean( nodeParams[ index++ ] ); - m_phongStrength = Convert.ToSingle( nodeParams[ index++ ] ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_enabled ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tessType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tessFactor ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tessMinDistance ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_tessMaxDistance ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_phongEnabled ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_phongStrength ); - } - - public string Uniforms() - { - string uniforms = string.Empty; - switch( m_tessType ) - { - case 0: - { - if( !m_hasCustomFunction ) - { - - //Tess - uniforms += "\t\tuniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessUniformName + ";\n"; - - //Min - uniforms += "\t\tuniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessMinUniformName + ";\n"; - - //Max - uniforms += "\t\tuniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessMaxUniformName + ";\n"; - } - } - break; - case 1: - //Tess - if( !m_hasCustomFunction ) - { - uniforms += "\t\tuniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessUniformName + ";\n"; - } - break; - } - - if( m_phongEnabled ) - { - uniforms += "\t\tuniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + PhongStrengthUniformName + ";\n" ; - } - - return uniforms; - } - - public void AddToDataCollector( ref MasterNodeDataCollector dataCollector, int reorder ) - { - int orderIndex = reorder; - switch ( m_tessType ) - { - case 0: - { - dataCollector.AddToIncludes( -1, TessellationOpHelper.TessInclude ); - if ( !m_hasCustomFunction ) - { - //Tess - dataCollector.AddToProperties( -1, string.Format( TessProperty, m_tessFactor ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessUniformName + ";" ); - - //Min - dataCollector.AddToProperties( -1, string.Format( TessMinProperty, m_tessMinDistance ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessMinUniformName + ";" ); - - //Max - dataCollector.AddToProperties( -1, string.Format( TessMaxProperty, m_tessMaxDistance ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessMaxUniformName + ";" ); - } - } - break; - case 1: - { - //Tess - if ( !m_hasCustomFunction ) - { - dataCollector.AddToProperties( -1, string.Format( TessProperty, m_tessFactor ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + TessUniformName + ";" ); - } - } - break; - case 2: - { - dataCollector.AddToIncludes( -1, TessellationOpHelper.TessInclude ); - - //Tess - if ( !m_hasCustomFunction ) - { - dataCollector.AddToProperties( -1, string.Format( EdgeLengthTessProperty, m_tessFactor ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + EdgeLengthTessUniformName + ";" ); - } - } - break; - case 3: - { - dataCollector.AddToIncludes( -1, TessellationOpHelper.TessInclude ); - - if ( !m_hasCustomFunction ) - { - //Tess - dataCollector.AddToProperties( -1, string.Format( EdgeLengthTessProperty, m_tessFactor ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + EdgeLengthTessUniformName + ";" ); - - //Max Displacement - dataCollector.AddToProperties( -1, string.Format( EdgeLengthTessMaxDispProperty, m_tessMaxDistance ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + EdgeLengthTessMaxDispUniformName + ";" ); - } - } - break; - } - - if ( m_phongEnabled ) - { - dataCollector.AddToProperties( -1, string.Format( PhongStrengthProperty, m_phongStrength ), orderIndex++ ); - dataCollector.AddToUniforms( -1, "uniform " + UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT ) + " " + PhongStrengthUniformName + ";" ); - } - } - - //ToDo: Optimize material property fetches to use Id instead of string - public void UpdateFromMaterial( Material mat ) - { - if ( m_enabled ) - { - if ( m_phongEnabled ) - { - if ( mat.HasProperty( PhongStrengthUniformName ) ) - m_phongStrength = mat.GetFloat( PhongStrengthUniformName ); - } - - switch ( m_tessType ) - { - case 0: - { - if ( mat.HasProperty( TessUniformName ) ) - m_tessFactor = mat.GetFloat( TessUniformName ); - - if ( mat.HasProperty( TessMinUniformName ) ) - m_tessMinDistance = mat.GetFloat( TessMinUniformName ); - - if ( mat.HasProperty( TessMaxUniformName ) ) - m_tessMaxDistance = mat.GetFloat( TessMaxUniformName ); - } - break; - case 1: - { - if ( mat.HasProperty( TessUniformName ) ) - m_tessFactor = mat.GetFloat( TessUniformName ); - } - break; - case 2: - { - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - m_tessFactor = mat.GetFloat( EdgeLengthTessUniformName ); - } - break; - case 3: - { - if ( mat.HasProperty( EdgeLengthTessUniformName ) ) - m_tessFactor = mat.GetFloat( EdgeLengthTessUniformName ); - - if ( mat.HasProperty( EdgeLengthTessMaxDispUniformName ) ) - m_tessMaxDistance = mat.GetFloat( EdgeLengthTessMaxDispUniformName ); - } - break; - } - } - } - - public void WriteToOptionalParams( ref string optionalParams ) - { - optionalParams += TessellationOpHelper.TessSurfParam + Constants.OptionalParametersSep; - if ( m_phongEnabled ) - { - optionalParams += TessellationOpHelper.PhongStrengthParam + Constants.OptionalParametersSep; - } - } - - public void Reset() - { - m_hasCustomFunction = false; - m_customFunction = string.Empty; - - m_additionalData = string.Empty; - m_additionalDataDict.Clear(); - switch ( m_tessType ) - { - case 0: - { - m_customData[ 0 ] = TessUniformName; - m_customData[ 1 ] = TessMinUniformName; - m_customData[ 2 ] = TessMaxUniformName; - } - break; - case 1: - { - m_customData[ 0 ] = TessUniformName; - m_customData[ 1 ] = string.Empty; - m_customData[ 2 ] = string.Empty; - } - break; - case 2: - { - m_customData[ 0 ] = EdgeLengthTessUniformName; - m_customData[ 1 ] = string.Empty; - m_customData[ 2 ] = string.Empty; - } - break; - case 3: - { - m_customData[ 0 ] = EdgeLengthTessUniformName; - m_customData[ 1 ] = EdgeLengthTessMaxDispUniformName; - m_customData[ 2 ] = string.Empty; - } - break; - } - } - - public string GetCurrentTessellationFunction - { - get - { - if ( m_hasCustomFunction ) - { - return TessFunctionOpen + - m_customFunction + - TessFunctionClose; - } - - string tessFunction = string.Empty; - switch ( m_tessType ) - { - case 0: - { - tessFunction = TessFunctionOpen + - DistBasedTessFunctionBody + - TessFunctionClose; - } - break; - case 1: - { - tessFunction = FixedAmountTessFunctionOpen + - FixedAmountTessFunctionBody + - TessFunctionClose; - } - break; - case 2: - { - tessFunction = TessFunctionOpen + - EdgeLengthTessFunctionBody + - TessFunctionClose; - } - break; - case 3: - { - tessFunction = TessFunctionOpen + - EdgeLengthTessCullFunctionBody + - TessFunctionClose; - } - break; - } - return tessFunction; - } - } - - public void AddAdditionalData( string data ) - { - if ( !m_additionalDataDict.ContainsKey( data ) ) - { - m_additionalDataDict.Add( data, true ); - m_additionalData += data; - } - } - - public void AddCustomFunction( string returnData ) - { - m_hasCustomFunction = true; - m_customFunction = m_additionalData + string.Format( CustomFunctionBody, returnData ); - } - - public void Destroy() - { - m_additionalDataDict.Clear(); - m_additionalDataDict = null; - } - - public bool IsTessellationPort( int index ) - { - return index == m_masterNodeIndexPort; - } - - public bool EnableTesselation { get { return m_enabled; } } - - public int TessType { get { return m_tessType; } } - public int MasterNodeIndexPort - { - get { return m_masterNodeIndexPort; } - set { m_masterNodeIndexPort = value; } - } - public int VertexOffsetIndexPort - { - get { return m_vertexOffsetIndexPort; } - set { m_vertexOffsetIndexPort = value; } - } - - public StandardSurfaceOutputNode ParentSurface { get { return m_parentSurface; } set { m_parentSurface = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs.meta deleted file mode 100644 index c4400a8a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/TessellationOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c6fbad94b0fc6b948be3a3dc61232c05 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs deleted file mode 100644 index d6e34adf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs +++ /dev/null @@ -1,360 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; - -namespace AmplifyShaderEditor -{ - public enum UsePassLocation - { - Above, - Below - } - - [Serializable] - public class UsePassItem : ScriptableObject - { - public UsePassLocation Location; - public string Value; - public UsePassItem() - { - Location = UsePassLocation.Above; - Value = string.Empty; - } - - public UsePassItem( UsePassLocation location, string name ) - { - Location = location; - Value = name; - } - - } - - [Serializable] - public class UsePassHelper : ScriptableObject - { - private const string UseGrabFormatNewLine = "UsePass \"{0}\"\n"; - private const string UseGrabFormat = "UsePass \"{0}\""; - private const float ShaderKeywordButtonLayoutWidth = 15; - private const string ShaderPoputContext = "CONTEXT/ShaderPopup"; - - [SerializeField] - private List<UsePassItem> m_items = new List<UsePassItem>(); - - [SerializeField] - private UndoParentNode m_owner = null; - - [SerializeField] - protected bool m_isDirty = false; - - [SerializeField] - protected string m_moduleName = string.Empty; - - private ReorderableList m_reordableList = null; - private ReordableAction m_actionType = ReordableAction.None; - private int m_actionIndex = 0; - private GUIStyle m_propertyAdjustment; - - private Material m_dummyMaterial; - private MenuCommand m_dummyCommand; - private int m_currentUsePassIdx = 0; - - public void Init( string moduleName ) - { - hideFlags = HideFlags.HideAndDontSave; - m_moduleName = moduleName; - } - - void DrawButtons() - { - EditorGUILayout.Separator(); - - // Add keyword - if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - UsePassItem newItem = ScriptableObject.CreateInstance<UsePassItem>(); - newItem.hideFlags = HideFlags.HideAndDontSave; - m_items.Add( newItem ); - EditorGUI.FocusTextInControl( null ); - m_isDirty = true; - } - - //Remove keyword - if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ShaderKeywordButtonLayoutWidth ) ) ) - { - if( m_items.Count > 0 ) - { - UsePassItem itemToDelete = m_items[ m_items.Count - 1 ]; - m_items.RemoveAt( m_items.Count - 1 ); - ScriptableObject.DestroyImmediate( itemToDelete ); - EditorGUI.FocusTextInControl( null ); - } - m_isDirty = true; - } - } - - public void Draw( UndoParentNode owner, bool style = true ) - { - if( m_owner == null ) - m_owner = owner; - - if( m_reordableList == null ) - { - m_reordableList = new ReorderableList( m_items, typeof( UsePassItem ), true, false, false, false ) - { - headerHeight = 0, - footerHeight = 0, - showDefaultBackground = false, - drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) => - { - if( m_items[ index ] != null ) - { - float labelWidthMultiplier; - float popUpWidth; - float shaderSelectorMultiplier; - float buttonPlusPosMultiplier; - if( style ) - { - rect.x -= 10; - labelWidthMultiplier = 0.9f; - popUpWidth = 0.31f; - shaderSelectorMultiplier = 1.01f; - buttonPlusPosMultiplier = 0.78f; - } - else - { - rect.x -= 1; - labelWidthMultiplier = 1.01f; - popUpWidth = 0.25f; - shaderSelectorMultiplier = 1.0f; - buttonPlusPosMultiplier = 0.55f; - } - - Rect popupPos = new Rect( rect.x, rect.y + 2, popUpWidth * rect.width, rect.height ); - Rect labelPos = new Rect( rect.x + popupPos.width * labelWidthMultiplier, rect.y, 0.59f * rect.width, rect.height ); - - Rect shaderSelectorPos = new Rect( labelPos.x + labelPos.width* shaderSelectorMultiplier, rect.y, 15, rect.height ); - - Rect buttonPlusPos = new Rect( shaderSelectorPos.x + shaderSelectorPos.width * buttonPlusPosMultiplier, rect.y, ShaderKeywordButtonLayoutWidth, rect.height ); - Rect buttonMinusPos = new Rect( buttonPlusPos.x + buttonPlusPos.width, rect.y, ShaderKeywordButtonLayoutWidth, rect.height ); - - EditorGUI.BeginChangeCheck(); - m_items[ index ].Location = (UsePassLocation)owner.EditorGUIEnumPopup( popupPos, m_items[ index ].Location ); - - if( EditorGUI.EndChangeCheck() && m_items[ index ].Location == UsePassLocation.Below && m_owner != null && m_owner.ContainerGraph.CurrentCanvasMode == NodeAvailability.TemplateShader ) - { - m_items[ index ].Location = UsePassLocation.Above; - UIUtils.ShowMessage( "Below option still not available on templates" ); - } - m_items[ index ].Value = owner.EditorGUITextField( labelPos, string.Empty, m_items[ index ].Value ); - - if( GUI.Button( shaderSelectorPos, string.Empty, UIUtils.InspectorPopdropdownFallback ) ) - { - EditorGUI.FocusTextInControl( null ); - GUI.FocusControl( null ); - m_currentUsePassIdx = index; - DisplayShaderContext( owner, GUILayoutUtility.GetRect( GUIContent.none, EditorStyles.popup ) ); - } - - if( GUI.Button( buttonPlusPos, string.Empty, UIUtils.PlusStyle ) ) - { - m_actionType = ReordableAction.Add; - m_actionIndex = index; - } - - if( GUI.Button( buttonMinusPos, string.Empty, UIUtils.MinusStyle ) ) - { - m_actionType = ReordableAction.Remove; - m_actionIndex = index; - } - } - } - }; - } - - if( m_actionType != ReordableAction.None ) - { - switch( m_actionType ) - { - case ReordableAction.Add: - UsePassItem newItem = ScriptableObject.CreateInstance<UsePassItem>(); - newItem.hideFlags = HideFlags.HideAndDontSave; - m_items.Insert( m_actionIndex + 1, newItem ); - break; - case ReordableAction.Remove: - UsePassItem itemToDelete = m_items[ m_actionIndex ]; - m_items.RemoveAt( m_actionIndex ); - ScriptableObject.DestroyImmediate( itemToDelete ); - break; - } - m_isDirty = true; - m_actionType = ReordableAction.None; - EditorGUI.FocusTextInControl( null ); - } - bool foldoutValue = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedUsePass; - if( style ) - { - NodeUtils.DrawPropertyGroup( ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons ); - } - else - { - NodeUtils.DrawNestedPropertyGroup( ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons ); - } - owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedUsePass = foldoutValue; - } - - private void DisplayShaderContext( UndoParentNode node, Rect r ) - { - if( m_dummyCommand == null ) - m_dummyCommand = new MenuCommand( this, 0 ); - - if( m_dummyMaterial == null ) - m_dummyMaterial = new Material( Shader.Find( "Hidden/ASESShaderSelectorUnlit" ) ); - -#pragma warning disable 0618 - UnityEditorInternal.InternalEditorUtility.SetupShaderMenu( m_dummyMaterial ); -#pragma warning restore 0618 - EditorUtility.DisplayPopupMenu( r, ShaderPoputContext, m_dummyCommand ); - } - - private void OnSelectedShaderPopup( string command, Shader shader ) - { - if( shader != null ) - { - UIUtils.MarkUndoAction(); - Undo.RecordObject( m_owner, "Selected Use Pass shader" ); - m_items[ m_currentUsePassIdx ].Value = shader.name; - } - } - - void DrawReordableList() - { - if( m_reordableList != null ) - { - if( m_propertyAdjustment == null ) - { - m_propertyAdjustment = new GUIStyle(); - m_propertyAdjustment.padding.left = 17; - } - EditorGUILayout.Space(); - - if( m_items.Count == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - else - { - m_reordableList.DoLayoutList(); - } - EditorGUILayout.Space(); - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - try - { - int count = Convert.ToInt32( nodeParams[ index++ ] ); - for( int i = 0; i < count; i++ ) - { - string locationValue = nodeParams[ index++ ]; - // REMOVE THIS TEST AFTER A COUPLE OF VERSIONS (curr v1.5.6 r02) - if( locationValue.Equals( "Bellow" ) ) locationValue = "Below"; - - UsePassLocation location = (UsePassLocation)Enum.Parse( typeof( UsePassLocation ), locationValue ); - string name = nodeParams[ index++ ]; - UsePassItem newItem = ScriptableObject.CreateInstance<UsePassItem>(); - newItem.hideFlags = HideFlags.HideAndDontSave; - newItem.Location = location; - newItem.Value = name; - m_items.Add( newItem ); - } - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - - public void WriteToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_items.Count ); - for( int i = 0; i < m_items.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].Location ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].Value ); - } - } - - public void BuildUsePassInfo( MasterNodeDataCollector dataCollector, ref string aboveItems, ref string bellowItems, string tabs) - { - int count = 0; - count = dataCollector.AboveUsePassesList.Count; - for( int i = 0; i < count; i++ ) - { - aboveItems += tabs + string.Format( UseGrabFormatNewLine, dataCollector.AboveUsePassesList[ i ].PropertyName ); - } - - count = dataCollector.BelowUsePassesList.Count; - for( int i = 0; i < count; i++ ) - { - bellowItems += tabs + string.Format( UseGrabFormatNewLine, dataCollector.BelowUsePassesList[ i ].PropertyName ); - } - - count = m_items.Count; - for( int i = 0; i < count; i++ ) - { - if( m_items[ i ].Location == UsePassLocation.Above ) - { - aboveItems += tabs + string.Format( UseGrabFormatNewLine, m_items[ i ].Value ); - } - else - { - bellowItems += tabs + string.Format( UseGrabFormatNewLine, m_items[ i ].Value ); - } - } - } - - public void BuildUsePassInfo( MasterNodeDataCollector dataCollector, ref List<PropertyDataCollector> aboveItems, ref List<PropertyDataCollector> bellowItems ) - { - int count = 0; - count = dataCollector.AboveUsePassesList.Count; - for( int i = 0; i < count; i++ ) - { - aboveItems.Add( new PropertyDataCollector( -1, string.Format( UseGrabFormat, dataCollector.AboveUsePassesList[ i ].PropertyName ) ) ); - } - - count = dataCollector.BelowUsePassesList.Count; - for( int i = 0; i < count; i++ ) - { - bellowItems.Add( new PropertyDataCollector( -1, string.Format( UseGrabFormat, dataCollector.BelowUsePassesList[ i ].PropertyName ) ) ); - } - - - count = m_items.Count; - for( int i = 0; i < count; i++ ) - { - if( m_items[ i ].Location == UsePassLocation.Above ) - { - aboveItems.Add( new PropertyDataCollector(-1,string.Format( UseGrabFormat, m_items[ i ].Value ))); - } - else - { - bellowItems.Add( new PropertyDataCollector( -1, string.Format( UseGrabFormat, m_items[ i ].Value ) ) ); - } - } - } - - //public string ModuleName { set { m_moduleName = value; } } - public void Destroy() - { - m_owner = null; - m_items.Clear(); - m_items = null; - m_reordableList = null; - m_dummyMaterial = null; - m_dummyCommand = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs.meta deleted file mode 100644 index ddf906c5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/UsePassHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d818a147712609646b8d6f0f7c2ae731 -timeCreated: 1530179906 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs deleted file mode 100644 index d09b8c04..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs +++ /dev/null @@ -1,272 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public enum ZWriteMode - { - On, - Off - } - - public enum ZTestMode - { - Less, - Greater, - LEqual, - GEqual, - Equal, - NotEqual, - Always - } - - [Serializable] - class ZBufferOpHelper - { - public static readonly string DepthParametersStr = " Depth"; - public static readonly string ZWriteModeStr = "ZWrite Mode"; - public static readonly string ZTestModeStr = "ZTest Mode"; - public static readonly string OffsetStr = "Offset"; - public static readonly string OffsetFactorStr = "Factor"; - public static readonly string OffsetUnitsStr = "Units"; - private const string ExtraDepthPassStr = "Extra Depth Pass"; - private const string DepthZTestStr = "Depth ZTest"; - - public static readonly string[] ZTestModeLabels = - { - "<Default>", - "Less", - "Greater", - "Less or Equal", - "Greater or Equal", - "Equal", - "Not Equal", - "Always" - }; - - public static readonly string[] ZTestModeValues = - { - "<Default>", - "Less", - "Greater", - "LEqual", - "GEqual", - "Equal", - "NotEqual", - "Always" - }; - - public static readonly string[] ZWriteModeValues = - { - "<Default>", - "On", - "Off" - }; - - public static readonly Dictionary<ZTestMode, int> ZTestModeDict = new Dictionary<ZTestMode, int> - { - {ZTestMode.Less,1 }, - {ZTestMode.Greater,2}, - {ZTestMode.LEqual,3}, - {ZTestMode.GEqual,4}, - {ZTestMode.Equal,5}, - {ZTestMode.NotEqual,6}, - {ZTestMode.Always,7} - }; - - public static readonly Dictionary<ZWriteMode, int> ZWriteModeDict = new Dictionary<ZWriteMode, int> - { - { ZWriteMode.On,1}, - { ZWriteMode.Off,2} - }; - - - [SerializeField] - private InlineProperty m_zTestMode = new InlineProperty(); - - [SerializeField] - private InlineProperty m_zWriteMode = new InlineProperty(); - [SerializeField] - private InlineProperty m_offsetFactor = new InlineProperty(); - - [SerializeField] - private InlineProperty m_offsetUnits = new InlineProperty(); - - [SerializeField] - private bool m_offsetEnabled; - - [SerializeField] - private bool m_extraDepthPass; - - [SerializeField] - private int m_extrazTestMode = 0; - - [SerializeField] - private StandardSurfaceOutputNode m_parentSurface; - - public string CreateDepthInfo( bool outlineZWrite, bool outlineZTest ) - { - string result = string.Empty; - if( m_zWriteMode.IntValue != 0 || m_zWriteMode.Active ) - { - MasterNode.AddRenderState( ref result, "ZWrite", m_zWriteMode.GetValueOrProperty( ZWriteModeValues[ m_zWriteMode.IntValue ] ) ); - } - else if( outlineZWrite ) - { - MasterNode.AddRenderState( ref result, "ZWrite", ZWriteModeValues[ 1 ] ); - } - - if( m_zTestMode.IntValue != 0 || m_zTestMode.Active ) - { - MasterNode.AddRenderState( ref result, "ZTest", m_zTestMode.GetValueOrProperty( ZTestModeValues[ m_zTestMode.IntValue ] ) ); - } - else if( outlineZTest ) - { - MasterNode.AddRenderState( ref result, "ZTest", ZTestModeValues[ 3 ] ); - } - - if( m_offsetEnabled ) - { - MasterNode.AddRenderState( ref result, "Offset ", m_offsetFactor.GetValueOrProperty() + " , " + m_offsetUnits.GetValueOrProperty() ); - } - - return result; - } - - public void Draw( UndoParentNode owner, GUIStyle toolbarstyle, bool customBlendAvailable ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( toolbarstyle ); - GUI.color = cachedColor; - EditorGUI.BeginChangeCheck(); - m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDepth = owner.GUILayoutToggle( m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDepth, DepthParametersStr, UIUtils.MenuItemToggleStyle ); - if( EditorGUI.EndChangeCheck() ) - { - EditorPrefs.SetBool( "ExpandedDepth", m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDepth ); - } - EditorGUILayout.EndHorizontal(); - - if( m_parentSurface.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedDepth ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - - EditorGUI.indentLevel++; - if( !customBlendAvailable ) - EditorGUILayout.HelpBox( "Depth Writing is only available for Opaque or Custom blend modes", MessageType.Warning ); - - EditorGUILayout.Separator(); - EditorGUI.BeginDisabledGroup( !customBlendAvailable ); - - m_zWriteMode.EnumTypePopup( ref owner, ZWriteModeStr, ZWriteModeValues ); - m_zTestMode.EnumTypePopup( ref owner, ZTestModeStr, ZTestModeLabels ); - //m_zWriteMode = owner.EditorGUILayoutPopup( ZWriteModeStr, m_zWriteMode, ZWriteModeValues ); - //m_zTestMode = owner.EditorGUILayoutPopup( ZTestModeStr, m_zTestMode, ZTestModeLabels ); - m_offsetEnabled = owner.EditorGUILayoutToggle( OffsetStr, m_offsetEnabled ); - if( m_offsetEnabled ) - { - EditorGUI.indentLevel++; - m_offsetFactor.FloatField( ref owner , OffsetFactorStr ); - m_offsetUnits.FloatField( ref owner , OffsetUnitsStr ); - EditorGUI.indentLevel--; - } - - m_extraDepthPass = owner.EditorGUILayoutToggle( ExtraDepthPassStr, m_extraDepthPass ); - if( m_extraDepthPass ) - { - EditorGUI.indentLevel++; - m_extrazTestMode = owner.EditorGUILayoutPopup( DepthZTestStr, m_extrazTestMode, ZTestModeLabels ); - EditorGUI.indentLevel--; - } - EditorGUILayout.Separator(); - EditorGUI.indentLevel--; - EditorGUI.EndDisabledGroup(); - EditorGUILayout.EndVertical(); - } - - EditorGUI.EndDisabledGroup(); - } - - public void DrawExtraDepthPass( ref string shaderBody ) - { - if( m_extraDepthPass ) - { - shaderBody += "\t\tPass\n"; - shaderBody += "\t\t{\n"; - shaderBody += "\t\t\tColorMask 0\n"; - if( m_extrazTestMode != 0 ) - shaderBody += "\t\t\tZTest " + ZTestModeValues[ m_extrazTestMode ] + "\n"; - shaderBody += "\t\t\tZWrite On\n"; - shaderBody += "\t\t}\n\n"; - } - } - - public void ReadFromString( ref uint index, ref string[] nodeParams ) - { - if( UIUtils.CurrentShaderVersion() < 2502 ) - { - string zWriteMode = nodeParams[ index++ ]; - m_zWriteMode.IntValue = zWriteMode.Equals( "Off" ) ? 2 : 0; - - string zTestMode = nodeParams[ index++ ]; - for( int i = 0; i < ZTestModeValues.Length; i++ ) - { - if( zTestMode.Equals( ZTestModeValues[ i ] ) ) - { - m_zTestMode.IntValue = i; - break; - } - } - } - else - { - if( UIUtils.CurrentShaderVersion() > 14501 ) - { - m_zWriteMode.ReadFromString( ref index, ref nodeParams ); - m_zTestMode.ReadFromString( ref index, ref nodeParams ); - } - else - { - m_zWriteMode.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - m_zTestMode.IntValue = Convert.ToInt32( nodeParams[ index++ ] ); - } - m_offsetEnabled = Convert.ToBoolean( nodeParams[ index++ ] ); - - if( UIUtils.CurrentShaderVersion() > 15303 ) - { - m_offsetFactor.ReadFromString( ref index, ref nodeParams ); - m_offsetUnits.ReadFromString( ref index, ref nodeParams ); - } - else - { - m_offsetFactor.FloatValue = Convert.ToSingle( nodeParams[ index++ ] ); - m_offsetUnits.FloatValue = Convert.ToSingle( nodeParams[ index++ ] ); - } - - if( UIUtils.CurrentShaderVersion() > 14202 ) - { - m_extraDepthPass = Convert.ToBoolean( nodeParams[ index++ ] ); - m_extrazTestMode = Convert.ToInt32( nodeParams[ index++ ] ); - } - } - } - - public void WriteToString( ref string nodeInfo ) - { - m_zWriteMode.WriteToString( ref nodeInfo ); - m_zTestMode.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_offsetEnabled ); - m_offsetFactor.WriteToString( ref nodeInfo ); - m_offsetUnits.WriteToString( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_extraDepthPass ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_extrazTestMode ); - } - public bool IsActive { get { return m_zTestMode.IntValue != 0 || m_zWriteMode.IntValue != 0 || m_offsetEnabled || m_zTestMode.Active || m_zWriteMode.Active; } } - public StandardSurfaceOutputNode ParentSurface { get { return m_parentSurface; } set { m_parentSurface = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs.meta deleted file mode 100644 index edee7bf1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Master/ZBufferOpHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f35a3e26a28596b4f9b54a1f2689db06 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc.meta deleted file mode 100644 index ae40b7c9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 6371d71bb076e1d47a3854adc59fdb93 -folderAsset: yes -timeCreated: 1481126945 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs deleted file mode 100644 index 6318614b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs +++ /dev/null @@ -1,254 +0,0 @@ -// 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]Append", "Vector Operators", "Append channels to create a new component",null,KeyCode.V,true,true,"Append",typeof(DynamicAppendNode))] - public sealed class AppendNode : ParentNode - { - private const string OutputTypeStr = "Output type"; - - [SerializeField] - private WirePortDataType m_selectedOutputType = WirePortDataType.FLOAT4; - - [SerializeField] - private int m_selectedOutputTypeInt = 2; - - [SerializeField] - private float[] m_defaultValues = { 0, 0, 0, 0 }; - private string[] m_defaultValuesStr = { "[0]", "[1]", "[2]", "[3]" }; - - private readonly string[] m_outputValueTypes ={ "Vector2", - "Vector3", - "Vector4", - "Color"}; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "[0]" ); - AddInputPort( WirePortDataType.FLOAT, false, "[1]" ); - AddInputPort( WirePortDataType.FLOAT, false, "[2]" ); - AddInputPort( WirePortDataType.FLOAT, false, "[3]" ); - AddOutputPort( m_selectedOutputType, Constants.EmptyPortValue ); - m_textLabelWidth = 90; - m_autoWrapProperties = true; - m_previewShaderGUID = "d80ac81aabf643848a4eaa76f2f88d65"; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( m_dropdownEditing ) - { - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUIPopup( m_dropdownRect, m_selectedOutputTypeInt, m_outputValueTypes, UIUtils.PropertyPopUp ); - if ( EditorGUI.EndChangeCheck() ) - { - SetupPorts(); - DropdownEditing = false; - } - } - } - - void SetupPorts() - { - switch ( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT2; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT3; break; - case 2: m_selectedOutputType = WirePortDataType.FLOAT4; break; - case 3: m_selectedOutputType = WirePortDataType.COLOR; break; - } - - UpdatePorts(); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUILayoutPopup( OutputTypeStr, m_selectedOutputTypeInt, m_outputValueTypes ); - if ( EditorGUI.EndChangeCheck() ) - { - SetupPorts(); - } - - int count = 0; - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - count = 4; - } - break; - case WirePortDataType.FLOAT3: - { - count = 3; - } - break; - case WirePortDataType.FLOAT2: - { - count = 2; - } - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - for ( int i = 0; i < count; i++ ) - { - if ( !m_inputPorts[ i ].IsConnected ) - m_defaultValues[ i ] = EditorGUILayoutFloatField( m_defaultValuesStr[ i ], m_defaultValues[ i ] ); - } - - EditorGUILayout.EndVertical(); - } - void UpdatePorts() - { - m_sizeIsDirty = true; - ChangeOutputType( m_selectedOutputType, false ); - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - m_inputPorts[ 0 ].Visible = true; - m_inputPorts[ 1 ].Visible = true; - m_inputPorts[ 2 ].Visible = true; - m_inputPorts[ 3 ].Visible = true; - } - break; - case WirePortDataType.FLOAT3: - { - m_inputPorts[ 0 ].Visible = true; - m_inputPorts[ 1 ].Visible = true; - m_inputPorts[ 2 ].Visible = true; - m_inputPorts[ 3 ].Visible = false; - if ( m_inputPorts[ 3 ].IsConnected ) - UIUtils.DeleteConnection( true, UniqueId, 3, false, true ); - } - break; - case WirePortDataType.FLOAT2: - { - m_inputPorts[ 0 ].Visible = true; - m_inputPorts[ 1 ].Visible = true; - m_inputPorts[ 2 ].Visible = false; - if ( m_inputPorts[ 2 ].IsConnected ) - UIUtils.DeleteConnection( true, UniqueId, 2, false, true ); - - m_inputPorts[ 3 ].Visible = false; - if ( m_inputPorts[ 3 ].IsConnected ) - UIUtils.DeleteConnection( true, UniqueId, 3, false, true ); - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - } - 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 = string.Empty; - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - value = "float4( "; - for ( int i = 0; i < 4; i++ ) - { - value += m_inputPorts[ i ].IsConnected ? InputPorts[ i ].GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT, ignoreLocalVar, true ) : m_defaultValues[ i ].ToString(); - if ( i != 3 ) - value += " , "; - } - value += " )"; - } - break; - case WirePortDataType.FLOAT3: - { - value = "float3( "; - for ( int i = 0; i < 3; i++ ) - { - value += m_inputPorts[ i ].IsConnected ? InputPorts[ i ].GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT, ignoreLocalVar, true ) : m_defaultValues[ i ].ToString(); - if ( i != 2 ) - value += " , "; - } - value += " )"; - } - break; - case WirePortDataType.FLOAT2: - { - value = "float2( "; - for ( int i = 0; i < 2; i++ ) - { - value += m_inputPorts[ i ].IsConnected ? InputPorts[ i ].GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT, ignoreLocalVar, true ) : m_defaultValues[ i ].ToString(); - if ( i != 1 ) - value += " , "; - } - value += " )"; - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - RegisterLocalVariable( 0, value, ref dataCollector, "appendResult" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedOutputType = ( WirePortDataType ) Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT2: m_selectedOutputTypeInt = 0; break; - case WirePortDataType.FLOAT3: m_selectedOutputTypeInt = 1; break; - case WirePortDataType.FLOAT4: m_selectedOutputTypeInt = 2; break; - case WirePortDataType.COLOR: m_selectedOutputTypeInt = 3; break; - } - for ( int i = 0; i < m_defaultValues.Length; i++ ) - { - m_defaultValues[ i ] = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - } - UpdatePorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedOutputType ); - for ( int i = 0; i < m_defaultValues.Length; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultValues[ i ] ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs.meta deleted file mode 100644 index bd513529..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/AppendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 688412c534df41444ad49759fa2b6a62 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs deleted file mode 100644 index 340ae384..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs +++ /dev/null @@ -1,273 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Break To Components", "Vector Operators", "Breaks the input data into its individual components", null, KeyCode.B, tags: "split" )] - public sealed class BreakToComponentsNode : ParentNode - { - private WirePortDataType m_currentType = WirePortDataType.FLOAT; - private readonly string[] ColorPortNames = { "R", "G", "B", "A" }; - private readonly string[] VectorPortNames = { "X", "Y", "Z", "W" }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - for( int i = 0; i < 16; i++ ) - { - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_outputPorts[ i ].IndexPreviewOffset = 1; - if( i != 0 ) - { - m_outputPorts[ i ].Visible = false; - } - } - m_previewShaderGUID = "5f58f74a202ba804daddec838b75207d"; - } - - public override void RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - SetPreviewInputs(); - - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - RenderTexture temp = RenderTexture.active; - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, Mathf.Min( i, 3 ) ); - RenderTexture.active = temp; - } - - PreviewIsDirty = m_continuousPreviewRefresh; - } - - public override RenderTexture PreviewTexture - { - get - { - return m_inputPorts[ 0 ].InputPreviewTexture( ContainerGraph ); - } - } - - void UpdateOutputs( WirePortDataType newType ) - { - //this only happens when on initial load - if( newType == WirePortDataType.OBJECT ) - return; - - m_currentType = newType; - switch( newType ) - { - case WirePortDataType.OBJECT: - { - m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.OBJECT, false ); - m_outputPorts[ 0 ].Visible = true; - for( int i = 1; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT: - { - m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.FLOAT, false ); - m_outputPorts[ 0 ].Visible = true; - for( int i = 1; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT2: - { - for( int i = 0; i < 2; i++ ) - { - m_outputPorts[ i ].ChangeProperties( VectorPortNames[ i ], WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - for( int i = 2; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT3: - { - for( int i = 0; i < 3; i++ ) - { - m_outputPorts[ i ].ChangeProperties( VectorPortNames[ i ], WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - for( int i = 3; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT4: - { - for( int i = 0; i < 4; i++ ) - { - m_outputPorts[ i ].ChangeProperties( VectorPortNames[ i ], WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - for( int i = 4; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT3x3: - { - for( int i = 0; i < 9; i++ ) - { - m_outputPorts[ i ].ChangeProperties( "[" + (int)( i / 3 ) + "][" + i % 3 + "]", WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - for( int i = 9; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.FLOAT4x4: - { - for( int i = 0; i < 16; i++ ) - { - m_outputPorts[ i ].ChangeProperties( "[" + (int)( i / 4 ) + "][" + i % 4 + "]", WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - } - break; - case WirePortDataType.COLOR: - { - for( int i = 0; i < 4; i++ ) - { - m_outputPorts[ i ].ChangeProperties( ColorPortNames[ i ], WirePortDataType.FLOAT, false ); - m_outputPorts[ i ].Visible = true; - } - for( int i = 4; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - case WirePortDataType.INT: - { - m_outputPorts[ 0 ].Visible = true; - m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.INT, false ); - for( int i = 1; i < m_outputPorts.Count; i++ ) - { - m_outputPorts[ i ].Visible = false; - } - } - break; - } - m_sizeIsDirty = true; - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - UpdateOutputs( m_inputPorts[ 0 ].DataType ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - UpdateOutputs( m_inputPorts[ 0 ].DataType ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentType ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - UpdateOutputs( (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ) ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - { - return ReturnByType( m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ), outputId ); - } - - string value = string.Empty; - value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - int channelsUsed = 0; - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - channelsUsed++; - } - string varName = "break" + OutputId; - if( channelsUsed > 1 ) - { - //RegisterLocalVariable( 0, value, ref dataCollector, varName ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, varName, value ); - m_outputPorts[ 0 ].SetLocalValue( varName, dataCollector.PortCategory ); - - - value = varName; - } - - return ReturnByType( value, outputId ); - } - - private string ReturnByType( string value, int outputId ) - { - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - { - return value; - } - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - { - return GetOutputVectorItem( 0, outputId + 1, value ); - } - case WirePortDataType.COLOR: - { - return GetOutputColorItem( 0, outputId + 1, value ); - } - case WirePortDataType.FLOAT3x3: - { - return value + "[ " + ( (int)( outputId / 3 ) ) + " ][ " + ( outputId % 3 ) + " ]"; - } - case WirePortDataType.FLOAT4x4: - { - return value + "[ " + ( (int)( outputId / 4 ) ) + " ][ " + ( outputId % 4 ) + " ]"; - } - } - return value; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs.meta deleted file mode 100644 index 34381d11..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/BreakToComponentsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a74e2c0a9306c0048bfcc733cb7d154d -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs deleted file mode 100644 index 4c792b7f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs +++ /dev/null @@ -1,1625 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; -using System.Text.RegularExpressions; - -namespace AmplifyShaderEditor -{ - public enum CustomExpressionMode - { - Create, - Call - } - - [Serializable] - public class CustomExpressionInputItem - { - public PrecisionType Precision; - public VariableQualifiers Qualifier; - public WirePortDataType Type; - public string CustomType; - public bool IsVariable; - public bool FoldoutFlag; - public string FoldoutLabel; - - public CustomExpressionInputItem( PrecisionType precision, VariableQualifiers qualifier, string customType, bool isVariable, bool foldoutFlag, string foldoutLabel ) - { - Precision = precision; - Qualifier = qualifier; - CustomType = customType; - FoldoutFlag = foldoutFlag; - FoldoutLabel = foldoutLabel; - IsVariable = isVariable; - } - } - - [Serializable] - public class CustomExpressionDependency - { - public int DependencyArrayIdx; - public int DependencyNodeId; - public CustomExpressionDependency() { DependencyArrayIdx = DependencyNodeId = -1; } - public CustomExpressionDependency( string id ) { DependencyNodeId = Convert.ToInt32( id ); DependencyArrayIdx = -1; } - public void Reset() - { - DependencyArrayIdx = -1; - DependencyNodeId = -1; - } - } - - [Serializable] - [NodeAttributes( "Custom Expression", "Miscellaneous", "Creates a custom expression or function if <b>return</b> is detected in the written code." )] - public sealed class CustomExpressionNode : ParentNode - { - private const float AddRemoveButtonLayoutWidth = 15; - private const float LineAdjust = 1.15f; - private const float IdentationAdjust = 5f; - private const string CustomExpressionInfo = "Creates a custom expression or function according to how code is written on text area.\n\n" + - " - If a return function is detected on Code text area then a function will be created.\n" + - "Also in function mode a ; is expected on the end of each instruction line.\n\n" + - "- If no return function is detected then an expression will be generated and used directly on the vertex/frag body.\n" + - "On Expression mode a ; is not required on the end of an instruction line."; - private const char LineFeedSeparator = '$'; - - private const string ReturnHelper = "return"; - private const double MaxTimestamp = 1; - private const string DefaultExpressionNameStr = "My Custom Expression"; - private const string DefaultInputNameStr = "In"; - private const string CodeTitleStr = "Code"; - private const string OutputTypeStr = "Output Type"; - private const string CustomTypeStr = " "; - private const string IsVariableStr = "Is Variable"; - private const string InputsStr = "Inputs"; - private const string InputNameStr = "Name"; - private const string InputTypeStr = "Type"; - private const string InputValueStr = "Value"; - private const string InputQualifierStr = "Qualifier"; - private const string ExpressionNameLabelStr = "Name"; - private const string FunctionCallModeStr = "Mode"; - private const string GenerateUniqueNameStr = "Set Unique"; - private const string AutoRegisterStr = "Auto-Register"; - private const string DependenciesStr = "Dependencies"; - - private const string VarRegexReplacer = @"\b{0}\b"; - private readonly string[] PrecisionLabelsExtraLocal = { "Float", "Half", "Inherit Local" }; - - private readonly string[] AvailableWireTypesStr = - { - "int", - "float", - "float2", - "float3", - "float4", - "float3x3", - "float4x4", - "sampler1D", - "sampler2D", - "sampler3D", - "samplerCUBE", - "custom"}; - - private readonly string[] AvailableOutputWireTypesStr = - { - "int", - "float", - "float2", - "float3", - "float4", - "float3x3", - "float4x4", - "void", - }; - - private readonly string[] QualifiersStr = - { - "In", - "Out", - "InOut" - }; - - private readonly WirePortDataType[] AvailableWireTypes = - { - WirePortDataType.INT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.SAMPLER1D, - WirePortDataType.SAMPLER2D, - WirePortDataType.SAMPLER3D, - WirePortDataType.SAMPLERCUBE, - WirePortDataType.OBJECT - }; - - private readonly WirePortDataType[] AvailableOutputWireTypes = - { - WirePortDataType.INT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.OBJECT, - }; - - - private readonly Dictionary<WirePortDataType, int> WireToIdx = new Dictionary<WirePortDataType, int> - { - { WirePortDataType.INT, 0}, - { WirePortDataType.FLOAT, 1}, - { WirePortDataType.FLOAT2, 2}, - { WirePortDataType.FLOAT3, 3}, - { WirePortDataType.FLOAT4, 4}, - { WirePortDataType.FLOAT3x3, 5}, - { WirePortDataType.FLOAT4x4, 6}, - { WirePortDataType.SAMPLER1D, 7}, - { WirePortDataType.SAMPLER2D, 8}, - { WirePortDataType.SAMPLER3D, 9}, - { WirePortDataType.SAMPLERCUBE, 10}, - { WirePortDataType.OBJECT, 11} - }; - - [SerializeField] - private string m_customExpressionName = DefaultExpressionNameStr; - - [SerializeField] - private List<CustomExpressionInputItem> m_items = new List<CustomExpressionInputItem>(); - - [SerializeField] - private string m_code = " "; - - [SerializeField] - private int m_outputTypeIdx = 1; - - [SerializeField] - private bool m_visibleInputsFoldout = true; - - [SerializeField] - private CustomExpressionMode m_mode = CustomExpressionMode.Create; - - [SerializeField] - private bool m_voidMode = false; - - [SerializeField] - private bool m_autoRegisterMode = false; - - [SerializeField] - private bool m_functionMode = false; - - [SerializeField] - private int m_firstAvailablePort = 0; - - [SerializeField] - private string m_uniqueName; - - [SerializeField] - private bool m_generateUniqueName = true; - - [SerializeField] - private bool m_dependenciesFoldout = false; - - [SerializeField] - private List<CustomExpressionDependency> m_dependencies = new List<CustomExpressionDependency>(); - - private const float ButtonLayoutWidth = 15; - - private bool m_repopulateNameDictionary = true; - private Dictionary<string, int> m_usedNames = new Dictionary<string, int>(); - - private double m_lastTimeNameModified = 0; - private bool m_nameModified = false; - - private double m_lastTimeCodeModified = 0; - private bool m_codeModified = false; - - //Title editing - private bool m_isEditing; - private bool m_stopEditing; - private bool m_startEditing; - private double m_clickTime; - private double m_doubleClickTime = 0.3; - private Rect m_titleClickArea; - - //Item Reordable List - private ReordableAction m_actionType = ReordableAction.None; - private int m_actionIndex = 0; - private int m_lastIndex = 0; - - private ReorderableList m_itemReordableList = null; - private ReorderableList m_dependenciesReordableList = null; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "In0" ); - m_items.Add( new CustomExpressionInputItem( PrecisionType.Inherit, VariableQualifiers.In, string.Empty, false, true, string.Empty/*"[0]"*/ ) ); - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - m_textLabelWidth = 97; - m_customPrecision = true; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - - if( m_mode == CustomExpressionMode.Create ) - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.AddNode( this ); - - SetTitleText( m_customExpressionName ); - - if( m_nodeAttribs != null ) - m_uniqueName = m_nodeAttribs.Name + OutputId; - else - m_uniqueName = "CustomExpression" + OutputId; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - CheckPortConnection( portId ); - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - CheckPortConnection( portId ); - } - - void CheckPortConnection( int portId ) - { - if( portId == 0 && ( m_mode == CustomExpressionMode.Call || m_voidMode ) ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - if( m_nameModified ) - { - if( ( EditorApplication.timeSinceStartup - m_lastTimeNameModified ) > MaxTimestamp ) - { - m_nameModified = false; - m_sizeIsDirty = true; - m_repopulateNameDictionary = true; - } - } - - if( m_repopulateNameDictionary ) - { - m_repopulateNameDictionary = false; - m_usedNames.Clear(); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_usedNames.Add( m_inputPorts[ i ].Name, i ); - } - } - - if( m_codeModified ) - { - if( ( EditorApplication.timeSinceStartup - m_lastTimeCodeModified ) > MaxTimestamp ) - { - m_codeModified = false; - bool functionMode = m_code.Contains( ReturnHelper ); - if( functionMode != m_functionMode ) - { - m_functionMode = functionMode; - CheckCallMode(); - } - } - } - } - - bool CheckCallMode() - { - if( m_functionMode && m_mode == CustomExpressionMode.Call ) - { - Mode = CustomExpressionMode.Create; - m_outputTypeIdx = ( AvailableOutputWireTypesStr.Length - 1 ); - //m_outputPorts[ 0 ].ChangeType( AvailableOutputWireTypes[ m_outputTypeIdx ], false ); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_voidMode = true; - return true; - } - return false; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( !m_isEditing && ( ( !ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains( drawInfo.MousePosition ) ) ) ) - { - if( ( EditorApplication.timeSinceStartup - m_clickTime ) < m_doubleClickTime ) - m_startEditing = true; - else - GUI.FocusControl( null ); - m_clickTime = EditorApplication.timeSinceStartup; - } - else if( m_isEditing && ( ( drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains( drawInfo.MousePosition ) ) || !EditorGUIUtility.editingTextField ) ) - { - m_stopEditing = true; - } - - if( m_isEditing || m_startEditing ) - { - EditorGUI.BeginChangeCheck(); - GUI.SetNextControlName( m_uniqueName ); - m_customExpressionName = EditorGUITextField( m_titleClickArea, string.Empty, m_customExpressionName, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - if( EditorGUI.EndChangeCheck() ) - { - SetTimedUpdate( 2 ); - SetTitleText( m_customExpressionName ); - m_sizeIsDirty = true; - m_isDirty = true; - } - - if( m_startEditing ) - EditorGUI.FocusTextInControl( m_uniqueName ); - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( m_startEditing ) - { - m_startEditing = false; - m_isEditing = true; - } - - if( m_stopEditing ) - { - m_stopEditing = false; - m_isEditing = false; - GUI.FocusControl( null ); - } - } - } - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - m_titleClickArea = m_titlePos; - m_titleClickArea.height = Constants.NODE_HEADER_HEIGHT; - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - if( !m_isVisible ) - return; - - // Fixed Title ( only renders when not editing ) - if( !m_isEditing && !m_startEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( m_titleClickArea, m_content, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public string GetFirstAvailableName() - { - string name = string.Empty; - for( int i = 0; i < m_inputPorts.Count + 1; i++ ) - { - name = DefaultInputNameStr + i; - if( !m_usedNames.ContainsKey( name ) ) - { - return name; - } - } - Debug.LogWarning( "Could not find valid name" ); - return string.Empty; - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawBaseProperties ); - //NodeUtils.DrawPropertyGroup( ref m_visibleInputsFoldout, InputsStr, DrawInputs, DrawAddRemoveInputs ); - NodeUtils.DrawPropertyGroup( ref m_visibleInputsFoldout, InputsStr, DrawReordableInputs, DrawItemsAddRemoveInputs ); - - EditorGUILayout.HelpBox( CustomExpressionInfo, MessageType.Info ); - } - - string WrapCodeInFunction( bool isTemplate, string functionName, bool expressionMode ) - { - //Hack to be used util indent is properly used - int currIndent = UIUtils.ShaderIndentLevel; - UIUtils.ShaderIndentLevel = isTemplate ? 0 : 1; - - if( !isTemplate ) UIUtils.ShaderIndentLevel++; - - //string functionName = UIUtils.RemoveInvalidCharacters( m_customExpressionName ); - string returnType = ( m_mode == CustomExpressionMode.Call || m_voidMode ) ? "void" : UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - if( expressionMode ) - returnType = "inline " + returnType; - - string functionBody = UIUtils.ShaderIndentTabs + returnType + " " + functionName + "( "; - int count = m_inputPorts.Count - m_firstAvailablePort; - for( int i = 0; i < count; i++ ) - { - int portIdx = i + m_firstAvailablePort; - string qualifier = m_items[ i ].Qualifier == VariableQualifiers.In ? string.Empty : UIUtils.QualifierToCg( m_items[ i ].Qualifier ) + " "; - PrecisionType precision = m_items[ i ].Precision; - if( precision == PrecisionType.Inherit ) - precision = CurrentPrecisionType; - string dataType = ( m_inputPorts[ portIdx ].DataType == WirePortDataType.OBJECT ) ? m_items[ i ].CustomType : UIUtils.PrecisionWirePortToCgType( precision, m_inputPorts[ portIdx ].DataType ); - functionBody += qualifier + dataType + " " + m_inputPorts[ portIdx ].Name; - if( i < ( count - 1 ) ) - { - functionBody += " , "; - } - } - functionBody += " )\n" + UIUtils.ShaderIndentTabs + "{\n"; - UIUtils.ShaderIndentLevel++; - { - if( expressionMode ) - functionBody += UIUtils.ShaderIndentTabs + "return "; - - string[] codeLines = m_code.Split( IOUtils.LINE_TERMINATOR ); - for( int i = 0; i < codeLines.Length; i++ ) - { - if( codeLines[ i ].Length > 0 ) - { - functionBody += ( ( i == 0 && expressionMode ) ? string.Empty : UIUtils.ShaderIndentTabs ) + codeLines[ i ] + ( ( ( i == codeLines.Length - 1 ) && expressionMode ) ? string.Empty : "\n" ); - } - } - if( expressionMode ) - functionBody += ";\n"; - } - UIUtils.ShaderIndentLevel--; - - functionBody += UIUtils.ShaderIndentTabs + "}\n"; - UIUtils.ShaderIndentLevel = currIndent; - return functionBody; - } - - void DrawBaseProperties() - { - EditorGUI.BeginChangeCheck(); - m_customExpressionName = EditorGUILayoutTextField( ExpressionNameLabelStr, m_customExpressionName ); - if( EditorGUI.EndChangeCheck() ) - { - SetTimedUpdate( 2 ); - SetTitleText( m_customExpressionName ); - } - - EditorGUI.BeginChangeCheck(); - Mode = (CustomExpressionMode)EditorGUILayoutEnumPopup( FunctionCallModeStr, m_mode ); - if( EditorGUI.EndChangeCheck() ) - { - if( CheckCallMode() ) - UIUtils.ShowMessage( UniqueId, "Call Mode cannot have return over is code.\nFalling back to Create Mode" ); - SetupCallMode(); - RecalculateInOutOutputPorts(); - } - - EditorGUILayout.LabelField( CodeTitleStr ); - EditorGUI.BeginChangeCheck(); - { - m_code = EditorGUILayoutTextArea( m_code, UIUtils.MainSkin.textArea ); - } - if( EditorGUI.EndChangeCheck() ) - { - m_codeModified = true; - m_lastTimeCodeModified = EditorApplication.timeSinceStartup; - } - - if( m_mode == CustomExpressionMode.Create ) - { - DrawPrecisionProperty(); - - bool guiEnabled = GUI.enabled; - - GUI.enabled = !AutoRegisterMode; - m_generateUniqueName = EditorGUILayoutToggle( GenerateUniqueNameStr, m_generateUniqueName ) && !AutoRegisterMode; - - GUI.enabled = !m_generateUniqueName; - AutoRegisterMode = EditorGUILayoutToggle( AutoRegisterStr, AutoRegisterMode ) && !m_generateUniqueName; - - GUI.enabled = guiEnabled; - - EditorGUI.BeginChangeCheck(); - m_outputTypeIdx = EditorGUILayoutPopup( OutputTypeStr, m_outputTypeIdx, AvailableOutputWireTypesStr ); - if( EditorGUI.EndChangeCheck() ) - { - bool oldVoidValue = m_voidMode; - UpdateVoidMode(); - if( oldVoidValue != m_voidMode ) - { - SetupCallMode(); - RecalculateInOutOutputPorts(); - } - else - { - m_outputPorts[ 0 ].ChangeType( AvailableOutputWireTypes[ m_outputTypeIdx ], false ); - } - } - } - NodeUtils.DrawNestedPropertyGroup( ref m_dependenciesFoldout, "Dependencies", DrawDependencies, DrawDependenciesAddRemoveInputs ); - } - - void UpdateVoidMode() - { - m_voidMode = ( m_outputTypeIdx == ( AvailableOutputWireTypesStr.Length - 1 ) ); - } - - void SetupCallMode() - { - if( m_mode == CustomExpressionMode.Call || m_voidMode ) - { - if( m_firstAvailablePort != 1 ) - { - m_firstAvailablePort = 1; - AddInputPortAt( 0, WirePortDataType.FLOAT, false, DefaultInputNameStr ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - } - } - else - { - if( m_firstAvailablePort != 0 ) - { - m_firstAvailablePort = 0; - if( m_inputPorts[ 0 ].IsConnected ) - { - m_containerGraph.DeleteConnection( true, UniqueId, m_inputPorts[ 0 ].PortId, false, true ); - } - DeleteInputPortByArrayIdx( 0 ); - m_outputPorts[ 0 ].ChangeType( AvailableOutputWireTypes[ m_outputTypeIdx ], false ); - } - } - } - - void DrawItemsAddRemoveInputs() - { - if( m_inputPorts.Count == m_firstAvailablePort ) - m_visibleInputsFoldout = false; - - // Add new port - if( GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - AddPortAt( m_inputPorts.Count ); - m_visibleInputsFoldout = true; - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - RemovePortAt( m_inputPorts.Count - 1 ); - EditorGUI.FocusTextInControl( null ); - } - } - - void DrawDependenciesAddRemoveInputs() - { - // Add new port - if( GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - m_dependencies.Add( new CustomExpressionDependency() ); - EditorGUI.FocusTextInControl( null ); - } - - //Remove port - if( GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) ) - { - m_dependencies.RemoveAt( m_dependencies.Count - 1 ); - } - } - - void DrawDependencies() - { - if( m_dependenciesReordableList == null ) - { - m_dependenciesReordableList = new ReorderableList( m_dependencies, typeof( CustomExpressionDependency ), true, false, false, false ) - { - headerHeight = 0, - footerHeight = 0, - showDefaultBackground = false, - drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) => - { - if( m_dependencies[ index ] != null ) - { - rect.xMin -= 1; - - Rect popupPos = new Rect( rect.x, rect.y, rect.width - 2 * Constants.PlusMinusButtonLayoutWidth, EditorGUIUtility.singleLineHeight ); - Rect buttonPlusPos = new Rect( rect.x + rect.width - 2 * Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth ); - Rect buttonMinusPos = new Rect( rect.x + rect.width - Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth ); - EditorGUI.BeginChangeCheck(); - m_dependencies[ index ].DependencyArrayIdx = EditorGUIPopup( popupPos, string.Empty, m_dependencies[ index ].DependencyArrayIdx, UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.NodesArr ); - if( EditorGUI.EndChangeCheck() ) - { - m_dependencies[ index ].DependencyNodeId = UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.GetNode( m_dependencies[ index ].DependencyArrayIdx ).UniqueId; - if( m_dependencies[ index ].DependencyNodeId == UniqueId ) - { - m_dependencies[ index ].Reset(); - } - } - - if( GUI.Button( buttonPlusPos, string.Empty, UIUtils.PlusStyle ) ) - { - m_actionType = ReordableAction.Add; - m_actionIndex = index; - } - - if( GUI.Button( buttonMinusPos, string.Empty, UIUtils.MinusStyle ) ) - { - m_actionType = ReordableAction.Remove; - m_actionIndex = index; - } - } - } - }; - } - - if( m_dependenciesReordableList != null ) - { - EditorGUILayout.Space(); - if( m_dependencies.Count == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - else - { - m_dependenciesReordableList.DoLayoutList(); - } - EditorGUILayout.Space(); - } - - if( m_actionType != ReordableAction.None ) - { - switch( m_actionType ) - { - case ReordableAction.Add: - m_dependencies.Insert( m_actionIndex + 1, new CustomExpressionDependency() ); - break; - case ReordableAction.Remove: - m_dependencies.RemoveAt( m_actionIndex ); - break; - } - m_isDirty = true; - m_actionType = ReordableAction.None; - EditorGUI.FocusTextInControl( null ); - } - } - - void DrawReordableInputs() - { - if( m_itemReordableList == null ) - { - m_itemReordableList = new ReorderableList( m_items, typeof( CustomExpressionInputItem ), true, false, false, false ) - { - headerHeight = 0, - footerHeight = 0, - showDefaultBackground = false, - elementHeightCallback = ( int index ) => - { - float lineHeight = EditorGUIUtility.singleLineHeight * LineAdjust; - if( m_items[ index ].FoldoutFlag ) - { - float size = 7 * lineHeight; - - // Take Is Variable toggle into account - if( m_mode == CustomExpressionMode.Call ) - size += lineHeight; - - if( m_inputPorts[ m_firstAvailablePort + index ].DataType == WirePortDataType.OBJECT ) - size += lineHeight; - - if( !m_inputPorts[ m_firstAvailablePort + index ].IsConnected ) - { - switch( m_inputPorts[ m_firstAvailablePort + index ].DataType ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - size += 0;// lineHeight; - break; - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - size += lineHeight;//2 * lineHeight; - break; - case WirePortDataType.FLOAT3x3: - size += 5 * lineHeight;//6 * lineHeight; - break; - case WirePortDataType.FLOAT4x4: - size += 6 * lineHeight;//8 * lineHeight; - break; - - } - } - - return size; - } - else - { - return lineHeight; - } - }, - - onReorderCallback = ( ReorderableList list ) => - { - int realLastIndex = m_firstAvailablePort + m_lastIndex; - int realCurrIndex = m_firstAvailablePort + list.index; - - InputPort portA = m_inputPorts[ realLastIndex ]; - int originalOutputPortId = CreateOutputId( portA.PortId ); - - SwapInputPorts( realLastIndex, realCurrIndex ); - - if( m_outputPorts.Count > 1 ) - { - if( list.index > m_lastIndex ) - { - for( int i = m_lastIndex; i <= list.index; i++ ) - { - if( m_items[ i ].Qualifier != VariableQualifiers.In ) - { - int portIdx = i + m_firstAvailablePort; - int oldOutputPortId; - if( i < list.index ) - { - int oldinputPortId = m_inputPorts[ portIdx ].PortId + 1; - oldOutputPortId = CreateOutputId( oldinputPortId ); - } - else - { - oldOutputPortId = originalOutputPortId; - } - - m_outputPortsDict[ oldOutputPortId ].ChangePortId( CreateOutputId( m_inputPorts[ portIdx ].PortId ) ); - } - } - } - else - { - for( int i = list.index; i <= m_lastIndex; i++ ) - { - if( m_items[ i ].Qualifier != VariableQualifiers.In ) - { - int portIdx = i + m_firstAvailablePort; - int oldOutputPortId; - if( i > list.index ) - { - int oldinputPortId = m_inputPorts[ portIdx ].PortId - 1; - oldOutputPortId = CreateOutputId( oldinputPortId ); - } - else - { - oldOutputPortId = originalOutputPortId; - } - - m_outputPortsDict[ oldOutputPortId ].ChangePortId( CreateOutputId( m_inputPorts[ portIdx ].PortId ) ); - } - } - } - } - - - m_outputPorts.Sort( ( A, B ) => - { - return A.PortId.CompareTo( B.PortId ); - } ); - - m_outputPortsDict.Clear(); - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - m_outputPortsDict.Add( m_outputPorts[ i ].PortId, m_outputPorts[ i ] ); - } - - }, - onSelectCallback = ( ReorderableList list ) => - { - m_lastIndex = list.index; - }, - drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) => - { - if( m_items[ index ] != null ) - { - float lineHeight = EditorGUIUtility.singleLineHeight; - float lineSpacing = lineHeight * LineAdjust; - - rect.x -= IdentationAdjust; - rect.height = lineHeight; - int portIdx = index + m_firstAvailablePort; - Rect foldoutRect = rect; - if( !m_items[ index ].FoldoutFlag ) - { - foldoutRect.width -= 2 * AddRemoveButtonLayoutWidth; - } - m_items[ index ].FoldoutFlag = EditorGUIFoldout( foldoutRect, m_items[ index ].FoldoutFlag, /*m_items[ index ].FoldoutLabel + " - " +*/ m_inputPorts[ portIdx ].Name ); - if( m_items[ index ].FoldoutFlag ) - { - rect.x += IdentationAdjust; - - //Qualifier - rect.y += lineSpacing; - VariableQualifiers newQualifier = (VariableQualifiers)EditorGUIPopup( rect, InputQualifierStr, (int)m_items[ index ].Qualifier, QualifiersStr ); - if( newQualifier != m_items[ index ].Qualifier ) - { - VariableQualifiers oldQualifier = m_items[ index ].Qualifier; - m_items[ index ].Qualifier = newQualifier; - if( newQualifier == VariableQualifiers.In ) - { - RemoveOutputPort( CreateOutputId( m_inputPorts[ portIdx ].PortId ), false ); - } - else if( oldQualifier == VariableQualifiers.In ) - { - int outputId = CreateOutputId( m_inputPorts[ portIdx ].PortId ); - AddOutputPort( m_inputPorts[ portIdx ].DataType, m_inputPorts[ portIdx ].Name, outputId ); - } - m_inputPorts[ portIdx ].Visible = newQualifier != VariableQualifiers.Out; - m_sizeIsDirty = true; - RecalculateInOutOutputPorts(); - } - - // Precision - rect.y += lineSpacing; - m_items[ index ].Precision = (PrecisionType)EditorGUIPopup( rect, PrecisionContent.text, (int)m_items[ index ].Precision, PrecisionLabelsExtraLocal ); - // Type - rect.y += lineSpacing; - int typeIdx = WireToIdx[ m_inputPorts[ portIdx ].DataType ]; - EditorGUI.BeginChangeCheck(); - { - typeIdx = EditorGUIPopup( rect, InputTypeStr, typeIdx, AvailableWireTypesStr ); - } - - if( EditorGUI.EndChangeCheck() ) - { - m_inputPorts[ portIdx ].ChangeType( AvailableWireTypes[ typeIdx ], false ); - if( typeIdx == 5 || typeIdx == 6 ) - { - m_inputPorts[ portIdx ].Matrix4x4InternalData = Matrix4x4.identity; - } - - if( m_items[ index ].Qualifier != VariableQualifiers.In ) - { - OutputPort currOutPort = GetOutputPortByUniqueId( CreateOutputId( m_inputPorts[ portIdx ].PortId ) ); - currOutPort.ChangeType( AvailableWireTypes[ typeIdx ], false ); - } - } - - if( AvailableWireTypes[ typeIdx ] == WirePortDataType.OBJECT ) - { - rect.y += lineSpacing; - m_items[ index ].CustomType = EditorGUITextField( rect, CustomTypeStr, m_items[ index ].CustomType ); - } - - //Name - rect.y += lineSpacing; - EditorGUI.BeginChangeCheck(); - { - m_inputPorts[ portIdx ].Name = EditorGUITextField( rect, InputNameStr, m_inputPorts[ portIdx ].Name ); - } - if( EditorGUI.EndChangeCheck() ) - { - m_nameModified = true; - m_lastTimeNameModified = EditorApplication.timeSinceStartup; - m_inputPorts[ portIdx ].Name = UIUtils.RemoveInvalidCharacters( m_inputPorts[ portIdx ].Name ); - if( string.IsNullOrEmpty( m_inputPorts[ portIdx ].Name ) ) - { - m_inputPorts[ portIdx ].Name = DefaultInputNameStr + index; - } - - if( m_items[ index ].Qualifier != VariableQualifiers.In ) - { - OutputPort currOutPort = GetOutputPortByUniqueId( CreateOutputId( m_inputPorts[ portIdx ].PortId ) ); - currOutPort.Name = m_inputPorts[ portIdx ].Name; - } - } - - if( m_mode == CustomExpressionMode.Call ) - { - //Is Unique - rect.y += lineSpacing; - m_items[ index ].IsVariable = EditorGUIToggle( rect, IsVariableStr, m_items[ index ].IsVariable ); - } - // Port Data - if( !m_inputPorts[ portIdx ].IsConnected ) - { - rect.y += lineSpacing; - m_inputPorts[ portIdx ].ShowInternalData( rect, this, true, InputValueStr ); - } - - //Buttons - rect.x += rect.width - 2 * AddRemoveButtonLayoutWidth; - rect.y += lineSpacing; - if( !m_inputPorts[ m_firstAvailablePort + index ].IsConnected ) - { - switch( m_inputPorts[ m_firstAvailablePort + index ].DataType ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - rect.y += 0;// lineSpacing; - break; - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - rect.y += lineSpacing;//2 * lineSpacing; - break; - case WirePortDataType.FLOAT3x3: - rect.y += 5 * lineSpacing;//6 * lineSpacing; - break; - case WirePortDataType.FLOAT4x4: - rect.y += 6 * lineSpacing;//8 * lineSpacing; - break; - - } - } - rect.width = AddRemoveButtonLayoutWidth; - if( GUI.Button( rect, string.Empty, UIUtils.PlusStyle ) ) - { - m_actionType = ReordableAction.Add; - m_actionIndex = index; - } - rect.x += AddRemoveButtonLayoutWidth; - if( GUI.Button( rect, string.Empty, UIUtils.MinusStyle ) ) - { - m_actionType = ReordableAction.Remove; - m_actionIndex = index; - } - - } - else - { - //Buttons - rect.x += IdentationAdjust + rect.width - 2 * AddRemoveButtonLayoutWidth; - rect.width = AddRemoveButtonLayoutWidth; - if( GUI.Button( rect, string.Empty, UIUtils.PlusStyle ) ) - { - m_actionType = ReordableAction.Add; - m_actionIndex = index; - } - rect.x += AddRemoveButtonLayoutWidth; - if( GUI.Button( rect, string.Empty, UIUtils.MinusStyle ) ) - { - m_actionType = ReordableAction.Remove; - m_actionIndex = index; - } - } - } - } - }; - } - - if( m_itemReordableList != null ) - { - EditorGUILayout.Space(); - if( m_items.Count == 0 ) - { - EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info ); - } - else - { - m_itemReordableList.DoLayoutList(); - } - EditorGUILayout.Space(); - } - - if( m_actionType != ReordableAction.None ) - { - switch( m_actionType ) - { - case ReordableAction.Add: - AddPortAt( m_firstAvailablePort + m_actionIndex + 1 ); - break; - case ReordableAction.Remove: - RemovePortAt( m_firstAvailablePort + m_actionIndex ); - break; - } - m_isDirty = true; - m_actionType = ReordableAction.None; - EditorGUI.FocusTextInControl( null ); - } - } - - void RecalculateInOutOutputPorts() - { - m_outputPorts.Sort( ( x, y ) => x.PortId.CompareTo( y.PortId ) ); - - m_outputPortsDict.Clear(); - int count = m_inputPorts.Count - m_firstAvailablePort; - int outputId = 1; - for( int i = 0; i < count; i++ ) - { - int idx = i + m_firstAvailablePort; - if( m_items[ i ].Qualifier != VariableQualifiers.In ) - { - m_outputPorts[ outputId ].ChangeProperties( m_inputPorts[ idx ].Name, m_inputPorts[ idx ].DataType, false ); - m_outputPorts[ outputId ].ChangePortId( CreateOutputId( m_inputPorts[ idx ].PortId ) ); - outputId++; - } - } - - int outCount = m_outputPorts.Count; - for( int i = 0; i < outCount; i++ ) - { - m_outputPortsDict.Add( m_outputPorts[ i ].PortId, m_outputPorts[ i ] ); - } - } - - void AddPortAt( int idx ) - { - AddInputPortAt( idx, WirePortDataType.FLOAT, false, GetFirstAvailableName() ); - m_items.Insert( idx - m_firstAvailablePort, new CustomExpressionInputItem( PrecisionType.Inherit, VariableQualifiers.In, string.Empty, false, true, string.Empty/* "[" + idx + "]"*/ ) ); - m_repopulateNameDictionary = true; - RecalculateInOutOutputPorts(); - } - - void RemovePortAt( int idx ) - { - if( m_inputPorts.Count > m_firstAvailablePort ) - { - int varIdx = idx - m_firstAvailablePort; - if( m_items[ varIdx ].Qualifier != VariableQualifiers.In ) - { - int id = CreateOutputId( m_inputPorts[ idx ].PortId ); - RemoveOutputPort( id, false ); - } - - DeleteInputPortByArrayIdx( idx ); - m_items.RemoveAt( varIdx ); - - m_repopulateNameDictionary = true; - - RecalculateInOutOutputPorts(); - } - } - - public override void OnAfterDeserialize() - { - base.OnAfterDeserialize(); - m_repopulateNameDictionary = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( string.IsNullOrEmpty( m_code ) ) - { - UIUtils.ShowMessage( UniqueId, "Custom Expression need to have code associated", MessageSeverity.Warning ); - return "0"; - } - - m_code = m_code.Replace( "\r\n", "\n" ); - - bool codeContainsReturn = m_code.Contains( ReturnHelper ); - if( !codeContainsReturn && outputId != 0 && m_mode == CustomExpressionMode.Create && !m_voidMode ) - { - UIUtils.ShowMessage( "Attempting to get value from inexisting inout/out variable", MessageSeverity.Warning ); - return "0"; - } - - int dependenciesCount = m_dependencies.Count; - Dictionary<int, CustomExpressionNode> examinedNodes = new Dictionary<int, CustomExpressionNode>(); - for( int i = 0; i < dependenciesCount; i++ ) - { - CustomExpressionNode node = m_containerGraph.GetNode( m_dependencies[ i ].DependencyNodeId ) as CustomExpressionNode; - if( node == null ) - { - node = UIUtils.CurrentWindow.OutsideGraph.GetNode( m_dependencies[ i ].DependencyNodeId ) as CustomExpressionNode; - } - - if( node != null ) - { - node.CheckDependencies( ref dataCollector, ref examinedNodes ); - } - } - examinedNodes.Clear(); - examinedNodes = null; - - - OutputPort outputPort = GetOutputPortByUniqueId( outputId ); - if( outputPort.IsLocalValue( dataCollector.PortCategory ) ) - return outputPort.LocalValue( dataCollector.PortCategory ); - - string expressionName = UIUtils.RemoveInvalidCharacters( m_customExpressionName ); - string localVarName = "local" + expressionName; - - if( m_generateUniqueName ) - { - expressionName += OutputId; - } - localVarName += OutputId; - - int count = m_inputPorts.Count; - if( count > 0 ) - { - if( m_mode == CustomExpressionMode.Call || m_voidMode ) - { - string mainData = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - RegisterLocalVariable( 0, string.Format( Constants.CodeWrapper, mainData ), ref dataCollector, localVarName ); - } - - if( codeContainsReturn ) - { - string function = WrapCodeInFunction( dataCollector.IsTemplate, expressionName, false ); - string functionCall = expressionName + "( "; - for( int i = m_firstAvailablePort; i < count; i++ ) - { - string inputPortLocalVar = m_inputPorts[ i ].Name + OutputId; - int idx = i - m_firstAvailablePort; - if( m_inputPorts[ i ].DataType != WirePortDataType.OBJECT ) - { - string result = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ i ].DataType, inputPortLocalVar, result ); - } - else - { - string result =( m_inputPorts[ i ].IsConnected )? m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector) : m_inputPorts[ i ].InternalData.ToString(); - string inputLocalVar = string.Format( Constants.CustomTypeLocalValueDecWithoutIdent, m_items[ idx ].CustomType, inputPortLocalVar, result ); - dataCollector.AddLocalVariable( UniqueId, inputLocalVar ); - } - - if( m_items[ idx ].Qualifier != VariableQualifiers.In ) - { - OutputPort currOutputPort = GetOutputPortByUniqueId( CreateOutputId( m_inputPorts[ i ].PortId ) ); - currOutputPort.SetLocalValue( inputPortLocalVar, dataCollector.PortCategory ); - } - functionCall += inputPortLocalVar; - if( i < ( count - 1 ) ) - { - functionCall += " , "; - } - } - functionCall += " )"; - - if( m_mode == CustomExpressionMode.Call || m_voidMode ) - { - dataCollector.AddLocalVariable( 0, functionCall + ";", true ); - } - else - { - RegisterLocalVariable( 0, functionCall, ref dataCollector, localVarName ); - } - - dataCollector.AddFunction( expressionName, function ); - } - else - { - - string localCode = m_code; - if( m_mode == CustomExpressionMode.Call || m_voidMode ) - { - for( int i = m_firstAvailablePort; i < count; i++ ) - { - int idx = i - m_firstAvailablePort; - if( !m_items[ idx ].IsVariable || - m_items[ idx ].Qualifier != VariableQualifiers.In || - !m_inputPorts[ i ].IsConnected - ) - { - string inputPortLocalVar = m_inputPorts[ i ].Name + OutputId; - string nameToReplaceRegex = string.Format( VarRegexReplacer, m_inputPorts[ i ].Name ); - localCode = Regex.Replace( localCode, nameToReplaceRegex, inputPortLocalVar, RegexOptions.Multiline ); - //localCode = localCode.Replace( m_inputPorts[ i ].Name, inputPortLocalVar ); - - if( m_inputPorts[ i ].IsConnected ) - { - string result = m_inputPorts[ i ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ i ].DataType, true, true ); - if( m_inputPorts[ i ].DataType == WirePortDataType.OBJECT ) - { - dataCollector.AddLocalVariable( UniqueId, m_items[ idx ].CustomType + " " + inputPortLocalVar, result + ";" ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ i ].DataType, inputPortLocalVar, result ); - } - } - else - { - if( m_inputPorts[ i ].DataType == WirePortDataType.OBJECT ) - { - dataCollector.AddLocalVariable( UniqueId, m_items[ idx ].CustomType + " " + inputPortLocalVar, m_inputPorts[ i ].WrappedInternalData + ";" ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ i ].DataType, inputPortLocalVar, m_inputPorts[ i ].WrappedInternalData ); - } - } - - if( m_items[ idx ].Qualifier != VariableQualifiers.In ) - { - OutputPort currOutputPort = GetOutputPortByUniqueId( CreateOutputId( m_inputPorts[ i ].PortId ) ); - currOutputPort.SetLocalValue( inputPortLocalVar, dataCollector.PortCategory ); - } - } - else - { - // Not Unique - string result = m_inputPorts[ i ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ i ].DataType, true, true ); - string nameToReplaceRegex = string.Format( VarRegexReplacer, m_inputPorts[ i ].Name ); - localCode = Regex.Replace( localCode, nameToReplaceRegex, result, RegexOptions.Multiline ); - //localCode = localCode.Replace( m_inputPorts[ i ].Name, result ); - } - } - string[] codeLines = localCode.Split( '\n' ); - for( int codeIdx = 0; codeIdx < codeLines.Length; codeIdx++ ) - { - dataCollector.AddLocalVariable( 0, codeLines[ codeIdx ], true ); - } - } - else - { - string function = WrapCodeInFunction( dataCollector.IsTemplate, expressionName, true ); - - string functionCall = expressionName + "( "; - for( int i = m_firstAvailablePort; i < count; i++ ) - { - - string inputPortLocalVar = m_inputPorts[ i ].Name + OutputId; - int idx = i - m_firstAvailablePort; - if( m_inputPorts[ i ].DataType != WirePortDataType.OBJECT ) - { - string result = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ i ].DataType, inputPortLocalVar, result ); - } - else - { - string result = ( m_inputPorts[ i ].IsConnected ) ? m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ) : m_inputPorts[ i ].InternalData.ToString(); - string inputLocalVar = string.Format( Constants.CustomTypeLocalValueDecWithoutIdent, m_items[ idx ].CustomType, inputPortLocalVar, result ); - dataCollector.AddLocalVariable( UniqueId, inputLocalVar ); - } - - if( m_items[ idx ].Qualifier != VariableQualifiers.In ) - { - OutputPort currOutputPort = GetOutputPortByUniqueId( CreateOutputId( m_inputPorts[ i ].PortId ) ); - currOutputPort.SetLocalValue( inputPortLocalVar, dataCollector.PortCategory ); - } - functionCall += inputPortLocalVar; - if( i < ( count - 1 ) ) - { - functionCall += " , "; - } - } - functionCall += " )"; - RegisterLocalVariable( 0, functionCall, ref dataCollector, localVarName ); - dataCollector.AddFunction( expressionName, function ); - } - } - - return outputPort.LocalValue( dataCollector.PortCategory ); - } - else - { - if( m_code.Contains( ReturnHelper ) ) - { - string function = WrapCodeInFunction( dataCollector.IsTemplate, expressionName, false ); - dataCollector.AddFunction( expressionName, function ); - string functionCall = expressionName + "()"; - RegisterLocalVariable( 0, functionCall, ref dataCollector, localVarName ); - } - else - { - RegisterLocalVariable( 0, string.Format( Constants.CodeWrapper, m_code ), ref dataCollector, localVarName ); - } - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } - - int CreateOutputId( int inputId ) - { - return ( inputId + 1 ); - } - - int CreateInputId( int outputId ) - { - return outputId - 1; - } - - void UpdateOutputPorts() - { - int count = m_inputPorts.Count - m_firstAvailablePort; - for( int i = 0; i < count; i++ ) - { - if( m_items[ i ].Qualifier != VariableQualifiers.In ) - { - int portIdx = i + m_firstAvailablePort; - int outputPortId = CreateOutputId( m_inputPorts[ portIdx ].PortId ); - AddOutputPort( m_inputPorts[ portIdx ].DataType, m_inputPorts[ portIdx ].Name, outputPortId ); - } - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - // This node is, by default, created with one input port - base.ReadFromString( ref nodeParams ); - m_code = GetCurrentParam( ref nodeParams ); - m_code = m_code.Replace( LineFeedSeparator, '\n' ); - m_code = m_code.Replace( Constants.SemiColonSeparator, ';' ); - m_outputTypeIdx = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( m_outputTypeIdx >= AvailableWireTypes.Length ) - { - UIUtils.ShowMessage( UniqueId, "Sampler types were removed as a valid output custom expression type" ); - m_outputTypeIdx = 1; - } - UpdateVoidMode(); - m_outputPorts[ 0 ].ChangeType( AvailableWireTypes[ m_outputTypeIdx ], false ); - - if( UIUtils.CurrentShaderVersion() > 12001 ) - { - bool mode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_mode = mode ? CustomExpressionMode.Call : CustomExpressionMode.Create; - if( m_mode == CustomExpressionMode.Call || m_voidMode ) - { - m_firstAvailablePort = 1; - AddInputPortAt( 0, WirePortDataType.FLOAT, false, DefaultInputNameStr ); - } - } - - if( m_mode == CustomExpressionMode.Call ) - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.RemoveNode( this ); - - int count = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( count == 0 ) - { - DeleteInputPortByArrayIdx( m_firstAvailablePort ); - m_items.Clear(); - } - else - { - for( int i = 0; i < count; i++ ) - { - bool foldoutValue = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - string name = GetCurrentParam( ref nodeParams ); - WirePortDataType type = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - string internalData = GetCurrentParam( ref nodeParams ); - VariableQualifiers qualifier = VariableQualifiers.In; - if( UIUtils.CurrentShaderVersion() > 12001 ) - { - qualifier = (VariableQualifiers)Enum.Parse( typeof( VariableQualifiers ), GetCurrentParam( ref nodeParams ) ); - } - string customType = string.Empty; - if( UIUtils.CurrentShaderVersion() > 15311 ) - { - customType = GetCurrentParam( ref nodeParams ); - } - PrecisionType precision = PrecisionType.Float; - if( UIUtils.CurrentShaderVersion() > 15607 ) - { - precision = (PrecisionType)Enum.Parse( typeof( PrecisionType ), GetCurrentParam( ref nodeParams ) ); - } - bool isVariable = false; - if( UIUtils.CurrentShaderVersion() > 16600 ) - { - isVariable = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - int portIdx = i + m_firstAvailablePort; - if( i == 0 ) - { - m_inputPorts[ portIdx ].ChangeProperties( name, type, false ); - m_inputPorts[ portIdx ].Visible = qualifier != VariableQualifiers.Out; - m_items[ 0 ].Qualifier = qualifier; - m_items[ 0 ].FoldoutFlag = foldoutValue; - m_items[ 0 ].CustomType = customType; - m_items[ 0 ].Precision = precision; - m_items[ 0 ].IsVariable = isVariable; - } - else - { - m_items.Add( new CustomExpressionInputItem( precision, qualifier, customType, isVariable, foldoutValue, string.Empty/*"[" + i + "]"*/ ) ); - AddInputPort( type, false, name ); - m_inputPorts[ m_inputPorts.Count - 1 ].Visible = qualifier != VariableQualifiers.Out; - } - m_inputPorts[ i ].InternalData = internalData; - } - } - - if( UIUtils.CurrentShaderVersion() > 7205 ) - { - m_customExpressionName = GetCurrentParam( ref nodeParams ); - SetTitleText( m_customExpressionName ); - } - - if( UIUtils.CurrentShaderVersion() > 14401 ) - { - m_generateUniqueName = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15102 ) - { - m_autoRegisterMode = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15403 ) - { - int dependencyCount = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - for( int i = 0; i < dependencyCount; i++ ) - { - m_dependencies.Add( new CustomExpressionDependency( GetCurrentParam( ref nodeParams ) ) ); - } - } - - if( m_mode == CustomExpressionMode.Create ) - { - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.AddNode( this ); - } - UpdateOutputPorts(); - - m_repopulateNameDictionary = true; - m_functionMode = m_code.Contains( ReturnHelper ); - CheckCallMode(); - - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - - m_code = m_code.Replace( "\r\n", "\n" ); - - string parsedCode = m_code.Replace( '\n', LineFeedSeparator ); - parsedCode = parsedCode.Replace( ';', Constants.SemiColonSeparator ); - - IOUtils.AddFieldValueToString( ref nodeInfo, parsedCode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_outputTypeIdx ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mode == CustomExpressionMode.Call ); - - int count = m_inputPorts.Count - m_firstAvailablePort; - IOUtils.AddFieldValueToString( ref nodeInfo, count ); - for( int i = 0; i < count; i++ ) - { - int portIdx = m_firstAvailablePort + i; - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].FoldoutFlag ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ portIdx ].Name ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ portIdx ].DataType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ portIdx ].InternalData ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].Qualifier ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].CustomType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].Precision ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_items[ i ].IsVariable ); - } - IOUtils.AddFieldValueToString( ref nodeInfo, m_customExpressionName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_generateUniqueName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoRegisterMode ); - count = m_dependencies.Count; - IOUtils.AddFieldValueToString( ref nodeInfo, count ); - for( int i = 0; i < count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_dependencies[ i ].DependencyNodeId ); - } - } - - public override void Destroy() - { - base.Destroy(); - if( m_mode == CustomExpressionMode.Create ) - { - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.RemoveNode( this ); - } - m_items.Clear(); - m_items = null; - m_dependencies.Clear(); - m_dependencies = null; - m_itemReordableList = null; - } - - public void CheckDependencies( ref MasterNodeDataCollector dataCollector, ref Dictionary<int, CustomExpressionNode> examinedNodes ) - { - if( !examinedNodes.ContainsKey( UniqueId ) && m_mode == CustomExpressionMode.Create && !m_generateUniqueName ) - { - int dependencyCount = m_dependencies.Count; - for( int d = 0; d < dependencyCount; d++ ) - { - if( !examinedNodes.ContainsKey( m_dependencies[ d ].DependencyNodeId ) ) - { - CustomExpressionNode dNode = m_containerGraph.GetNode( m_dependencies[ d ].DependencyNodeId ) as CustomExpressionNode; - - if( dNode == null ) - { - dNode = UIUtils.CurrentWindow.OutsideGraph.GetNode( m_dependencies[ d ].DependencyNodeId ) as CustomExpressionNode; - } - - if( dNode != null ) - { - dNode.CheckDependencies( ref dataCollector, ref examinedNodes ); - } - } - } - dataCollector.AddFunction( ExpressionName, EncapsulatedCode( dataCollector.IsTemplate ) ); - examinedNodes.Add( UniqueId, this ); - } - } - - public string EncapsulatedCode( bool isTemplate ) - { - string functionName = UIUtils.RemoveInvalidCharacters( m_customExpressionName ); - if( m_generateUniqueName ) - { - functionName += OutputId; - } - return WrapCodeInFunction( isTemplate, functionName, false ); - } - - public CustomExpressionMode Mode - { - get { return m_mode; } - set - { - if( m_mode != value ) - { - m_mode = value; - if( m_mode == CustomExpressionMode.Call ) - { - AutoRegisterMode = false; - m_generateUniqueName = false; - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.RemoveNode( this ); - } - else - { - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.AddNode( this ); - } - } - } - } - - public string ExpressionName - { - get - { - string expressionName = UIUtils.RemoveInvalidCharacters( m_customExpressionName ); - - if( m_generateUniqueName ) - { - expressionName += OutputId; - } - return expressionName; - } - } - public override string DataToArray { get { return m_customExpressionName; } } - public bool AutoRegisterMode - { - get { return m_autoRegisterMode; } - set - { - if( value != m_autoRegisterMode ) - { - m_autoRegisterMode = value; - } - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - int portCount = m_inputPorts.Count; - for( int i = 0; i < portCount; i++ ) - { - if( m_inputPorts[ i ].DataType == WirePortDataType.COLOR ) - { - m_inputPorts[ i ].ChangeType( WirePortDataType.FLOAT4, false ); ; - } - } - - int dependencyCount = m_dependencies.Count; - for( int i = 0; i < dependencyCount; i++ ) - { - m_dependencies[ i ].DependencyArrayIdx = UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.GetNodeRegisterIdx( m_dependencies[ i ].DependencyNodeId ); - } - //Fixing bug where user could set main output port as OBJECT - if( m_outputPorts[ 0 ].DataType == WirePortDataType.OBJECT && ( m_voidMode || m_mode == CustomExpressionMode.Call ) ) - { - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - } - - public override void FireTimedUpdate() - { - UIUtils.CurrentWindow.OutsideGraph.CustomExpressionOnFunctionMode.UpdateDataOnNode( UniqueId, m_customExpressionName ); - } - - public List<CustomExpressionDependency> Dependencies { get { return m_dependencies; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs.meta deleted file mode 100644 index bf377187..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/CustomExpressionNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f2507a764c07082458e350211d671334 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs deleted file mode 100644 index 64cc8ebe..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs +++ /dev/null @@ -1,475 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - - public struct AppendData - { - public WirePortDataType PortType; - public int OldPortId; - public int NewPortId; - public AppendData( WirePortDataType portType, int oldPortId, int newPortId ) - { - PortType = portType; - OldPortId = oldPortId; - NewPortId = newPortId; - } - } - - [Serializable] - [NodeAttributes( "Append", "Vector Operators", "Append channels to create a new component", null, KeyCode.V, tags: "combine" )] - public sealed class DynamicAppendNode : ParentNode - { - private const string OutputTypeStr = "Output type"; - private const string OutputFormatStr = "({0}({1}))"; - - [SerializeField] - private WirePortDataType m_selectedOutputType = WirePortDataType.FLOAT4; - - [SerializeField] - private int m_selectedOutputTypeInt = 2; - - private readonly string[] m_outputValueTypes ={ "Vector2", - "Vector3", - "Vector4", - "Color"}; - - [SerializeField] - private int[] m_occupiedChannels = { -1, -1, -1, -1 }; - - [SerializeField] - private int m_maskId; - - [SerializeField] - private Vector4 m_maskValue = Vector4.one; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.ChannelNamesVector[ 0 ] ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.ChannelNamesVector[ 1 ] ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.ChannelNamesVector[ 2 ] ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.ChannelNamesVector[ 3 ] ); - AddOutputPort( m_selectedOutputType, Constants.EmptyPortValue ); - m_textLabelWidth = 90; - m_autoWrapProperties = true; - m_useInternalPortData = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "bfcd2919fe75bbf428fbbe583f463a9e"; - } - - public override void OnEnable() - { - base.OnEnable(); - m_maskId = Shader.PropertyToID( "_Mask" ); - } - - void NewUpdateBehaviorConn( int portId, bool onLoading ) - { - InputPort inputPort = GetInputPortByUniqueId( portId ); - int channelsRequired = UIUtils.GetChannelsAmount( onLoading ? inputPort.DataType : inputPort.ConnectionType( 0 ) ); - int availableChannels = UIUtils.GetChannelsAmount( m_selectedOutputType ); - - // Invalidate previously used channels - for( int i = 0; i < availableChannels; i++ ) - { - if( m_occupiedChannels[ i ] == portId ) - { - m_occupiedChannels[ i ] = -1; - m_inputPorts[ i ].Visible = true; - } - } - // Lock available channels to port - int len = Mathf.Min( portId + channelsRequired, availableChannels ); - - int channelsUsed = 0; - for( int i = portId; i < len; i++ ) - { - if( m_occupiedChannels[ i ] == -1 ) - { - m_occupiedChannels[ i ] = portId; - channelsUsed += 1; - } - else - { - break; - } - } - - if( !onLoading ) - inputPort.ChangeType( UIUtils.GetWireTypeForChannelAmount( channelsUsed ), false ); - - if( channelsUsed > 1 && portId < availableChannels - 1 ) - { - channelsUsed -= 1; - int i = portId + 1; - for( ; channelsUsed > 0; i++, --channelsUsed ) - { - m_inputPorts[ i ].Visible = false; - } - - } - m_sizeIsDirty = true; - } - - void NewUpdateBehaviorDisconn( int portId ) - { - int availableChannels = UIUtils.GetChannelsAmount( m_selectedOutputType ); - // Invalidate previously used channels - for( int i = 0; i < availableChannels; i++ ) - { - if( m_occupiedChannels[ i ] == portId ) - { - m_occupiedChannels[ i ] = -1; - m_inputPorts[ i ].Visible = true; - m_inputPorts[ i ].ChangeType( WirePortDataType.FLOAT, false ); - } - } - m_sizeIsDirty = true; - } - - void RenamePorts() - { - int channel = 0; - for( int i = 0; i < 4; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - string name = string.Empty; - int usedChannels = UIUtils.GetChannelsAmount( m_inputPorts[ i ].DataType ); - bool isColor = ( m_selectedOutputType == WirePortDataType.COLOR ); - for( int j = 0; j < usedChannels; j++ ) - { - if( channel < Constants.ChannelNamesVector.Length ) - name += isColor ? Constants.ChannelNamesColor[ channel++ ] : Constants.ChannelNamesVector[ channel++ ]; - } - m_inputPorts[ i ].Name = name; - } - } - - CalculatePreviewData(); - } - - void UpdatePortTypes() - { - ChangeOutputType( m_selectedOutputType, false ); - int availableChannels = UIUtils.GetChannelsAmount( m_selectedOutputType ); - int usedChannels = 0; - while( usedChannels < availableChannels ) - { - int channelsRequired = m_inputPorts[ usedChannels ].IsConnected ? UIUtils.GetChannelsAmount( m_inputPorts[ usedChannels ].DataType ) : 0; - if( channelsRequired > 0 ) - { - - if( ( usedChannels + channelsRequired ) < availableChannels ) - { - usedChannels += channelsRequired; - } - else - { - m_inputPorts[ usedChannels ].Visible = true; - WirePortDataType newType = UIUtils.GetWireTypeForChannelAmount( availableChannels - usedChannels ); - m_inputPorts[ usedChannels ].ChangeType( newType, false ); - usedChannels = availableChannels; - break; - } - } - else - { - m_occupiedChannels[ usedChannels ] = -1; - m_inputPorts[ usedChannels ].Visible = true; - m_inputPorts[ usedChannels ].ChangeType( WirePortDataType.FLOAT, false ); - usedChannels += 1; - } - } - - for( int i = usedChannels; i < availableChannels; i++ ) - { - m_occupiedChannels[ i ] = -1; - m_inputPorts[ i ].Visible = true; - m_inputPorts[ i ].ChangeType( WirePortDataType.FLOAT, false ); - } - - for( int i = availableChannels; i < 4; i++ ) - { - m_occupiedChannels[ i ] = -1; - m_inputPorts[ i ].Visible = false; - m_inputPorts[ i ].ChangeType( WirePortDataType.FLOAT, false ); - } - m_sizeIsDirty = true; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - - if( ( m_containerGraph.IsLoading || m_isNodeBeingCopied ) && UIUtils.CurrentShaderVersion() < 13206 ) - return; - - NewUpdateBehaviorConn( portId, ( UIUtils.IsLoading|| m_isNodeBeingCopied ) ); - RenamePorts(); - - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - - if( ( UIUtils.IsLoading || m_isNodeBeingCopied ) && UIUtils.CurrentShaderVersion() < 13206 ) - return; - - NewUpdateBehaviorDisconn( portId ); - RenamePorts(); - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - - if( ( UIUtils.IsLoading || m_isNodeBeingCopied ) && UIUtils.CurrentShaderVersion() < 13206 ) - return; - - NewUpdateBehaviorConn( portId, ( UIUtils.IsLoading || m_isNodeBeingCopied ) ); - RenamePorts(); - } - - void SetupPorts() - { - switch( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT2; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT3; break; - case 2: m_selectedOutputType = WirePortDataType.FLOAT4; break; - case 3: m_selectedOutputType = WirePortDataType.COLOR; break; - } - UpdatePortTypes(); - RenamePorts(); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_dropdownEditing ) - { - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUIPopup( m_dropdownRect, m_selectedOutputTypeInt, m_outputValueTypes, UIUtils.PropertyPopUp ); - if( EditorGUI.EndChangeCheck() ) - { - SetupPorts(); - DropdownEditing = false; - } - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUILayoutPopup( OutputTypeStr, m_selectedOutputTypeInt, m_outputValueTypes ); - if( EditorGUI.EndChangeCheck() ) - { - SetupPorts(); - } - - EditorGUILayout.EndVertical(); - } - - 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 result = string.Empty; - for( int i = 0; i < 4; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - if( i > 0 ) - { - result += " , "; - } - result += m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ); - } - } - - result = string.Format( OutputFormatStr, - UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_selectedOutputType ), - result ); - - RegisterLocalVariable( 0, result, ref dataCollector, "appendResult" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedOutputType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT2: m_selectedOutputTypeInt = 0; break; - case WirePortDataType.FLOAT3: m_selectedOutputTypeInt = 1; break; - case WirePortDataType.FLOAT4: m_selectedOutputTypeInt = 2; break; - case WirePortDataType.COLOR: m_selectedOutputTypeInt = 3; break; - } - } - - public override void ReadFromDeprecated( ref string[] nodeParams, Type oldType = null ) - { - m_selectedOutputType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT2: m_selectedOutputTypeInt = 0; break; - case WirePortDataType.FLOAT3: m_selectedOutputTypeInt = 1; break; - case WirePortDataType.FLOAT4: m_selectedOutputTypeInt = 2; break; - case WirePortDataType.COLOR: m_selectedOutputTypeInt = 3; break; - } - for( int i = 0; i < 4; i++ ) - { - m_inputPorts[i].FloatInternalData = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - - if( UIUtils.CurrentShaderVersion() < 13206 ) - { - //TODO: MAKE THIS LESS BRUTE FORCE - List<AppendData> reroutes = new List<AppendData>(); - int availableChannel = 0; - for( int i = 0; i < 4 && availableChannel < 4; i++ ) - { - int channelsAmount = UIUtils.GetChannelsAmount( m_inputPorts[ i ].DataType ); - if( m_inputPorts[ i ].IsConnected /*&& availableChannel != i*/ ) - { - reroutes.Add( new AppendData( m_inputPorts[ i ].DataType, i, availableChannel ) ); - } - - availableChannel += channelsAmount; - } - - if( reroutes.Count > 0 ) - { - for( int i = reroutes.Count - 1; i > -1; i-- ) - { - int nodeId = m_inputPorts[ reroutes[ i ].OldPortId ].ExternalReferences[ 0 ].NodeId; - int portId = m_inputPorts[ reroutes[ i ].OldPortId ].ExternalReferences[ 0 ].PortId; - - m_containerGraph.DeleteConnection( true, UniqueId, reroutes[ i ].OldPortId, false, false, false ); - m_containerGraph.CreateConnection( UniqueId, reroutes[ i ].NewPortId, nodeId, portId, false ); - NewUpdateBehaviorConn( reroutes[ i ].NewPortId, true ); - } - } - - availableChannel = UIUtils.GetChannelsAmount( m_selectedOutputType ); - int currChannelIdx = 0; - for( ; currChannelIdx < availableChannel; currChannelIdx++ ) - { - if( m_inputPorts[ currChannelIdx ].Visible ) - { - int channelsAmount = UIUtils.GetChannelsAmount( m_inputPorts[ currChannelIdx ].DataType ); - for( int j = currChannelIdx + 1; j < currChannelIdx + channelsAmount; j++ ) - { - m_inputPorts[ j ].Visible = false; - } - } - } - - for( ; currChannelIdx < 4; currChannelIdx++ ) - { - m_inputPorts[ currChannelIdx ].Visible = false; - } - } - SetupPorts(); - m_sizeIsDirty = true; - } - - - void CalculatePreviewData() - { - switch( m_outputPorts[ 0 ].DataType ) - { - default: m_maskValue = Vector4.zero; break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: m_maskValue = new Vector4( 1, 0, 0, 0 ); break; - case WirePortDataType.FLOAT2: m_maskValue = new Vector4( 1, 1, 0, 0 ); break; - case WirePortDataType.FLOAT3: m_maskValue = new Vector4( 1, 1, 1, 0 ); break; - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: m_maskValue = Vector4.one; break; - } - - m_previewMaterialPassId = -1; - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - { - switch( m_inputPorts[ 1 ].DataType ) - { - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - { - if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT || - m_inputPorts[ 2 ].DataType == WirePortDataType.INT ) - { - m_previewMaterialPassId = 0; - } - else if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT2 ) - { - m_previewMaterialPassId = 1; - } - } - break; - case WirePortDataType.FLOAT2: m_previewMaterialPassId = 2; break; - case WirePortDataType.FLOAT3: m_previewMaterialPassId = 3; break; - } - - }; break; - case WirePortDataType.FLOAT2: - { - if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT || - m_inputPorts[ 2 ].DataType == WirePortDataType.INT ) - { - m_previewMaterialPassId = 4; - } - else if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT2 ) - { - m_previewMaterialPassId = 5; - } - }; break; - case WirePortDataType.FLOAT3: m_previewMaterialPassId = 6; break; - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: m_previewMaterialPassId = 7; break; - } - - if( m_previewMaterialPassId == -1 ) - { - m_previewMaterialPassId = 0; - if( DebugConsoleWindow.DeveloperMode ) - { - UIUtils.ShowMessage( UniqueId, "Could not find pass ID for append" , MessageSeverity.Error ); - } - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - PreviewMaterial.SetVector( m_maskId, m_maskValue ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedOutputType ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs.meta deleted file mode 100644 index c442e367..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/DynamicAppendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bc524cd13743b6f49a2e331767646448 -timeCreated: 1500632879 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs deleted file mode 100644 index 7cb2a329..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs +++ /dev/null @@ -1,393 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// http://kylehalladay.com/blog/tutorial/2014/02/18/Fresnel-Shaders-From-The-Ground-Up.html -// http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter07.html - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Fresnel", "Surface Data", "Simple Fresnel effect" )] - public sealed class FresnelNode : ParentNode - { - private const string FresnedFinalVar = "fresnelNode"; - - [SerializeField] - private ViewSpace m_normalSpace = ViewSpace.Tangent; - - enum FresnelType - { - Standard = 0, - Schlick, - SchlickIOR, - } - - enum NormalType - { - WorldNormal = 0, - TangentNormal, - HalfVector, - } - - enum ViewType - { - ViewDir = 0, - LightDir, - } - - [SerializeField] - private FresnelType m_fresnelType = FresnelType.Standard; - - [SerializeField] - private NormalType m_normalType = NormalType.WorldNormal; - - [SerializeField] - private ViewType m_viewType = ViewType.ViewDir; - - [SerializeField] - private bool m_normalizeVectors = false; - - [SerializeField] - private bool m_safePower = false; - - private InputPort m_normalVecPort; - private InputPort m_viewVecPort; - private InputPort m_biasPort; - private InputPort m_scalePort; - private InputPort m_powerPort; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "World Normal", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT3, false, "View Dir", -1, MasterNodePortCategory.Fragment, 4 ); - AddInputPort( WirePortDataType.FLOAT, false, "Bias", -1, MasterNodePortCategory.Fragment, 1 ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, "Power", -1, MasterNodePortCategory.Fragment, 3 ); - AddOutputPort( WirePortDataType.FLOAT, "Out" ); - - m_normalVecPort = m_inputPorts[ 0 ]; - m_viewVecPort = m_inputPorts[ 1 ]; - m_biasPort = m_inputPorts[ 2 ]; - m_scalePort = m_inputPorts[ 3 ]; - m_powerPort = m_inputPorts[ 4 ]; - - m_biasPort.AutoDrawInternalData = true; - m_scalePort.AutoDrawInternalData = true; - m_powerPort.AutoDrawInternalData = true; - m_autoWrapProperties = true; - m_drawPreviewAsSphere = true; - m_normalVecPort.Vector3InternalData = Vector3.forward; - m_scalePort.FloatInternalData = 1; - m_powerPort.FloatInternalData = 5; - m_previewShaderGUID = "240145eb70cf79f428015012559f4e7d"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - //m_mate - PreviewMaterial.SetInt( "_FresnelType", (int)m_fresnelType ); - - if( m_normalType == NormalType.TangentNormal && m_normalVecPort.IsConnected ) - m_previewMaterialPassId = 2; - else if( (m_normalType == NormalType.WorldNormal || m_normalType == NormalType.HalfVector ) && m_normalVecPort.IsConnected && !m_viewVecPort.IsConnected ) - m_previewMaterialPassId = 1; - else if( m_normalType == NormalType.HalfVector && !m_normalVecPort.IsConnected && !m_viewVecPort.IsConnected ) - m_previewMaterialPassId = 3; - else if( m_normalVecPort.IsConnected && m_viewVecPort.IsConnected ) - m_previewMaterialPassId = 4; - else if( !m_normalVecPort.IsConnected && !m_viewVecPort.IsConnected && m_viewType == ViewType.LightDir ) - m_previewMaterialPassId = 5; - else if( !m_normalVecPort.IsConnected && m_viewVecPort.IsConnected && m_normalType == NormalType.HalfVector ) - m_previewMaterialPassId = 7; - else if( !m_normalVecPort.IsConnected && m_viewVecPort.IsConnected ) - m_previewMaterialPassId = 6; - else - m_previewMaterialPassId = 0; - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_fresnelType = (FresnelType)EditorGUILayoutEnumPopup( "Type", m_fresnelType ); - m_normalType = (NormalType)EditorGUILayoutEnumPopup( "Normal Vector", m_normalType ); - m_viewType = (ViewType)EditorGUILayoutEnumPopup( "View Vector", m_viewType ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePort(); - } - - if( !m_biasPort.IsConnected && m_biasPort.Visible ) - m_biasPort.FloatInternalData = EditorGUILayoutFloatField( m_biasPort.Name, m_biasPort.FloatInternalData ); - if( !m_scalePort.IsConnected && m_scalePort.Visible ) - m_scalePort.FloatInternalData = EditorGUILayoutFloatField( m_scalePort.Name, m_scalePort.FloatInternalData ); - if( !m_powerPort.IsConnected && m_powerPort.Visible ) - m_powerPort.FloatInternalData = EditorGUILayoutFloatField( m_powerPort.Name, m_powerPort.FloatInternalData ); - - m_normalizeVectors = EditorGUILayoutToggle( "Normalize Vectors", m_normalizeVectors ); - m_safePower = EditorGUILayoutToggle( PowerNode.SafePowerLabel, m_safePower ); - } - - private void UpdatePort() - { - switch( m_normalType ) - { - default: - case NormalType.WorldNormal: - m_normalVecPort.Name = "World Normal"; - break; - case NormalType.TangentNormal: - m_normalVecPort.Name = "Normal"; - break; - case NormalType.HalfVector: - m_normalVecPort.Name = "Half Vector"; - break; - } - - switch( m_viewType ) - { - default: - case ViewType.ViewDir: - m_viewVecPort.Name = "View Dir"; - break; - case ViewType.LightDir: - m_viewVecPort.Name = "Light Dir"; - break; - } - - switch( m_fresnelType ) - { - default: - case FresnelType.Standard: - m_biasPort.Visible = true; - m_biasPort.Name = "Bias"; - m_scalePort.Name = "Scale"; - m_scalePort.Visible = true; - m_powerPort.Visible = true; - break; - case FresnelType.Schlick: - m_biasPort.Visible = true; - m_biasPort.Name = "F0"; - m_scalePort.Visible = false; - m_powerPort.Visible = false; - break; - case FresnelType.SchlickIOR: - m_biasPort.Visible = false; - m_scalePort.Name = "IOR"; - m_scalePort.Visible = true; - m_powerPort.Visible = false; - break; - } - - m_sizeIsDirty = true; - } - - 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 ); - - if( dataCollector.IsFragmentCategory ) - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ); - - string viewdir = string.Empty; - if( m_viewType == ViewType.ViewDir ) - { - if( m_viewVecPort.IsConnected ) - viewdir = m_viewVecPort.GeneratePortInstructions( ref dataCollector ); - else - viewdir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.World ); - } - else - { - if( m_viewVecPort.IsConnected ) - viewdir = m_viewVecPort.GeneratePortInstructions( ref dataCollector ); - else - viewdir = GeneratorUtils.GenerateWorldLightDirection( ref dataCollector, UniqueId, CurrentPrecisionType ); - } - - string normal = string.Empty; - if( m_normalType == NormalType.WorldNormal || m_normalType == NormalType.TangentNormal ) - { - if( m_normalVecPort.IsConnected ) - { - normal = m_normalVecPort.GeneratePortInstructions( ref dataCollector ); - - if( dataCollector.IsFragmentCategory ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - - if( m_normalType == NormalType.TangentNormal ) - { - if( dataCollector.IsTemplate ) - { - normal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, CurrentPrecisionType, normal, OutputId ); - } - else - { - normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, CurrentPrecisionType, normal, OutputId ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.ForceNormal = true; - } - } - else - { - if( m_normalizeVectors ) - normal = string.Format( "normalize( {0} )", normal ); - } - } - else - { - if( m_normalType == NormalType.TangentNormal ) - { - string wtMatrix = GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType ); - normal = "mul( " + normal + "," + wtMatrix + " )"; - } - } - } - else - { - if( dataCollector.IsFragmentCategory ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - if( dataCollector.DirtyNormal ) - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - if( dataCollector.IsTemplate ) - normal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( CurrentPrecisionType, normalize: ( dataCollector.DirtyNormal && m_normalizeVectors ) ); - else - normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId, ( dataCollector.DirtyNormal && m_normalizeVectors ) ); - - if( dataCollector.DirtyNormal ) - { - dataCollector.ForceNormal = true; - } - } - } - else - { - // generate HV - if( !m_normalVecPort.IsConnected ) - { - string halfView = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.World ); - string halfLight = GeneratorUtils.GenerateWorldLightDirection( ref dataCollector, UniqueId, CurrentPrecisionType ); - normal = "halfVector" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT3, normal, "normalize( " + halfView + " + " + halfLight + " )" ); - } - else - { - normal = m_normalVecPort.GeneratePortInstructions( ref dataCollector ); - if( m_normalizeVectors ) - normal = string.Format( "normalize( {0} )", normal ); - } - } - - string bias = m_biasPort.GeneratePortInstructions( ref dataCollector ); - string scale = m_scalePort.GeneratePortInstructions( ref dataCollector ); - string power = m_powerPort.GeneratePortInstructions( ref dataCollector ); - - string fresnelNDotVLocalValue = "dot( " + normal + ", " + viewdir + " )"; - string fresnelNDotVLocalVar = "fresnelNdotV" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, fresnelNDotVLocalVar, fresnelNDotVLocalValue ); - - string fresnelFinalVar = FresnedFinalVar + OutputId; - - string result = string.Empty; - switch( m_fresnelType ) - { - default: - case FresnelType.Standard: - { - string powOp = m_safePower? string.Format( "pow( max( 1.0 - {0} , 0.0001 ), {1} )", fresnelNDotVLocalVar, power ): - string.Format( "pow( 1.0 - {0}, {1} )", fresnelNDotVLocalVar, power ); - result = string.Format( "( {0} + {1} * {2} )", bias, scale, powOp ); - } - break; - case FresnelType.Schlick: - { - string f0VarName = "f0" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, f0VarName, bias ); - string powOp = m_safePower? string.Format( "pow( max( 1.0 - {0} , 0.0001 ), 5 )", fresnelNDotVLocalVar ) : - string.Format( "pow( 1.0 - {0}, 5 )", fresnelNDotVLocalVar ); - result = string.Format( "( {0} + ( 1.0 - {0} ) * {1} )", f0VarName, powOp ); - } - break; - case FresnelType.SchlickIOR: - { - string iorVarName = "ior" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT, iorVarName, scale ); - string iorPowOp = m_safePower? string.Format( "pow( max( ( 1 - {0} ) / ( 1 + {0} ) , 0.0001 ), 2 )", iorVarName ): - string.Format( "pow( ( 1 - {0} ) / ( 1 + {0} ), 2 )", iorVarName ); - - dataCollector.AddLocalVariable( UniqueId, iorVarName +" = "+ iorPowOp + ";"); - - string fresnelPowOp = m_safePower? string.Format( "pow( max( 1.0 - {0} , 0.0001 ), 5 )", fresnelNDotVLocalVar ): - string.Format( "pow( 1.0 - {0}, 5 )", fresnelNDotVLocalVar ); - result = string.Format( "( {0} + ( 1.0 - {0} ) * {1} )", iorVarName, fresnelPowOp ); - } - break; - } - - RegisterLocalVariable( 0, result, ref dataCollector, fresnelFinalVar ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( m_normalType == NormalType.TangentNormal && m_normalVecPort.IsConnected ) - dataCollector.DirtyNormal = true; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - - if( UIUtils.CurrentShaderVersion() > 15305 ) - { - m_fresnelType = (FresnelType)Enum.Parse( typeof( FresnelType ), GetCurrentParam( ref nodeParams ) ); - m_normalType = (NormalType)Enum.Parse( typeof( NormalType ), GetCurrentParam( ref nodeParams ) ); - m_viewType = (ViewType)Enum.Parse( typeof( ViewType ), GetCurrentParam( ref nodeParams ) ); - m_normalizeVectors = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 17502 ) - m_safePower = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - else - { - if( UIUtils.CurrentShaderVersion() >= 13202 ) - { - m_normalSpace = (ViewSpace)Enum.Parse( typeof( ViewSpace ), GetCurrentParam( ref nodeParams ) ); - } - else - { - m_normalSpace = ViewSpace.World; - } - - if( m_normalSpace == ViewSpace.World ) - m_normalType = NormalType.WorldNormal; - else - m_normalType = NormalType.TangentNormal; - } - UpdatePort(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_fresnelType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_viewType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_normalizeVectors ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_safePower ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs.meta deleted file mode 100644 index 54876f82..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/FresnelNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 91955bc593b0dc14d90b10cb3eb25355 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs deleted file mode 100644 index 7a5b54f2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs +++ /dev/null @@ -1,430 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Get Local Var", "Miscellaneous", "Use a registered local variable", null, KeyCode.G )] - public class GetLocalVarNode : ParentNode - { - [SerializeField] - private int m_referenceId = -1; - - [SerializeField] - private float m_referenceWidth = -1; - - [SerializeField] - private int m_nodeId = -1; - - [SerializeField] - private RegisterLocalVarNode m_currentSelected = null; - - [SerializeField] - private string m_registerLocalVarName = string.Empty; - - private int m_cachedPropertyId = -1; - - private string m_previousLabel = string.Empty; - - private bool m_refSelect = false; - private int m_prevReferenceId = -1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue ); - - // This is needed for infinite loop detection - AddInputPort( WirePortDataType.OBJECT, false, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].Visible = false; - - m_outputPorts[ 0 ].Locked = true; - m_textLabelWidth = 80; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "f21a6e44c7d7b8543afacd19751d24c6"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - - if( UniqueId > -1 ) - m_containerGraph.LocalVarNodes.OnReorderEventComplete += OnReorderEventComplete; - } - - private void OnReorderEventComplete() - { - if( m_currentSelected != null ) - { - m_referenceId = m_containerGraph.LocalVarNodes.GetNodeRegisterIdx( m_currentSelected.UniqueId ); - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_currentSelected != null ) - { - if( m_drawPreviewAsSphere != m_currentSelected.SpherePreview ) - { - m_drawPreviewAsSphere = m_currentSelected.SpherePreview; - OnNodeChange(); - } - //CheckSpherePreview(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_A" ); - - PreviewMaterial.SetTexture( m_cachedPropertyId, m_currentSelected.OutputPorts[ 0 ].OutputPreviewTexture ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginHorizontal(); - EditorGUI.BeginChangeCheck(); - m_referenceId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceId, UIUtils.LocalVarNodeArr() ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromSelected(); - } - - if( GUILayout.Button( "\u25C4", "minibutton", GUILayout.Width( 17 ) ) && m_currentSelected ) - { - UIUtils.FocusOnNode( m_currentSelected, 0, false ); - } - EditorGUILayout.EndHorizontal(); - //EditorGUILayout.LabelField( ConnStatus.ToString() + " " + m_activeConnections ); - } - - public override void Destroy() - { - base.Destroy(); - CurrentSelected = null; - if( UniqueId > -1 ) - m_containerGraph.LocalVarNodes.OnReorderEventComplete -= OnReorderEventComplete; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_dropdownEditing ) - { - EditorGUI.BeginChangeCheck(); - m_referenceId = EditorGUIPopup( m_dropdownRect, m_referenceId, UIUtils.LocalVarNodeArr(), UIUtils.PropertyPopUp ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromSelected(); - DropdownEditing = false; - } - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - UpdateLocalVar(); - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( m_isVisible && m_refSelect && !m_selected ) - { - GUI.color = Constants.SpecialGetLocalVarSelectionColor; - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ) ); - GUI.color = m_colorBuffer; - } - } - - void CheckForLoops() - { - if( CurrentSelected != null && UIUtils.DetectNodeLoopsFrom( CurrentSelected, new Dictionary<int, int>() ) ) - { - CurrentSelected = UIUtils.GetLocalVarNode( m_prevReferenceId ); - if( CurrentSelected == null || UIUtils.DetectNodeLoopsFrom( CurrentSelected, new Dictionary<int, int>() ) ) - { - m_referenceId = -1; - m_prevReferenceId = -1; - CurrentSelected = null; - m_outputPorts[ 0 ].Locked = true; - SetAdditonalTitleText( "" ); - UIUtils.ShowMessage( "Infinite Loop detected, disabled selection" ); - } - else - { - m_referenceId = m_prevReferenceId; - UIUtils.ShowMessage( "Infinite Loop detected, reverted to previous selection" ); - } - } - } - - void UpdateFromSelected() - { - CurrentSelected = UIUtils.GetLocalVarNode( m_referenceId ); - CheckForLoops(); - - if( m_currentSelected != null ) - { - m_nodeId = m_currentSelected.UniqueId; - m_outputPorts[ 0 ].Locked = false; - m_outputPorts[ 0 ].ChangeType( m_currentSelected.OutputPorts[ 0 ].DataType, false ); - m_drawPreviewAsSphere = m_currentSelected.SpherePreview; - CheckSpherePreview(); - - m_previousLabel = m_currentSelected.DataToArray; - SetAdditonalTitleText( string.Format( Constants.SubTitleVarNameFormatStr, m_currentSelected.DataToArray ) ); - m_referenceWidth = m_currentSelected.Position.width; - } - - m_sizeIsDirty = true; - m_isDirty = true; - m_prevReferenceId = m_referenceId; - } - - void UpdateLocalVar() - { - m_refSelect = false; - if( m_referenceId > -1 ) - { - ParentNode newNode = UIUtils.GetLocalVarNode( m_referenceId ); - if( newNode != null ) - { - if( newNode.UniqueId != m_nodeId ) - { - CurrentSelected = null; - int count = UIUtils.LocalVarNodeAmount(); - for( int i = 0; i < count; i++ ) - { - ParentNode node = UIUtils.GetLocalVarNode( i ); - if( node.UniqueId == m_nodeId ) - { - CurrentSelected = node as RegisterLocalVarNode; - m_referenceId = i; - break; - } - } - } - } - - if( m_currentSelected != null ) - { - if( m_currentSelected.OutputPorts[ 0 ].DataType != m_outputPorts[ 0 ].DataType ) - { - m_outputPorts[ 0 ].Locked = false; - m_outputPorts[ 0 ].ChangeType( m_currentSelected.OutputPorts[ 0 ].DataType, false ); - } - - if( !m_previousLabel.Equals( m_currentSelected.DataToArray ) ) - { - m_previousLabel = m_currentSelected.DataToArray; - SetAdditonalTitleText( string.Format( Constants.SubTitleVarNameFormatStr, m_currentSelected.DataToArray ) ); - } - - if( m_referenceWidth != m_currentSelected.Position.width ) - { - m_referenceWidth = m_currentSelected.Position.width; - m_sizeIsDirty = true; - } - - if( m_currentSelected.Selected ) - m_refSelect = true; - } - else - { - ResetReference(); - } - } - } - - public void ResetReference() - { - m_outputPorts[ 0 ].Locked = true; - m_currentSelected = null; - m_inputPorts[ 0 ].DummyClear(); - m_nodeId = -1; - m_referenceId = -1; - m_referenceWidth = -1; - SetAdditonalTitleText( string.Empty ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_currentSelected != null ) - { - return m_currentSelected.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - else - { - UIUtils.ShowMessage( UniqueId, "Get Local Var node without reference. Attempting to access inexistant local variable.", MessageSeverity.Error ); - - return m_outputPorts[ 0 ].ErrorValue; - } - } - - - //public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - //{ - // base.PropagateNodeData( nodeData, ref dataCollector ); - // if( m_currentSelected != null ) - // { - // m_currentSelected.PropagateNodeData( nodeData, ref dataCollector ); - // } - //} - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 15 ) - { - m_nodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_outputPorts[ 0 ].Locked = ( m_nodeId < 0 ); - if( UIUtils.CurrentShaderVersion() > 15500 ) - { - m_registerLocalVarName = GetCurrentParam( ref nodeParams ); - } - } - else - { - m_referenceId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_outputPorts[ 0 ].Locked = ( m_referenceId < 0 ); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - if( m_currentSelected != null ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentSelected.UniqueId ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentSelected.DataToArray ); - } - else - { - IOUtils.AddFieldValueToString( ref nodeInfo, -1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, string.Empty ); - } - - } - - public override void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - if( m_currentSelected != null ) - { - UIUtils.FocusOnNode( m_currentSelected, 0, true ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( UIUtils.CurrentShaderVersion() > 15 ) - { - CurrentSelected = UIUtils.GetNode( m_nodeId ) as RegisterLocalVarNode; - m_referenceId = UIUtils.GetLocalVarNodeRegisterId( m_nodeId ); - if( CurrentSelected == null && UIUtils.CurrentShaderVersion() > 15500 && !string.IsNullOrEmpty( m_registerLocalVarName ) ) - { - CurrentSelected = m_containerGraph.LocalVarNodes.GetNodeByDataToArray( m_registerLocalVarName ); - if( CurrentSelected != null ) - { - m_nodeId = CurrentSelected.UniqueId; - m_referenceId = UIUtils.GetLocalVarNodeRegisterId( m_nodeId ); - } - } - } - else - { - CurrentSelected = UIUtils.GetLocalVarNode( m_referenceId ); - if( m_currentSelected != null ) - { - m_nodeId = m_currentSelected.UniqueId; - } - } - - CheckForLoops(); - - if( m_currentSelected != null ) - { - m_outputPorts[ 0 ].Locked = false; - m_outputPorts[ 0 ].ChangeType( m_currentSelected.OutputPorts[ 0 ].DataType, false ); - } - else - { - m_outputPorts[ 0 ].Locked = true; - } - } - - public override void ActivateNode( int signalGenNodeId, int signalGenPortId, System.Type signalGenNodeType ) - { - base.ActivateNode( signalGenNodeId, signalGenPortId, signalGenNodeType ); - if( m_activeConnections == 1 ) - { - if( m_currentSelected != null ) - { - m_currentSelected.ActivateNode( signalGenNodeId, signalGenPortId, signalGenNodeType ); - } - } - } - - public override void DeactivateNode( int deactivatedPort, bool forceComplete ) - { - forceComplete = forceComplete || ( m_activeConnections == 1 ); - base.DeactivateNode( deactivatedPort, forceComplete ); - if( forceComplete && m_currentSelected != null ) - { - m_currentSelected.DeactivateNode( deactivatedPort, false ); - } - } - - public override void OnNodeSelected( bool value ) - { - base.OnNodeSelected( value ); - if( m_currentSelected != null ) - { - m_currentSelected.CheckReferenceSelection(); - } - } - - public RegisterLocalVarNode CurrentSelected - { - get { return m_currentSelected; } - set - { - // This is needed for infinite loop detection - if( m_inputPorts != null ) - m_inputPorts[ 0 ].DummyClear(); - - if( m_currentSelected != null ) - { - m_currentSelected.UnregisterGetLocalVar( this ); - - //if( m_currentSelected != value ) - m_currentSelected.DeactivateNode( 0, false ); - } - - if( value != null ) - { - value.RegisterGetLocalVar( this ); - if( IsConnected && value != m_currentSelected ) - value.ActivateNode( UniqueId, 0, m_activeType ); - - // This is needed for infinite loop detection - m_inputPorts[ 0 ].DummyAdd( value.UniqueId, 0 ); ; - } - - m_currentSelected = value; - - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs.meta deleted file mode 100644 index 9b80adde..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/GetLocalVarNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: efce529ed3c74854b9d0cece836991c3 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs deleted file mode 100644 index 21589b00..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Layered Blend", "Miscellaneous", "Mix all channels through interpolation factors", null, KeyCode.None, true )] - public sealed class LayeredBlendNode : WeightedAvgNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 1 ].Name = "Layer Base"; - AddInputPort( WirePortDataType.FLOAT, false, string.Empty ); - for ( int i = 2; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].Name = AmountsStr[ i - 2 ]; - } - m_inputData = new string[ 6 ]; - m_minimumSize = 2; - UpdateConnection( 0 ); - m_previewShaderGUID = "48faca2f6506fc44c97adb1e2b79c37d"; - } - - 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 ); - - GetInputData( ref dataCollector, ignoreLocalvar ); - - string result = string.Empty; - string localVarName = "layeredBlendVar" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, localVarName, m_inputData[ 0 ] ); - - if ( m_activeCount == 1 ) - { - result = m_inputData[ 0 ]; - } - else if ( m_activeCount == 2 ) - { - result += "lerp( " + m_inputData[ 1 ] + "," + m_inputData[ 2 ] + " , " + localVarName + " )"; - } - else - { - result = m_inputData[ 1 ]; - for ( int i = 1; i < m_activeCount; i++ ) - { - result = "lerp( " + result + " , " + m_inputData[ i + 1 ] + " , " + localVarName + Constants.VectorSuffixes[ i - 1 ] + " )"; - } - } - result = UIUtils.AddBrackets( result ); - RegisterLocalVariable( 0, result, ref dataCollector, "layeredBlend" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs.meta deleted file mode 100644 index bcfcd292..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LayeredBlendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 90801da82a0b4f74cae2f9387bd5ad92 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs deleted file mode 100644 index 0193bbc9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Linear Depth", "Miscellaneous", "Converts depth values given on logarithmic space to linear" )] - public sealed class LinearDepthNode : ParentNode - { - private readonly string[] LinearModeLabels = { "Eye Space", "0-1 Space" }; - - private const string LinearEyeFuncFormat = "LinearEyeDepth({0})"; - private const string Linear01FuncFormat = "Linear01Depth({0})"; - private const string LinerValName = "depthToLinear"; - private const string ViewSpaceLabel = "View Space"; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - [SerializeField] - private int m_currentOption = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "2b0785cc8b854974ab4e45419072705a"; - UpdateFromOption(); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - void UpdateFromOption() - { - m_previewMaterialPassId = m_currentOption; - SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, LinearModeLabels[ m_currentOption ] ) ); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_currentOption = m_upperLeftWidget.DrawWidget( this, m_currentOption, LinearModeLabels ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateFromOption(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_currentOption = EditorGUILayoutPopup( ViewSpaceLabel, m_currentOption, LinearModeLabels ); - if( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleSpaceFormatStr, LinearModeLabels[ m_currentOption ] ) ); - } - } - - 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 ); - - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - value = string.Format( (( m_currentOption == 0 ) ? LinearEyeFuncFormat : Linear01FuncFormat), value ); - RegisterLocalVariable( 0, value, ref dataCollector, LinerValName + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentOption ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - int.TryParse( GetCurrentParam( ref nodeParams ), out m_currentOption ); - UpdateFromOption(); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs.meta deleted file mode 100644 index 490856d4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/LinearDepthNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8b8af65130c9ed64f95976ec67ac1adf -timeCreated: 1546438982 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs deleted file mode 100644 index af6325bc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs +++ /dev/null @@ -1,215 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Matrix From Vectors", "Matrix Operators", "Matrix From Vectors" )] - public sealed class MatrixFromVectors : ParentNode - { - private const string RowFromVector = "Input to Row"; - [SerializeField] - private WirePortDataType m_selectedOutputType = WirePortDataType.FLOAT3x3; - - [SerializeField] - private int m_selectedOutputTypeInt = 0; - - [SerializeField] - private Vector3[] m_defaultValuesV3 = { Vector3.zero, Vector3.zero, Vector3.zero }; - - [SerializeField] - private Vector4[] m_defaultValuesV4 = { Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero }; - - [SerializeField] - private bool m_rowsFromVector = true; - - private string[] m_defaultValuesStr = { "[0]", "[1]", "[2]", "[3]" }; - - private readonly string[] _outputValueTypes ={ "Matrix3X3", - "Matrix4X4"}; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, "[0]" ); - AddInputPort( WirePortDataType.FLOAT4, false, "[1]" ); - AddInputPort( WirePortDataType.FLOAT4, false, "[2]" ); - AddInputPort( WirePortDataType.FLOAT4, false, "[3]" ); - AddOutputPort( m_selectedOutputType, Constants.EmptyPortValue ); - m_textLabelWidth = 90; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - UpdatePorts(); - } - - 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_selectedOutputTypeInt = m_upperLeftWidget.DrawWidget( this, m_selectedOutputTypeInt, _outputValueTypes ); - if( EditorGUI.EndChangeCheck() ) - { - switch( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT3x3; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT4x4; break; - } - - UpdatePorts(); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUILayoutPopup( "Output type", m_selectedOutputTypeInt, _outputValueTypes ); - if( EditorGUI.EndChangeCheck() ) - { - switch( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT3x3; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT4x4; break; - } - - UpdatePorts(); - } - - int count = 0; - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT3x3: - count = 3; - for( int i = 0; i < count; i++ ) - { - if( !m_inputPorts[ i ].IsConnected ) - m_defaultValuesV3[ i ] = EditorGUILayoutVector3Field( m_defaultValuesStr[ i ], m_defaultValuesV3[ i ] ); - } - break; - case WirePortDataType.FLOAT4x4: - count = 4; - for( int i = 0; i < count; i++ ) - { - if( !m_inputPorts[ i ].IsConnected ) - m_defaultValuesV4[ i ] = EditorGUILayoutVector4Field( m_defaultValuesStr[ i ], m_defaultValuesV4[ i ] ); - } - break; - } - m_rowsFromVector = EditorGUILayoutToggle( RowFromVector, m_rowsFromVector ); - } - - void UpdatePorts() - { - m_sizeIsDirty = true; - ChangeOutputType( m_selectedOutputType, false ); - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT3x3: - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 3 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_inputPorts[ 3 ].Visible = false; - break; - case WirePortDataType.FLOAT4x4: - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 3 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 3 ].Visible = true; - break; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - string result = ""; - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT3x3: - if( m_rowsFromVector ) - { - result = "float3x3(" + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ", " - + m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ) + ", " - + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ) + ")"; - } - else - { - string vec0 = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string vec1 = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string vec2 = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - result = string.Format( "float3x3({0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z )", vec0, vec1, vec2 ); - } - break; - case WirePortDataType.FLOAT4x4: - if( m_rowsFromVector ) - { - result = "float4x4(" + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ", " - + m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ) + ", " - + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ) + ", " - + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ")"; - } - else - { - string vec0 = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string vec1 = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string vec2 = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string vec3 = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - result = string.Format( "float4x4( {0}.x,{1}.x,{2}.x,{3}.x,{0}.y,{1}.y,{2}.y,{3}.y,{0}.z,{1}.z,{2}.z,{3}.z,{0}.w,{1}.w,{2}.w,{3}.w )", vec0, vec1, vec2, vec3 ); - } - break; - } - - return result; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedOutputType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15310 ) - { - m_rowsFromVector = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - switch( m_selectedOutputType ) - { - case WirePortDataType.FLOAT3x3: - m_selectedOutputTypeInt = 0; - break; - case WirePortDataType.FLOAT4x4: - m_selectedOutputTypeInt = 1; - break; - } - UpdatePorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedOutputType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_rowsFromVector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs.meta deleted file mode 100644 index 25231848..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/MatrixFromVectors.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a313774cf0e4d1e4289d7395e8e49067 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs deleted file mode 100644 index 41a14788..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Position From Transform", "Matrix Operators", "Gets the position vector from a transformation matrix" )] - public sealed class PosFromTransformMatrix : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4x4, true, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT4, "XYZW" ); - AddOutputPort( WirePortDataType.FLOAT, "X" ); - AddOutputPort( WirePortDataType.FLOAT, "Y" ); - AddOutputPort( WirePortDataType.FLOAT, "Z" ); - AddOutputPort( WirePortDataType.FLOAT, "W" ); - } - - 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 ) ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string result = string.Format( "float4( {0},{1},{2},{3})", value + "[3][0]", value + "[3][1]", value + "[3][2]", value + "[3][3]" ); - RegisterLocalVariable( 0, result, ref dataCollector, "matrixToPos" + OutputId ); - - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs.meta deleted file mode 100644 index 568be07a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/PosFromTransformMatrix.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7c7321a370f1f1b499d4655cc25f457b -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs deleted file mode 100644 index 15bf0313..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs +++ /dev/null @@ -1,346 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Register Local Var", "Miscellaneous", "Forces a local variable to be written with the given name. Can then be fetched at any place with a <b>Get Local Var</b> node.", null, KeyCode.R )] - public sealed class RegisterLocalVarNode : ParentNode - { - private const double MaxEditingTimestamp = 1; - - private const string LocalDefaultNameStr = "myVarName"; - private const string LocalVarNameStr = "Var Name"; - private const string OrderIndexStr = "Order Index"; - private const string AutoOrderIndexStr = "Auto Order"; - private const string ReferencesStr = "References"; - - private const string GetLocalVarLabel = "( {0} ) Get Local Var"; - private string m_oldName = string.Empty; - private bool m_reRegisterName = false; - private int m_autoOrderIndex = int.MaxValue; - private bool m_forceUpdate = true; - private bool m_refSelect = false; - - private bool m_referencesVisible = false; - - [SerializeField] - private string m_variableName = LocalDefaultNameStr; - - [SerializeField] - private int m_orderIndex = -1; - - [SerializeField] - private bool m_autoIndexActive = true; - - [SerializeField] - private List<GetLocalVarNode> m_registeredGetLocalVars = new List<GetLocalVarNode>(); - - [NonSerialized] - private double m_editingTimestamp; - - [NonSerialized] - private bool m_editingTimestampFlag; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 85; - m_customPrecision = true; - - if( m_containerGraph != null ) - m_variableName += m_containerGraph.LocalVarNodes.NodesList.Count; - - m_oldName = m_variableName; - UpdateTitle(); - m_previewShaderGUID = "5aaa1d3ea9e1fa64781647e035a82334"; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_containerGraph.LocalVarNodes.AddNode( this ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - void UpdateTitle() - { - SetAdditonalTitleText( string.Format( Constants.SubTitleVarNameFormatStr, m_variableName ) ); - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - if( m_editingTimestampFlag && ( EditorApplication.timeSinceStartup - m_editingTimestamp ) > MaxEditingTimestamp ) - { - m_editingTimestampFlag = false; - CheckAndChangeName(); - } - } - - void DrawMainProperties() - { - EditorGUI.BeginChangeCheck(); - m_variableName = EditorGUILayoutTextField( LocalVarNameStr, m_variableName ); - if( EditorGUI.EndChangeCheck() ) - { - m_editingTimestampFlag = true; - m_editingTimestamp = EditorApplication.timeSinceStartup; - //CheckAndChangeName(); - } - - DrawPrecisionProperty(); - } - - public override void AfterDuplication() - { - base.AfterDuplication(); - CheckAndChangeName(); - } - - void CheckAndChangeName() - { - m_variableName = UIUtils.RemoveInvalidCharacters( m_variableName ); - if( string.IsNullOrEmpty( m_variableName ) ) - { - m_variableName = LocalDefaultNameStr + OutputId; - } - bool isNumericName = UIUtils.IsNumericName( m_variableName ); - bool isLocalVarNameAvailable = m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.IsLocalvariableNameAvailable( m_variableName ); - if( !isNumericName && isLocalVarNameAvailable ) - { - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.ReleaseLocalVariableName( UniqueId, m_oldName ); - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.RegisterLocalVariableName( UniqueId, m_variableName ); - m_oldName = m_variableName; - m_containerGraph.LocalVarNodes.UpdateDataOnNode( UniqueId, m_variableName ); - UpdateTitle(); - m_forceUpdate = true; - } - else - { - if( isNumericName ) - { - UIUtils.ShowMessage( UniqueId, string.Format( "Local variable name '{0}' cannot start or be numerical values. Reverting back to '{1}'.", m_variableName, m_oldName ), MessageSeverity.Warning ); - } - else if( !isLocalVarNameAvailable ) - { - UIUtils.ShowMessage( UniqueId, string.Format( "Local variable name '{0}' already being used. Reverting back to '{1}'.", m_variableName, m_oldName ), MessageSeverity.Warning ); - } - - m_variableName = m_oldName; - m_containerGraph.LocalVarNodes.UpdateDataOnNode( UniqueId, m_variableName ); - } - } - - void DrawReferences() - { - int count = m_registeredGetLocalVars.Count; - if( m_registeredGetLocalVars.Count > 0 ) - { - for( int i = 0; i < count; i++ ) - { - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField( string.Format( GetLocalVarLabel, m_registeredGetLocalVars[ i ].UniqueId ) ); - if( GUILayout.Button( "\u25BA", "minibutton", GUILayout.Width( 17 ) ) ) - { - m_containerGraph.ParentWindow.FocusOnNode( m_registeredGetLocalVars[ i ], 0, false ); - } - EditorGUILayout.EndHorizontal(); - } - - if( GUILayout.Button( "Back" ) ) - { - m_containerGraph.ParentWindow.FocusOnNode( this, 0, false ); - } - } - else - { - EditorGUILayout.HelpBox( "This node is not being referenced by any Get Local Var.", MessageType.Info ); - } - } - - public override void DrawProperties() - { - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawMainProperties ); - NodeUtils.DrawPropertyGroup( ref m_referencesVisible, ReferencesStr, DrawReferences ); - //EditorGUILayout.LabelField(ConnStatus.ToString()+" "+m_activeConnections); - } - - public override void OnEnable() - { - base.OnEnable(); - m_reRegisterName = true; - } - - public void CheckReferenceSelection() - { - m_refSelect = false; - int count = m_registeredGetLocalVars.Count; - for( int i = 0; i < count; i++ ) - { - if( m_registeredGetLocalVars[ i ].Selected ) - m_refSelect = true; - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - if( m_isVisible && m_refSelect && !m_selected ) - { - GUI.color = Constants.SpecialRegisterLocalVarSelectionColor; - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ) ); - GUI.color = m_colorBuffer; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - - base.Draw( drawInfo ); - if( m_reRegisterName ) - { - m_reRegisterName = false; - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.RegisterLocalVariableName( UniqueId, m_variableName ); - } - - if( m_forceUpdate ) - { - m_forceUpdate = false; - UpdateTitle(); - } - } - - 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 result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_inputPorts[ 0 ].DataType == WirePortDataType.OBJECT ) - m_outputPorts[ 0 ].SetLocalValue( result, dataCollector.PortCategory ); - else - RegisterLocalVariable( 0, result, ref dataCollector, m_variableName + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_variableName = GetCurrentParam( ref nodeParams ); - m_oldName = m_variableName; - if( UIUtils.CurrentShaderVersion() > 14 ) - m_orderIndex = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - if( UIUtils.CurrentShaderVersion() > 3106 ) - { - m_autoIndexActive = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - else - { - m_autoIndexActive = false; - } - if( !m_isNodeBeingCopied ) - { - m_containerGraph.LocalVarNodes.UpdateDataOnNode( UniqueId, m_variableName ); - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.ReleaseLocalVariableName( UniqueId, m_oldName ); - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.RegisterLocalVariableName( UniqueId, m_variableName ); - } - m_forceUpdate = true; - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_variableName ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_orderIndex ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoIndexActive ); - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - if( m_autoOrderIndex < nodeData.OrderIndex ) - { - nodeData.OrderIndex = m_autoOrderIndex - 1; - } - else - { - m_autoOrderIndex = nodeData.OrderIndex; - nodeData.OrderIndex -= 1; - } - - base.PropagateNodeData( nodeData, ref dataCollector ); - } - - public override void ResetNodeData() - { - base.ResetNodeData(); - m_autoOrderIndex = int.MaxValue; - } - - public void RegisterGetLocalVar( GetLocalVarNode node ) - { - if( !m_registeredGetLocalVars.Contains( node ) ) - { - m_registeredGetLocalVars.Add( node ); - CheckReferenceSelection(); - } - } - - public void UnregisterGetLocalVar( GetLocalVarNode node ) - { - if( m_registeredGetLocalVars.Contains( node ) ) - { - m_registeredGetLocalVars.Remove( node ); - CheckReferenceSelection(); - } - } - - public override void Destroy() - { - base.Destroy(); - m_containerGraph.LocalVarNodes.RemoveNode( this ); - m_containerGraph.ParentWindow.DuplicatePrevBufferInstance.ReleaseLocalVariableName( UniqueId, m_variableName ); - - int count = m_registeredGetLocalVars.Count; - for( int i = 0; i < count; i++ ) - { - //GetLocalVarNode node = m_containerGraph.GetNode( m_registeredGetLocalVars[ i ] ) as GetLocalVarNode; - if( m_registeredGetLocalVars[ i ] != null ) - m_registeredGetLocalVars[ i ].ResetReference(); - } - m_registeredGetLocalVars.Clear(); - m_registeredGetLocalVars = null; - - m_containerGraph.LocalVarNodes.RemoveNode( this ); - } - - public override void ActivateNode( int signalGenNodeId, int signalGenPortId, Type signalGenNodeType ) - { - base.ActivateNode( signalGenNodeId, signalGenPortId, signalGenNodeType ); - } - public override string DataToArray { get { return m_variableName; } } - public List<GetLocalVarNode> NodeReferences { get { return m_registeredGetLocalVars; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs.meta deleted file mode 100644 index 9cda9e54..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RegisterLocalVarNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ebd1a3b3014ccdd40b8fa805b4281c6f -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs deleted file mode 100644 index ab6df692..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Relay", "Miscellaneous", "Relay" )] - public sealed class RelayNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.OBJECT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue ); - m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs.meta deleted file mode 100644 index 378c2048..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RelayNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ef679ba7cdeda594aa3e5c02b25e66df -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs deleted file mode 100644 index b9b0a6c2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Rotate About Axis", "Vector Operators", "Rotates a vector around a normalized axis" )] - public class RotateAboutAxisNode : ParentNode - { - private const string FunctionHeader = "float3 RotateAroundAxis( float3 center, float3 original, float3 u, float angle )"; - private const string FunctionCall = "RotateAroundAxis( {0}, {1}, {2}, {3} )"; - private readonly string[] FunctionBody = - { - "float3 RotateAroundAxis( float3 center, float3 original, float3 u, float angle )\n", - "{\n", - "\toriginal -= center;\n", - "\tfloat C = cos( angle );\n", - "\tfloat S = sin( angle );\n", - "\tfloat t = 1 - C;\n", - "\tfloat m00 = t * u.x * u.x + C;\n", - "\tfloat m01 = t * u.x * u.y - S * u.z;\n", - "\tfloat m02 = t * u.x * u.z + S * u.y;\n", - "\tfloat m10 = t * u.x * u.y + S * u.z;\n", - "\tfloat m11 = t * u.y * u.y + C;\n", - "\tfloat m12 = t * u.y * u.z - S * u.x;\n", - "\tfloat m20 = t * u.x * u.z - S * u.y;\n", - "\tfloat m21 = t * u.y * u.z + S * u.x;\n", - "\tfloat m22 = t * u.z * u.z + C;\n", - "\tfloat3x3 finalMatrix = float3x3( m00, m01, m02, m10, m11, m12, m20, m21, m22 );\n", - "\treturn mul( finalMatrix, original ) + center;\n", - "}\n" - }; - - private const string NormalizeAxisLabel = "Rotation Axis"; - private const string NonNormalizeAxisLabel = "Normalized Rotation Axis"; - private const string NormalizeAxisStr = "Normalize Axis"; - - [UnityEngine.SerializeField] - private bool m_normalizeAxis = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, m_normalizeAxis? NormalizeAxisLabel: NonNormalizeAxisLabel ); - AddInputPort( WirePortDataType.FLOAT, false, "Rotation Angle" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Pivot Point" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Position" ); - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_normalizeAxis = EditorGUILayoutToggle( NormalizeAxisStr, m_normalizeAxis ); - if( EditorGUI.EndChangeCheck() ) - { - m_inputPorts[ 0 ].Name = (m_normalizeAxis ? NormalizeAxisLabel : NonNormalizeAxisLabel); - } - } - - 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 normalizeRotAxis = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_normalizeAxis ) - { - normalizeRotAxis = string.Format( "normalize( {0} )", normalizeRotAxis ); - } - string rotationAngle = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string pivotPoint = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string position = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddFunction( FunctionHeader, FunctionBody, false ); - RegisterLocalVariable( 0, string.Format( FunctionCall, pivotPoint, position, normalizeRotAxis, rotationAngle ), ref dataCollector, "rotatedValue" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_normalizeAxis = 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_normalizeAxis ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs.meta deleted file mode 100644 index f5af5b8d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/RotateAboutAxisNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6190b6c1a4cd29b48bfd36ff9b2ea773 -timeCreated: 1513184612 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs deleted file mode 100644 index 735bcd9a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Summed Blend", "Miscellaneous", "Mix all channels through weighted sum", null, KeyCode.None, true )] - public sealed class SummedBlendNode : WeightedAvgNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputData = new string[ 6 ]; - m_previewShaderGUID = "eda18b96e13f78b49bbdaa4da3fead19"; - } - - 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 ); - - GetInputData( ref dataCollector, ignoreLocalvar ); - - string result = string.Empty; - string localVarName = "weightedBlendVar" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, localVarName, m_inputData[ 0 ] ); - - if ( m_activeCount == 0 ) - { - result = m_inputData[ 0 ]; - } - else if ( m_activeCount == 1 ) - { - result += localVarName + "*" + m_inputData[ 1 ]; - } - else - { - for ( int i = 0; i < m_activeCount; i++ ) - { - result += localVarName + Constants.VectorSuffixes[ i ] + "*" + m_inputData[ i + 1 ]; - if ( i != ( m_activeCount - 1 ) ) - { - result += " + "; - } - } - } - - result = UIUtils.AddBrackets( result ); - RegisterLocalVariable( 0, result, ref dataCollector, "weightedBlend" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs.meta deleted file mode 100644 index 102a6f19..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SummedBlendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: da71cf021d98a7f468319e56eaefe6f1 -timeCreated: 1484229430 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs deleted file mode 100644 index ae3d4107..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs +++ /dev/null @@ -1,230 +0,0 @@ -// 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( "Debug Switch", "Logical Operators", "Hard Switch between any of its input ports" )] - public class SwitchNode : ParentNode - { - private const string Info = "This is a Debug node which only generates the source for the selected port. This means that no properties are generated for other ports and information might be lost."; - private const string InputPortName = "In "; - - private const string CurrSelectedStr = "Current"; - private const string MaxAmountStr = "Max Amount"; - private const int MaxAllowedAmount = 8; - - [SerializeField] - private string[] m_availableInputsLabels = { "In 0", "In 1" }; - - [SerializeField] - private int[] m_availableInputsValues = { 0, 1 }; - - [SerializeField] - private int m_currentSelectedInput = 0; - - [SerializeField] - private int m_maxAmountInputs = 2; - - private int m_cachedPropertyId = -1; - - private GUIContent m_popContent; - - private Rect m_varRect; - private Rect m_imgRect; - private bool m_editing; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - AddInputPort( WirePortDataType.FLOAT, false, InputPortName + i ); - m_inputPorts[ i ].Visible = ( i < 2 ); - } - AddOutputPort( WirePortDataType.FLOAT, " " ); - - m_popContent = new GUIContent(); - m_popContent.image = UIUtils.PopupIcon; - - m_insideSize.Set( 50, 25 ); - m_textLabelWidth = 100; - m_autoWrapProperties = false; - m_previewShaderGUID = "a58e46feaa5e3d14383bfeac24d008bc"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_Current" ); - - PreviewMaterial.SetInt( m_cachedPropertyId, m_currentSelectedInput ); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - m_inputPorts[ inputPortId ].MatchPortToConnection(); - if( inputPortId == m_currentSelectedInput ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ inputPortId ].DataType, false ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ portId ].MatchPortToConnection(); - if( portId == m_currentSelectedInput ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ portId ].DataType, false ); - } - - public void UpdateLabels() - { - m_availableInputsLabels = new string[ m_maxAmountInputs ]; - m_availableInputsValues = new int[ m_maxAmountInputs ]; - - for( int i = 0; i < m_maxAmountInputs; i++ ) - { - m_availableInputsLabels[ i ] = InputPortName + i; - m_availableInputsValues[ i ] = i; - } - } - - //void UpdateOutput() - //{ - // m_outputPorts[ 0 ].ChangeProperties( m_inputPorts[ m_currentSelectedInput ].Name, m_inputPorts[ m_currentSelectedInput ].DataType, false ); - // m_sizeIsDirty = true; - //} - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_varRect = m_remainingBox; - m_varRect.width = 50 * drawInfo.InvertedZoom; - m_varRect.height = 16 * drawInfo.InvertedZoom; - m_varRect.x = m_remainingBox.xMax - m_varRect.width; - //m_varRect.x += m_remainingBox.width * 0.5f - m_varRect.width * 0.5f; - m_varRect.y += 1 * drawInfo.InvertedZoom; - - m_imgRect = m_varRect; - m_imgRect.x = m_varRect.xMax - 16 * drawInfo.InvertedZoom; - m_imgRect.width = 16 * drawInfo.InvertedZoom; - m_imgRect.height = m_imgRect.width; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - if( m_varRect.Contains( drawInfo.MousePosition ) ) - { - m_editing = true; - } - else if( m_editing ) - { - m_editing = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_editing ) - { - EditorGUI.BeginChangeCheck(); - m_currentSelectedInput = EditorGUIIntPopup( m_varRect, m_currentSelectedInput, m_availableInputsLabels, m_availableInputsValues, UIUtils.GraphDropDown ); - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - m_editing = false; - } - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - if( !m_editing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - GUI.Label( m_varRect, m_availableInputsLabels[ m_currentSelectedInput ], UIUtils.GraphDropDown ); - GUI.Label( m_imgRect, m_popContent, UIUtils.GraphButtonIcon ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawDebugOptions ); - - EditorGUILayout.HelpBox( Info, MessageType.Warning ); - } - - void DrawDebugOptions() - { - EditorGUI.BeginChangeCheck(); - m_maxAmountInputs = EditorGUILayoutIntSlider( MaxAmountStr, m_maxAmountInputs, 2, MaxAllowedAmount ); - if( EditorGUI.EndChangeCheck() ) - { - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - UpdateLabels(); - m_sizeIsDirty = true; - } - - m_currentSelectedInput = EditorGUILayoutIntPopup( CurrSelectedStr, m_currentSelectedInput, m_availableInputsLabels, m_availableInputsValues ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - return m_inputPorts[ m_currentSelectedInput ].GeneratePortInstructions( ref dataCollector ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_currentSelectedInput = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_maxAmountInputs = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - - for( int i = 0; i < MaxAllowedAmount; i++ ) - { - m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ); - } - - if( m_currentSelectedInput >= m_maxAmountInputs ) - { - m_currentSelectedInput = m_maxAmountInputs - 1; - } - - UpdateLabels(); - m_sizeIsDirty = true; - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentSelectedInput ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_maxAmountInputs ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs.meta deleted file mode 100644 index 246aa75c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwitchNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ad88ed9f1b6010a4bb17685dec17a585 -timeCreated: 1483956795 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs deleted file mode 100644 index ec839517..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs +++ /dev/null @@ -1,441 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Swizzle -// Donated by Tobias Pott - @ Tobias Pott -// www.tobiaspott.de - -using System; -using UnityEditor; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Swizzle", "Vector Operators", "Swizzle components of vector types", null, KeyCode.Z, true, false, null, null, "Tobias Pott - @TobiasPott" )] - public sealed class SwizzleNode : SingleInputOp - { - - private const string OutputTypeStr = "Output type"; - - [SerializeField] - private WirePortDataType m_selectedOutputType = WirePortDataType.FLOAT4; - - [SerializeField] - private int m_selectedOutputTypeInt = 3; - - [SerializeField] - private int[] m_selectedOutputSwizzleTypes = new int[] { 0, 1, 2, 3 }; - - [SerializeField] - private int m_maskId; - - [SerializeField] - private Vector4 m_maskValue = Vector4.one; - - private readonly string[] SwizzleVectorChannels = { "x", "y", "z", "w" }; - private readonly string[] SwizzleColorChannels = { "r", "g", "b", "a" }; - private readonly string[] SwizzleChannelLabels = { "Channel 0", "Channel 1", "Channel 2", "Channel 3" }; - - private readonly string[] m_outputValueTypes ={ "Float", - "Vector 2", - "Vector 3", - "Vector 4"}; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - - - m_inputPorts[ 0 ].DataType = WirePortDataType.FLOAT4; - m_outputPorts[ 0 ].DataType = m_selectedOutputType; - m_textLabelWidth = 90; - m_autoWrapProperties = true; - m_autoUpdateOutputPort = false; - m_hasLeftDropdown = true; - m_previewShaderGUID = "d20531704ce28b14bafb296f291f6608"; - SetAdditonalTitleText( "Value( XYZW )" ); - CalculatePreviewData(); - } - - public override void OnEnable() - { - base.OnEnable(); - m_maskId = Shader.PropertyToID( "_Mask" ); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - PreviewMaterial.SetVector( m_maskId, m_maskValue ); - } - - void CalculatePreviewData() - { - switch( m_outputPorts[ 0 ].DataType ) - { - default: m_maskValue = Vector4.zero; break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: m_maskValue = new Vector4( 1, 0, 0, 0 ); break; - case WirePortDataType.FLOAT2: m_maskValue = new Vector4( 1, 1, 0, 0 ); break; - case WirePortDataType.FLOAT3: m_maskValue = new Vector4( 1, 1, 1, 0 ); break; - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: m_maskValue = Vector4.one; break; - } - - int inputMaxChannelId = 0; - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - inputMaxChannelId = 3; - break; - case WirePortDataType.FLOAT3: - inputMaxChannelId = 2; - break; - case WirePortDataType.FLOAT2: - inputMaxChannelId = 1; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - inputMaxChannelId = 0; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - m_previewMaterialPassId = -1; - float passValue = 0; - for( int i = 3; i > -1; i-- ) - { - int currentSwizzle = Mathf.Min( inputMaxChannelId, m_selectedOutputSwizzleTypes[ i ] ); - if( currentSwizzle > 0 ) - { - passValue += Mathf.Pow( 4, 3 - i ) * currentSwizzle; - } - } - - m_previewMaterialPassId = (int)passValue; - - if( m_previewMaterialPassId == -1 ) - { - m_previewMaterialPassId = 0; - if( DebugConsoleWindow.DeveloperMode ) - { - UIUtils.ShowMessage( UniqueId, "Could not find pass ID for swizzle", MessageSeverity.Error ); - } - } - } - - 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 OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - UpdatePorts(); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdatePorts(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdatePorts(); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( m_dropdownEditing ) - { - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUIPopup( m_dropdownRect, m_selectedOutputTypeInt, m_outputValueTypes, UIUtils.PropertyPopUp ); - if ( EditorGUI.EndChangeCheck() ) - { - switch ( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT2; break; - case 2: m_selectedOutputType = WirePortDataType.FLOAT3; break; - case 3: m_selectedOutputType = WirePortDataType.FLOAT4; break; - } - - UpdatePorts(); - DropdownEditing = false; - } - } - } - - public override void DrawProperties() - { - - EditorGUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - m_selectedOutputTypeInt = EditorGUILayoutPopup( OutputTypeStr, m_selectedOutputTypeInt, m_outputValueTypes ); - if ( EditorGUI.EndChangeCheck() ) - { - switch ( m_selectedOutputTypeInt ) - { - case 0: m_selectedOutputType = WirePortDataType.FLOAT; break; - case 1: m_selectedOutputType = WirePortDataType.FLOAT2; break; - case 2: m_selectedOutputType = WirePortDataType.FLOAT3; break; - case 3: m_selectedOutputType = WirePortDataType.FLOAT4; break; - } - - UpdatePorts(); - } - EditorGUILayout.EndVertical(); - - // Draw base properties - base.DrawProperties(); - - EditorGUILayout.BeginVertical(); - - int count = 0; - - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - count = 4; - break; - case WirePortDataType.FLOAT3: - count = 3; - break; - case WirePortDataType.FLOAT2: - count = 2; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - count = 1; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - EditorGUI.BeginChangeCheck(); - if ( m_inputPorts[ 0 ].DataType == WirePortDataType.COLOR ) - { - for ( int i = 0; i < count; i++ ) - { - m_selectedOutputSwizzleTypes[ i ] = EditorGUILayoutPopup( SwizzleChannelLabels[ i ], m_selectedOutputSwizzleTypes[ i ], SwizzleColorChannels ); - } - } - else - { - for ( int i = 0; i < count; i++ ) - { - m_selectedOutputSwizzleTypes[ i ] = EditorGUILayoutPopup( SwizzleChannelLabels[ i ], m_selectedOutputSwizzleTypes[ i ], SwizzleVectorChannels ); - } - } - if ( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - - EditorGUILayout.EndVertical(); - - } - - void UpdatePorts() - { - ChangeOutputType( m_selectedOutputType, false ); - - int count = 0; - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - count = 4; - break; - case WirePortDataType.FLOAT3: - count = 3; - break; - case WirePortDataType.FLOAT2: - count = 2; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - count = 1; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - int inputMaxChannelId = 0; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - inputMaxChannelId = 3; - break; - case WirePortDataType.FLOAT3: - inputMaxChannelId = 2; - break; - case WirePortDataType.FLOAT2: - inputMaxChannelId = 1; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - inputMaxChannelId = 0; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - //for ( int i = 0; i < count; i++ ) - //{ - //m_selectedOutputSwizzleTypes[ i ] = Mathf.Clamp( m_selectedOutputSwizzleTypes[ i ], 0, inputMaxChannelId ); - //} - - // Update Title - string additionalText = string.Empty; - for ( int i = 0; i < count; i++ ) - { - int currentSwizzle = Mathf.Min( inputMaxChannelId, m_selectedOutputSwizzleTypes[ i ] ); - additionalText += GetSwizzleComponentForChannel( currentSwizzle ).ToUpper(); - } - - if ( additionalText.Length > 0 ) - SetAdditonalTitleText( "Value( " + additionalText + " )" ); - else - SetAdditonalTitleText( string.Empty ); - - CalculatePreviewData(); - m_sizeIsDirty = true; - } - - public string GetSwizzleComponentForChannel( int channel ) - { - if ( m_inputPorts[ 0 ].DataType == WirePortDataType.COLOR ) - { - return SwizzleColorChannels[ channel ]; - } - else - { - return SwizzleVectorChannels[ channel ]; - } - } - - 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 = string.Format( "({0}).", m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) ); - - int inputMaxChannelId = 0; - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - inputMaxChannelId = 3; - break; - case WirePortDataType.FLOAT3: - inputMaxChannelId = 2; - break; - case WirePortDataType.FLOAT2: - inputMaxChannelId = 1; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - inputMaxChannelId = 0; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - int count = 0; - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - count = 4; - break; - case WirePortDataType.FLOAT3: - count = 3; - break; - case WirePortDataType.FLOAT2: - count = 2; - break; - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - count = 1; - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - break; - } - - for ( int i = 0; i < count; i++ ) - { - int currentSwizzle = Mathf.Min( inputMaxChannelId, m_selectedOutputSwizzleTypes[ i ] ); - value += GetSwizzleComponentForChannel( currentSwizzle ); - } - - return CreateOutputLocalVariable( 0, value, ref dataCollector ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedOutputType = ( WirePortDataType ) Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - switch ( m_selectedOutputType ) - { - case WirePortDataType.FLOAT: m_selectedOutputTypeInt = 0; break; - case WirePortDataType.FLOAT2: m_selectedOutputTypeInt = 1; break; - case WirePortDataType.FLOAT3: m_selectedOutputTypeInt = 2; break; - case WirePortDataType.COLOR: - case WirePortDataType.FLOAT4: m_selectedOutputTypeInt = 3; break; - } - for ( int i = 0; i < m_selectedOutputSwizzleTypes.Length; i++ ) - { - m_selectedOutputSwizzleTypes[ i ] = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - UpdatePorts(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedOutputType ); - for ( int i = 0; i < m_selectedOutputSwizzleTypes.Length; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedOutputSwizzleTypes[ i ] ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs.meta deleted file mode 100644 index 5049f92b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/SwizzleNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3bb41488b4b3e034d838c73c2eb471f5 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs deleted file mode 100644 index baa91b53..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs +++ /dev/null @@ -1,285 +0,0 @@ -// 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( "Toggle Switch", "Logical Operators", "Switch between any of its input ports" )] - public class ToggleSwitchNode : PropertyNode - { - private const string InputPortName = "In "; - private const string CurrSelectedStr = "Toggle Value"; - //private const string LerpOp = "lerp({0},{1},{2})"; - private const string LerpOp = "(( {2} )?( {1} ):( {0} ))"; - - [SerializeField] - private string[] AvailableInputsLabels = { "In 0", "In 1" }; - - [SerializeField] - private int[] AvailableInputsValues = { 0, 1 }; - - [SerializeField] - private int m_currentSelectedInput = 0; - - [SerializeField] - private WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - private int m_cachedPropertyId = -1; - - private GUIContent m_popContent; - - private Rect m_varRect; - private Rect m_imgRect; - private bool m_editing; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( m_mainDataType, false, InputPortName + "0" ); - AddInputPort( m_mainDataType, false, InputPortName + "1" ); - - AddOutputPort( m_mainDataType, " " ); - m_insideSize.Set( 80, 25 ); - m_currentParameterType = PropertyType.Property; - m_customPrefix = "Toggle Switch"; - - m_popContent = new GUIContent(); - m_popContent.image = UIUtils.PopupIcon; - - m_availableAttribs.Clear(); - //Need to maintain this because of retrocompatibility reasons - m_availableAttribs.Add( new PropertyAttributes( "Toggle", "[Toggle]" ) ); - - m_drawAttributes = false; - m_freeType = false; - m_useVarSubtitle = true; - m_useInternalPortData = true; - m_previewShaderGUID = "beeb138daeb592a4887454f81dba2b3f"; - - m_allowPropertyDuplicates = true; - m_showAutoRegisterUI = false; - - m_srpBatcherCompatible = true; - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - UIUtils.RegisterPropertyNode( this ); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_Current" ); - - PreviewMaterial.SetInt( m_cachedPropertyId, m_currentSelectedInput ); - } - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - UpdateConnection(); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateConnection(); - } - - void UpdateConnection() - { - WirePortDataType type1 = WirePortDataType.FLOAT; - if( m_inputPorts[ 0 ].IsConnected ) - type1 = m_inputPorts[ 0 ].GetOutputConnection( 0 ).DataType; - - WirePortDataType type2 = WirePortDataType.FLOAT; - if( m_inputPorts[ 1 ].IsConnected ) - type2 = m_inputPorts[ 1 ].GetOutputConnection( 0 ).DataType; - - m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2; - - m_inputPorts[ 0 ].ChangeType( m_mainDataType, false ); - m_inputPorts[ 1 ].ChangeType( m_mainDataType, false ); - - - //m_outputPorts[ 0 ].ChangeProperties( m_out, m_mainDataType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_varRect = m_remainingBox; - m_varRect.width = 50 * drawInfo.InvertedZoom; - m_varRect.height = 16 * drawInfo.InvertedZoom; - m_varRect.x = m_remainingBox.xMax - m_varRect.width; - m_varRect.y += 1 * drawInfo.InvertedZoom; - - m_imgRect = m_varRect; - m_imgRect.x = m_varRect.xMax - 16 * drawInfo.InvertedZoom; - m_imgRect.width = 16 * drawInfo.InvertedZoom; - m_imgRect.height = m_imgRect.width; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - if ( m_varRect.Contains( drawInfo.MousePosition ) ) - { - m_editing = true; - } - else if ( m_editing ) - { - m_editing = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_editing ) - { - EditorGUI.BeginChangeCheck(); - m_currentSelectedInput = EditorGUIIntPopup( m_varRect, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues, UIUtils.SwitchNodePopUp ); - if ( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - UpdateConnection(); - m_requireMaterialUpdate = true; - m_editing = false; - } - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( !m_editing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - GUI.Label( m_varRect, AvailableInputsLabels[ m_currentSelectedInput ], UIUtils.GraphDropDown ); - GUI.Label( m_imgRect, m_popContent, UIUtils.GraphButtonIcon ); - } - } - - public override void DrawMainPropertyBlock() - { - base.DrawMainPropertyBlock(); - EditorGUILayout.Separator(); - EditorGUI.BeginChangeCheck(); - m_currentSelectedInput = EditorGUILayoutIntPopup( CurrSelectedStr, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues ); - if ( EditorGUI.EndChangeCheck() ) - { - UpdateConnection(); - m_requireMaterialUpdate = true; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_visibleCustomAttrFoldout, CustomAttrStr, DrawCustomAttributes, DrawCustomAttrAddRemoveButtons ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_outputPorts[ 0 ].DataType ); - - string resultA = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalvar, true ); - string resultB = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalvar, true ); - return string.Format( LerpOp, resultA, resultB, m_propertyName ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_currentSelectedInput = 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_currentSelectedInput ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - m_selectedAttribs.Clear(); - UpdateConnection(); - } - public override string GetPropertyValue() - { - return PropertyAttributes + "[Toggle]" + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + m_currentSelectedInput; - } - - public override string GetUniformValue() - { - int index = m_containerGraph.IsSRP ? 1 : 0; - return string.Format( Constants.UniformDec[ index ], UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT ), m_propertyName ); - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - dataType = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT ); - dataName = m_propertyName; - return true; - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if ( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - mat.SetFloat( m_propertyName, ( float ) m_currentSelectedInput ); - } - } - - public override void SetMaterialMode( Material mat , bool fetchMaterialValues ) - { - base.SetMaterialMode( mat , fetchMaterialValues ); - if ( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) && mat.HasProperty( m_propertyName ) ) - { - m_currentSelectedInput = ( int ) mat.GetFloat( m_propertyName ); - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( m_propertyName ) ) - { - m_currentSelectedInput = (int)material.GetFloat( m_propertyName ); - PreviewIsDirty = true; - } - } - - public override string GetPropertyValStr() - { - return PropertyName; //return m_currentSelectedInput.ToString(); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs.meta deleted file mode 100644 index 54b20752..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/ToggleSwitchNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c7f6ffd9a8c958e449321777764784de -timeCreated: 1484213504 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation.meta deleted file mode 100644 index 3dcf03fc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2505ed67ae6a9d647a25755a065e350e -folderAsset: yes -timeCreated: 1488205900 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs deleted file mode 100644 index 48de5fbe..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Object To World", "Object Transform", "Transforms input to World Space" )] - public sealed class ObjectToWorldTransfNode : ParentTransfNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_matrixName = "unity_ObjectToWorld"; - m_matrixHDName = "GetObjectToWorldMatrix()"; - m_matrixLWName = "GetObjectToWorldMatrix()"; - m_previewShaderGUID = "a4044ee165813654486d0cecd0de478c"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = base.GenerateShaderForOutput( 0, ref dataCollector, ignoreLocalvar ); - if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_matrixHDName ) ) - { - dataCollector.AddLocalVariable( UniqueId, string.Format( "{0}.xyz", result ), string.Format( "GetAbsolutePositionWS(({0}).xyz);", result ) ); - } - - return GetOutputVectorItem( 0, outputId, result ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs.meta deleted file mode 100644 index 40b45c87..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ObjectToWorldTransfNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 545417ad304cea84b9f625a3b6ad4e56 -timeCreated: 1488205951 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs deleted file mode 100644 index 5781e115..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - public class ParentTransfNode : ParentNode - { - protected string m_matrixName; - protected string m_matrixHDName; - protected string m_matrixLWName; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, string.Empty ); - AddOutputVectorPorts( WirePortDataType.FLOAT4, "XYZW" ); - m_useInternalPortData = true; - m_inputPorts[ 0 ].Vector4InternalData = new UnityEngine.Vector4( 0, 0, 0, 1 ); - } - - 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 ) ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string matrixName = string.Empty; - if( dataCollector.IsTemplate ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_matrixHDName ) ) - { - matrixName = m_matrixHDName; - } - else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_matrixLWName ) ) - { - matrixName = m_matrixLWName; - } - else - { - matrixName = m_matrixName; - } - } - else - { - matrixName = m_matrixName; - } - - RegisterLocalVariable( 0, string.Format( "mul({0},{1})", matrixName, value ),ref dataCollector,"transform"+ OutputId ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs.meta deleted file mode 100644 index 5a714ba2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/ParentTransfNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 11f04432b7f1ffb43b584adb226614c6 -timeCreated: 1488206086 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs deleted file mode 100644 index ccc57813..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "World To Object", "Object Transform", "Transforms input to Object Space" )] - public sealed class WorldToObjectTransfNode : ParentTransfNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_matrixName = "unity_WorldToObject"; - m_matrixHDName = "GetWorldToObjectMatrix()"; - m_matrixLWName = "GetWorldToObjectMatrix()"; - m_previewShaderGUID = "79a5efd1e3309f54d8ba3e7fdf5e459b"; - } - - 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 ) ); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string matrixName = string.Empty; - if( dataCollector.IsTemplate ) - { - if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_matrixHDName ) ) - { - string varName = "localWorldVar" + OutputId; - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT4, varName, value ); - dataCollector.AddLocalVariable( UniqueId, string.Format( "({0}).xyz", varName ), string.Format( "GetCameraRelativePositionWS(({0}).xyz);", varName ) ); - value = varName; - matrixName = m_matrixHDName; - } - else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_matrixLWName ) ) - { - matrixName = m_matrixLWName; - } - else - { - matrixName = m_matrixName; - } - } - else - { - matrixName = m_matrixName; - } - - RegisterLocalVariable( 0, string.Format( "mul({0},{1})", matrixName, value ), ref dataCollector, "transform" + OutputId ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs.meta deleted file mode 100644 index 8ad85ca4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/Transformation/WorldToObjectTransfNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8a25ccf8973bfae46ae3df2823f58229 -timeCreated: 1488205986 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs deleted file mode 100644 index 1095df44..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public enum eVectorFromMatrixMode - { - Row, - Column - } - - [Serializable] - [NodeAttributes( "Vector From Matrix", "Matrix Operators", "Retrieve vector data from a matrix" )] - public sealed class VectorFromMatrixNode : ParentNode - { - private const string IndexStr = "Index"; - private const string ModeStr = "Mode"; - - [SerializeField] - private eVectorFromMatrixMode m_mode = eVectorFromMatrixMode.Row; - - [SerializeField] - private int m_index = 0; - - [SerializeField] - private int m_maxIndex = 3; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4x4, false, Constants.EmptyPortValue ); - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3, WirePortDataType.FLOAT4x4 ); - AddOutputVectorPorts( WirePortDataType.FLOAT4, "XYZW" ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - } - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdatePorts(); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type ); - UpdatePorts(); - } - - void UpdatePorts() - { - m_inputPorts[ 0 ].MatchPortToConnection(); - - if ( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "XYZ"; - m_maxIndex = 2; - m_outputPorts[ 4 ].Visible = false; - } - else - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "XYZW"; - m_maxIndex = 3; - m_outputPorts[ 4 ].Visible = true; - } - m_sizeIsDirty = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if ( m_inputPorts[ 0 ].DataType != WirePortDataType.FLOAT4x4 && - m_inputPorts[ 0 ].DataType != WirePortDataType.FLOAT3x3 ) - { - value = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), value, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT4x4, value ); - } - if ( m_mode == eVectorFromMatrixMode.Row ) - { - value += "[" + m_index + "]"; - } - else - { - string formatStr = value + "[{0}]" + "[" + m_index + "]"; - int count = 4; - if ( m_inputPorts[ 0 ].DataType != WirePortDataType.FLOAT3x3 ) - { - value = "float4( "; - } - else - { - count = 3; - value = "float3( "; - } - - for ( int i = 0; i < count; i++ ) - { - value += string.Format( formatStr, i ); - if ( i != ( count - 1 ) ) - { - value += ","; - } - } - value += " )"; - } - return GetOutputVectorItem( 0, outputId, value ); - } - - public override void DrawProperties() - { - m_mode = (eVectorFromMatrixMode)EditorGUILayoutEnumPopup( ModeStr, m_mode ); - m_index = EditorGUILayoutIntSlider( IndexStr, m_index, 0, m_maxIndex ); - base.DrawProperties(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_index ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_mode = ( eVectorFromMatrixMode ) Enum.Parse( typeof( eVectorFromMatrixMode ), GetCurrentParam( ref nodeParams ) ); - m_index = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs.meta deleted file mode 100644 index c2e6a9f5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/VectorFromMatrixNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 31c07015a5f2aa44297aa7cfb80ffdd5 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs deleted file mode 100644 index 2ef31bf2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; -using UnityEditor; -namespace AmplifyShaderEditor -{ - [Serializable] - - public class WeightedAvgNode : ParentNode - { - protected string[] AmountsStr = { "Layer 1", "Layer 2", "Layer 3", "Layer 4" }; - - [SerializeField] - protected int m_minimumSize = 1; - - [SerializeField] - protected WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - [SerializeField] - protected string[] m_inputData; - [SerializeField] - protected int m_activeCount = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Weights" ); - AddInputPort( WirePortDataType.FLOAT, false, AmountsStr[ 0 ] ); - AddInputPort( WirePortDataType.FLOAT, false, AmountsStr[ 1 ] ); - AddInputPort( WirePortDataType.FLOAT, false, AmountsStr[ 2 ] ); - AddInputPort( WirePortDataType.FLOAT, false, AmountsStr[ 3 ] ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].AddPortForbiddenTypes( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.SAMPLER1D, - WirePortDataType.SAMPLER2D, - WirePortDataType.SAMPLER3D, - WirePortDataType.SAMPLERCUBE ); - } - UpdateConnection( 0 ); - m_useInternalPortData = true; - } - - 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 OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnection( portId ); - } - - void UpdateInputPorts( int activePorts ) - { - int idx = 1; - for ( ; idx < m_minimumSize + activePorts; idx++ ) - { - m_inputPorts[ idx ].Visible = true; - } - - m_activeCount = idx - 1; - - for ( ; idx < m_inputPorts.Count; idx++ ) - { - m_inputPorts[ idx ].Visible = false; - } - } - - protected void UpdateConnection( int portId ) - { - if ( portId == 0 ) - { - if( m_inputPorts[ portId ].IsConnected ) - m_inputPorts[ portId ].MatchPortToConnection(); - - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - { - UpdateInputPorts( 1 ); - m_previewMaterialPassId = 0; - } - break; - case WirePortDataType.FLOAT2: - { - UpdateInputPorts( 2 ); - m_previewMaterialPassId = 1; - } - break; - case WirePortDataType.FLOAT3: - { - UpdateInputPorts( 3 ); - m_previewMaterialPassId = 2; - } - break; - case WirePortDataType.COLOR: - case WirePortDataType.FLOAT4: - { - UpdateInputPorts( 4 ); - m_previewMaterialPassId = 3; - } - break; - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - for ( int i = 1; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].Visible = false; - } - m_activeCount = 0; - } - break; - } - } - //else - //{ - // SetMainOutputType(); - //} - - SetMainOutputType(); - m_sizeIsDirty = true; - } - - protected void SetMainOutputType() - { - m_mainDataType = WirePortDataType.OBJECT; - int count = m_inputPorts.Count; - for ( int i = 1; i < count; i++ ) - { - if ( m_inputPorts[ i ].Visible ) - { - WirePortDataType portType = m_inputPorts[ i ].IsConnected ? m_inputPorts[ i ].ConnectionType() : WirePortDataType.FLOAT; - if ( m_mainDataType != portType && - UIUtils.GetPriority( portType ) > UIUtils.GetPriority( m_mainDataType ) ) - { - m_mainDataType = portType; - } - } - } - - for( int i = 1; i < count; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - m_inputPorts[ i ].ChangeType( m_mainDataType, false ); - } - } - - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - protected void GetInputData( ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - m_inputData[ 0 ] = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - for ( int i = 1; i < m_inputPorts.Count; i++ ) - { - if ( m_inputPorts[ i ].Visible ) - { - m_inputData[ i ] = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ); - } - } - } - - public override void ReadInputDataFromString( ref string[] nodeParams ) - { - base.ReadInputDataFromString( ref nodeParams ); - UpdateConnection( 0 ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs.meta deleted file mode 100644 index 1faefae2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedAvgNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 35c70c67524c86049a25b7ebd0de6ae3 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs deleted file mode 100644 index dc5fc1b0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Weighted Blend", "Miscellaneous", "Mix all channels through weighted average sum", null, KeyCode.None, true )] - public sealed class WeightedBlendNode : WeightedAvgNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputData = new string[ 6 ]; - m_previewShaderGUID = "6076cbeaa41ebb14c85ff81b58df7d88"; - } - - 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 ); - - GetInputData( ref dataCollector, ignoreLocalvar ); - - string result = string.Empty; - string avgSum = string.Empty; - - string localVarName = "weightedBlendVar" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, localVarName, m_inputData[ 0 ] ); - - if ( m_activeCount < 2 ) - { - return CreateOutputLocalVariable( 0, m_inputData[ 1 ], ref dataCollector ); - } - else - { - for ( int i = 0; i < m_activeCount; i++ ) - { - result += localVarName + Constants.VectorSuffixes[ i ] + "*" + m_inputData[ i + 1 ]; - avgSum += localVarName + Constants.VectorSuffixes[ i ]; - if ( i != ( m_activeCount - 1 ) ) - { - result += " + "; - avgSum += " + "; - } - } - } - - result = UIUtils.AddBrackets( result ) + "/" + UIUtils.AddBrackets( avgSum ); - result = UIUtils.AddBrackets( result ); - RegisterLocalVariable( 0, result, ref dataCollector, "weightedAvg" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs.meta deleted file mode 100644 index 744bfd0c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WeightedBlendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b91b2aefbfad5b444b25320e9ed53cac -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs deleted file mode 100644 index 4bcc5005..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs +++ /dev/null @@ -1,484 +0,0 @@ -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Wire Node", "Miscellaneous", "Wire Node", null, KeyCode.None, false )] - public sealed class WireNode : ParentNode - { - private bool m_markedToDelete = false; - - [SerializeField] - private WirePortDataType m_visualDataType = WirePortDataType.FLOAT; - - bool m_forceVisualDataUpdate = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.OBJECT, false, string.Empty ); - AddOutputPort( WirePortDataType.OBJECT, Constants.EmptyPortValue ); - m_tooltipText = string.Empty; - m_drawPreview = false; - m_drawPreviewExpander = false; - m_canExpand = false; - m_previewShaderGUID = "fa1e3e404e6b3c243b5527b82739d682"; - } - - public WirePortDataType GetLastInputDataTypeRecursively() - { - if( m_outputPorts[ 0 ].ExternalReferences.Count > 0 ) - { - WireNode rightWire = m_outputPorts[ 0 ].GetInputNode( 0 ) as WireNode; - if( rightWire != null ) - return rightWire.GetLastInputDataTypeRecursively(); - else - { - return m_outputPorts[ 0 ].GetInputConnection( 0 ).DataType; - } - } - - if( m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid ) - return m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.DataType; - else - return m_visualDataType; - } - - public override WirePortDataType GetInputPortVisualDataTypeByArrayIdx( int portArrayIdx ) - { - return m_visualDataType; - } - - public override WirePortDataType GetOutputPortVisualDataTypeById( int portId ) - { - return m_visualDataType; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - - m_forceVisualDataUpdate = true; - } - - public override void OnOutputPortConnected( int portId, int otherNodeId, int otherPortId ) - { - base.OnOutputPortConnected( portId, otherNodeId, otherPortId ); - - if( m_outputPorts[ portId ].ConnectionCount > 1 ) - { - for( int i = 0; i < m_outputPorts[ portId ].ExternalReferences.Count; i++ ) - { - if( m_outputPorts[ portId ].ExternalReferences[ i ].PortId != otherPortId ) - { - UIUtils.DeleteConnection( true, m_outputPorts[ portId ].ExternalReferences[ i ].NodeId, m_outputPorts[ portId ].ExternalReferences[ i ].PortId, false, true ); - } - } - } - - m_inputPorts[ 0 ].NotifyExternalRefencesOnChange(); - m_forceVisualDataUpdate = true; - } - - public override void OnConnectedInputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedInputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - - m_inputPorts[ 0 ].NotifyExternalRefencesOnChange(); - m_forceVisualDataUpdate = true; - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - - m_forceVisualDataUpdate = true; - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - TestIfValid(); - - m_forceVisualDataUpdate = true; - m_outputPorts[ 0 ].NotifyExternalRefencesOnChange(); - } - - public override void OnOutputPortDisconnected( int portId ) - { - base.OnOutputPortDisconnected( portId ); - TestIfValid(); - - m_forceVisualDataUpdate = true; - m_inputPorts[ 0 ].NotifyExternalRefencesOnChange(); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - - public override void DrawProperties() - { - if( m_markedToDelete ) - return; - - base.DrawProperties(); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - if( m_firstDraw ) - { - m_firstDraw = false; - AfterCommonInit(); - OnNodeChange(); - } - - if( m_forceVisualDataUpdate ) - { - m_forceVisualDataUpdate = false; - m_visualDataType = GetLastInputDataTypeRecursively(); - } - - if( m_repopulateDictionaries ) - { - m_repopulateDictionaries = false; - - m_inputPortsDict.Clear(); - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - m_inputPortsDict.Add( m_inputPorts[ i ].PortId, m_inputPorts[ i ] ); - } - - m_outputPortsDict.Clear(); - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPortsDict.Add( m_outputPorts[ i ].PortId, m_outputPorts[ i ] ); - } - } - - if( m_sizeIsDirty ) - { - m_sizeIsDirty = false; - m_extraSize.Set( 20f, 20f ); - m_position.width = m_extraSize.x + UIUtils.PortsSize.x; - m_position.height = m_extraSize.y + UIUtils.PortsSize.y; - - Vec2Position -= Position.size * 0.5f; - if( OnNodeChangeSizeEvent != null ) - { - OnNodeChangeSizeEvent( this ); - } - - ChangeSizeFinished(); - //ChangeSize(); - } - - CalculatePositionAndVisibility( drawInfo ); - - // Input Ports - { - m_currInputPortPos = m_globalPosition; - m_currInputPortPos.width = drawInfo.InvertedZoom * UIUtils.PortsSize.x; - m_currInputPortPos.height = drawInfo.InvertedZoom * UIUtils.PortsSize.y; - m_currInputPortPos.position = m_globalPosition.center - m_currInputPortPos.size * 0.5f; - int inputCount = m_inputPorts.Count; - - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - // Button - m_inputPorts[ i ].Position = m_currInputPortPos; - - if( !m_inputPorts[ i ].Locked ) - { - float overflow = 2; - float scaledOverflow = 3 * drawInfo.InvertedZoom; - m_auxRect = m_currInputPortPos; - m_auxRect.yMin -= scaledOverflow + overflow; - m_auxRect.yMax += scaledOverflow + overflow; - m_auxRect.xMin -= Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_auxRect.xMax += m_inputPorts[ i ].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_inputPorts[ i ].ActivePortArea = m_auxRect; - } - m_currInputPortPos.y += drawInfo.InvertedZoom * ( m_fontHeight + Constants.INPUT_PORT_DELTA_Y ); - } - } - } - - // Output Ports - { - m_currOutputPortPos = m_globalPosition; - m_currOutputPortPos.width = drawInfo.InvertedZoom * UIUtils.PortsSize.x; - m_currOutputPortPos.height = drawInfo.InvertedZoom * UIUtils.PortsSize.y; - m_currOutputPortPos.position = m_globalPosition.center - m_currOutputPortPos.size * 0.5f; - //m_currOutputPortPos.x += ( m_globalPosition.width - drawInfo.InvertedZoom * ( Constants.PORT_INITIAL_X + m_anchorAdjust ) ); - //m_currOutputPortPos.y += drawInfo.InvertedZoom * Constants.PORT_INITIAL_Y;// + m_extraHeaderHeight * drawInfo.InvertedZoom; - int outputCount = m_outputPorts.Count; - - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].Visible ) - { - //Button - m_outputPorts[ i ].Position = m_currOutputPortPos; - - if( !m_outputPorts[ i ].Locked ) - { - float overflow = 2; - float scaledOverflow = 3 * drawInfo.InvertedZoom; - m_auxRect = m_currOutputPortPos; - m_auxRect.yMin -= scaledOverflow + overflow; - m_auxRect.yMax += scaledOverflow + overflow; - m_auxRect.xMin -= m_outputPorts[ i ].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_auxRect.xMax += Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_outputPorts[ i ].ActivePortArea = m_auxRect; - } - m_currOutputPortPos.y += drawInfo.InvertedZoom * ( m_fontHeight + Constants.INPUT_PORT_DELTA_Y ); - } - } - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - //base.OnRepaint( drawInfo ); - //return; - if( !m_isVisible ) - return; - - m_colorBuffer = GUI.color; - - // Output Ports - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].Visible ) - { - // Output Port Icon - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - if( m_outputPorts[ i ].Locked ) - GUI.color = Constants.LockedPortColor; - else if( ContainerGraph.ParentWindow.Options.ColoredPorts ) - GUI.color = UIUtils.GetColorForDataType( m_visualDataType, false, false ); - else - GUI.color = m_outputPorts[ i ].HasCustomColor ? m_outputPorts[ i ].CustomColor : UIUtils.GetColorForDataType( m_visualDataType, true, false ); - - GUIStyle style = m_outputPorts[ i ].IsConnected ? UIUtils.GetCustomStyle( CustomStyle.PortFullIcon ) : UIUtils.GetCustomStyle( CustomStyle.PortEmptyIcon ); - GUI.Label( m_outputPorts[ i ].Position, string.Empty, style ); - - GUI.color = m_colorBuffer; - } - - // Output Port Label - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( m_outputPorts[ i ].Locked ) - { - GUI.color = Constants.PortLockedTextColor; - GUI.Label( m_outputPorts[ i ].LabelPosition, m_outputPorts[ i ].Name, UIUtils.OutputPortLabel ); - GUI.color = m_colorBuffer; - } - else - { - GUI.Label( m_outputPorts[ i ].LabelPosition, m_outputPorts[ i ].Name, UIUtils.OutputPortLabel ); - } - } - } - } - - // Selection Box - if( m_selected ) - { - Rect selectionBox = m_globalPosition; - selectionBox.size = Vector2.one * 16 * drawInfo.InvertedZoom + Vector2.one * 4; - selectionBox.center = m_globalPosition.center; - GUI.DrawTexture( selectionBox, UIUtils.WireNodeSelection ); - GUI.color = m_colorBuffer; - } - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - //base.DrawGUIControls( drawInfo ); - } - - public override void Draw( DrawInfo drawInfo ) - { - if( m_markedToDelete ) - return; - - if( drawInfo.CurrentEventType == EventType.Repaint ) - OnNodeRepaint( drawInfo ); - //base.Draw( drawInfo ); - - if( drawInfo.CurrentEventType == EventType.Repaint ) - TestIfValid(); - } - - bool TestIfValid() - { - if( !Alive ) - return false; - - bool result = true; - if( !m_inputPorts[ 0 ].IsConnected ) - { - if( !m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.IsValid || m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.IsValid && m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.NodeId != UniqueId ) - { - ContainerGraph.MarkWireNodeSequence( this, true ); - result = false; - } - } - - if( !m_outputPorts[ 0 ].IsConnected ) - { - if( !m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid || m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid && m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.NodeId != UniqueId ) - { - ContainerGraph.MarkWireNodeSequence( this, false ); - result = false; - } - } - return result; - } - - public Vector3 TangentDirection - { - get - { - ParentNode otherInputNode = null; - ParentNode otherOutputNode = null; - - //defaults to itself so it can still calculate tangents - WirePort otherInputPort = m_outputPorts[ 0 ]; - WirePort otherOutputPort = m_inputPorts[ 0 ]; - - if( m_outputPorts[ 0 ].ConnectionCount > 0 ) - { - otherInputNode = m_containerGraph.GetNode( m_outputPorts[ 0 ].ExternalReferences[ 0 ].NodeId ); - otherInputPort = otherInputNode.GetInputPortByUniqueId( m_outputPorts[ 0 ].ExternalReferences[ 0 ].PortId ); - } - - if( m_inputPorts[ 0 ].ConnectionCount > 0 ) - { - otherOutputNode = m_containerGraph.GetNode( m_inputPorts[ 0 ].ExternalReferences[ 0 ].NodeId ); - otherOutputPort = otherOutputNode.GetOutputPortByUniqueId( m_inputPorts[ 0 ].ExternalReferences[ 0 ].PortId ); - } - - //TODO: it still generates crooked lines if wire nodes get too close to non-wire nodes (the fix would be to calculate the non-wire nodes magnitude properly) - float mag = Constants.HORIZONTAL_TANGENT_SIZE * ContainerGraph.ParentWindow.CameraDrawInfo.InvertedZoom; - - Vector2 outPos; - if( otherOutputNode != null && otherOutputNode.GetType() != typeof( WireNode ) ) - outPos = otherOutputPort.Position.position + Vector2.right * mag * 0.66f; - else - outPos = otherOutputPort.Position.position; - - Vector2 inPos; - if( otherInputNode != null && otherInputNode.GetType() != typeof( WireNode ) ) - inPos = otherInputPort.Position.position - Vector2.right * mag * 0.66f; - else - inPos = otherInputPort.Position.position; - - Vector2 tangent = ( outPos - inPos ).normalized; - return new Vector3( tangent.x, tangent.y ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - - m_extraSize.Set( 20f, 20f ); - m_position.width = m_extraSize.x + UIUtils.PortsSize.x; - m_position.height = m_extraSize.y + UIUtils.PortsSize.y; - - Vec2Position += Position.size * 0.5f; - } - - public override void OnAfterDeserialize() - { - base.OnAfterDeserialize(); - m_sizeIsDirty = false; - } - - public WireReference FindNewValidInputNode( WireNode current ) - { - if( current.InputPorts[ 0 ].IsConnected ) - { - ParentNode node = m_containerGraph.GetNode( current.InputPorts[ 0 ].ExternalReferences[ 0 ].NodeId ); - if( node != null ) - { - WireNode wireNode = node as WireNode; - if( wireNode != null && wireNode.MarkToDelete ) - { - return FindNewValidInputNode( wireNode ); - } - else - { - return current.InputPorts[ 0 ].ExternalReferences[ 0 ]; - } - } - } - return null; - } - - public WireReference FindNewValidOutputNode( WireNode current ) - { - if( current.OutputPorts[ 0 ].IsConnected ) - { - ParentNode node = m_containerGraph.GetNode( current.OutputPorts[ 0 ].ExternalReferences[ 0 ].NodeId ); - - if( node != null ) - { - WireNode wireNode = node as WireNode; - if( wireNode != null && wireNode.MarkToDelete ) - { - return FindNewValidOutputNode( wireNode ); - } - else - { - return current.OutputPorts[ 0 ].ExternalReferences[ 0 ]; - } - } - } - return null; - } - - public override void Rewire() - { - //if ( m_inputPorts[ 0 ].ExternalReferences != null && m_inputPorts[ 0 ].ExternalReferences.Count > 0 ) - //{ - //WireReference backPort = m_inputPorts[ 0 ].ExternalReferences[ 0 ]; - //for ( int i = 0; i < m_outputPorts[ 0 ].ExternalReferences.Count; i++ ) - //{ - // UIUtils.CurrentWindow.ConnectInputToOutput( m_outputPorts[ 0 ].ExternalReferences[ i ].NodeId, m_outputPorts[ 0 ].ExternalReferences[ i ].PortId, backPort.NodeId, backPort.PortId ); - //} - //} - MarkToDelete = true; - WireReference outputReference = FindNewValidInputNode( this ); - WireReference inputReference = FindNewValidOutputNode( this ); - if( outputReference != null && inputReference != null ) - { - ContainerGraph.ParentWindow.ConnectInputToOutput( inputReference.NodeId, inputReference.PortId, outputReference.NodeId, outputReference.PortId ); - } - } - - public bool MarkToDelete - { - get { return m_markedToDelete; } - set { m_markedToDelete = value; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs.meta deleted file mode 100644 index ab597cb9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Misc/WireNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7a566d6bf220cd74b8385a91f690b683 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs deleted file mode 100644 index 91e441ea..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - public enum NodeAvailability - { - SurfaceShader = 1 << 0, - ShaderFunction = 1 << 1, - CustomLighting = 1 << 2, - TemplateShader = 1 << 3 - } - - - [AttributeUsage( AttributeTargets.Class )] - public class NodeAttributes : Attribute - { - - public string Name; - public string Description; - public string Category; - public KeyCode ShortcutKey; - public bool Available; - public System.Type[] CastType; // Type that will be converted to AttribType if dropped on the canvas ... p.e. dropping a texture2d on the canvas will generate a sampler2d node - public bool Deprecated; - public string DeprecatedAlternative; - public System.Type DeprecatedAlternativeType; - public bool FromCommunity; - public string CustomCategoryColor; // Color created via a string containing its hexadecimal representation - public int SortOrderPriority; // to be used when name comparing on sorting - public int NodeAvailabilityFlags;// used to define where this node can be used - private string m_nodeUrl; - public string Community; - public string Tags; - public NodeAttributes( string name, string category, string description, System.Type castType = null, KeyCode shortcutKey = KeyCode.None, bool available = true, bool deprecated = false, string deprecatedAlternative = null, System.Type deprecatedAlternativeType = null, string community = null, string customCategoryColor = null, int sortOrderPriority = -1, int nodeAvailabilityFlags = int.MaxValue, string tags = null ) - { - Name = name; - Description = description; - Category = category; - if( castType != null ) - CastType = new System.Type[] { castType }; - - ShortcutKey = shortcutKey; - Available = available; - Deprecated = deprecated; - DeprecatedAlternative = deprecatedAlternative; - Community = community; - if( string.IsNullOrEmpty( Community ) ) - Community = string.Empty; - else - FromCommunity = true; - - if( !string.IsNullOrEmpty( customCategoryColor ) ) - CustomCategoryColor = customCategoryColor; - - DeprecatedAlternativeType = deprecatedAlternativeType; - SortOrderPriority = sortOrderPriority; - NodeAvailabilityFlags = nodeAvailabilityFlags; - Tags = tags; - if( string.IsNullOrEmpty( tags ) ) - Tags = string.Empty; - //m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name ); - } - - public NodeAttributes( string name, string category, string description, KeyCode shortcutKey, bool available, int sortOrderPriority, int nodeAvailabilityFlags, params System.Type[] castTypes ) - { - Name = name; - Description = description; - Category = category; - if( castTypes != null && castTypes.Length > 0 ) - { - CastType = castTypes; - } - - ShortcutKey = shortcutKey; - Available = available; - SortOrderPriority = sortOrderPriority; - NodeAvailabilityFlags = nodeAvailabilityFlags; - //m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name ); - } - - public string NodeUrl - { - get - { - if( string.IsNullOrEmpty( m_nodeUrl ) ) - { - m_nodeUrl = ( FromCommunity ? Constants.CommunityNodeCommonUrl : Constants.NodeCommonUrl ) + UIUtils.UrlReplaceInvalidStrings( Name ); - } - return m_nodeUrl; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs.meta deleted file mode 100644 index c7a076f4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeAttributes.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ec3cfdc3a4d1a7a4cb24c1c079e1750a -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs deleted file mode 100644 index d68d8eb1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -namespace AmplifyShaderEditor -{ - public class NodeRestrictionsData - { - private bool m_allPorts; - private Dictionary<int, bool> m_portRestrictions; - public NodeRestrictionsData() - { - m_portRestrictions = new Dictionary<int, bool>(); - } - - public NodeRestrictionsData( int port ) - { - m_portRestrictions = new Dictionary<int, bool>(); - m_portRestrictions.Add( port, true ); - } - - public void SetAllPortRestiction( bool value ) - { - m_allPorts = value; - } - - public void AddRestriction( int port ) - { - if ( !m_portRestrictions.ContainsKey( port ) ) - m_portRestrictions.Add( port, true ); - else - m_portRestrictions[ port ] = true; - } - - public void RemoveRestriction( int port ) - { - if ( m_portRestrictions.ContainsKey( port ) ) - m_portRestrictions[ port ] = true; - } - - public bool IsPortRestricted( int port ) - { - if ( m_portRestrictions.ContainsKey( port ) ) - return m_portRestrictions[ port ]; - return false; - } - - public void Destroy() - { - m_portRestrictions.Clear(); - m_portRestrictions = null; - } - - public bool AllPortsRestricted - { - get - { - return m_allPorts; - } - } - } - - public class NodeRestrictions - { - private Dictionary<System.Type, NodeRestrictionsData> m_restrictions; - - public NodeRestrictions() - { - m_restrictions = new Dictionary<System.Type, NodeRestrictionsData>(); - } - - public void AddTypeRestriction( System.Type type ) - { - if ( !m_restrictions.ContainsKey( type ) ) - m_restrictions.Add( type, new NodeRestrictionsData() ); - - m_restrictions[ type ].SetAllPortRestiction( true ); - - } - - public void AddPortRestriction( System.Type type, int port ) - { - if ( !m_restrictions.ContainsKey( type ) ) - m_restrictions.Add( type, new NodeRestrictionsData( port ) ); - else - { - m_restrictions[ type ].AddRestriction( port ); - } - } - - public bool GetRestiction( System.Type type, int port ) - { - if ( m_restrictions.Count == 0 || type == null ) - return false; - - if ( m_restrictions.ContainsKey( type ) ) - { - if ( m_restrictions[ type ].AllPortsRestricted ) - return true; - - return m_restrictions[ type ].IsPortRestricted( port ); - } - - return false; - } - - public void Destroy() - { - foreach ( KeyValuePair<System.Type, NodeRestrictionsData> pair in m_restrictions ) - { - pair.Value.Destroy(); - } - - m_restrictions.Clear(); - m_restrictions = null; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs.meta deleted file mode 100644 index dccb7b31..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeRestrictions.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bd1aff8475f370d4380918491184aef5 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs deleted file mode 100644 index 944ce812..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] public class UsageListSamplerNodes : NodeUsageRegister<SamplerNode> { } - [Serializable] public class UsageListFloatIntNodes : NodeUsageRegister<PropertyNode> { } - [Serializable] public class UsageListTexturePropertyNodes : NodeUsageRegister<TexturePropertyNode> { } - [Serializable] public class UsageListTextureArrayNodes : NodeUsageRegister<TextureArrayNode> { } - [Serializable] public class UsageListPropertyNodes : NodeUsageRegister<PropertyNode> { } - [Serializable] public class UsageListScreenColorNodes : NodeUsageRegister<ScreenColorNode> { } - [Serializable] public class UsageListRegisterLocalVarNodes : NodeUsageRegister<RegisterLocalVarNode> { } - [Serializable] public class UsageListFunctionInputNodes : NodeUsageRegister<FunctionInput> { } - [Serializable] public class UsageListFunctionNodes : NodeUsageRegister<FunctionNode> { } - [Serializable] public class UsageListFunctionOutputNodes : NodeUsageRegister<FunctionOutput> { } - [Serializable] public class UsageListFunctionSwitchNodes : NodeUsageRegister<FunctionSwitch> { } - [Serializable] public class UsageListFunctionSwitchCopyNodes : NodeUsageRegister<FunctionSwitch> { } - [Serializable] public class UsageListTemplateMultiPassMasterNodes : NodeUsageRegister<TemplateMultiPassMasterNode> { } - [Serializable] public class UsageListCustomExpressionsOnFunctionMode : NodeUsageRegister<CustomExpressionNode> { } - [Serializable] public class UsageListGlobalArrayNodes : NodeUsageRegister<GlobalArrayNode> { } - [Serializable] public class UsageListStaticSwitchNodes : NodeUsageRegister<StaticSwitch> { } - - [Serializable] - public class NodeUsageRegister<T> where T : ParentNode - { - public delegate void ReorderEvent(); - public event ReorderEvent OnReorderEventComplete; - - [SerializeField] - public bool ReorderOnChange = false; - - // Sampler Nodes registry - [SerializeField] - private List<T> m_nodes; - - [SerializeField] - private string[] m_nodesArr; - - [SerializeField] - private int[] m_nodeIDs; - - [SerializeField] - ParentGraph m_containerGraph; - - public NodeUsageRegister() - { - m_nodesArr = new string[ 0 ]; - m_nodeIDs = new int[ 0 ]; - m_nodes = new List<T>(); - } - - public void Destroy() - { - m_nodes.Clear(); - m_nodes = null; - m_nodesArr = null; - m_nodeIDs = null; - } - - public void Clear() - { - m_nodes.Clear(); - } - - public int AddNode( T node ) - { - if( node == null ) - return -1; - - if( !m_nodes.Contains( node ) ) - { - if( m_containerGraph != null ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoRegisterNodeId ); - Undo.RegisterCompleteObjectUndo( m_containerGraph, Constants.UndoRegisterNodeId ); - } - m_nodes.Add( node ); - ReorderNodes(); - UpdateNodeArr(); - return m_nodes.Count - 1; - } - else if( node.UniqueId > -1 ) - { - UpdateNodeArr(); - } - - return -1; - } - - public bool HasNode( int uniqueId ) - { - return m_nodes.FindIndex( x => x.UniqueId == uniqueId ) > -1 ? true : false; - } - - public void RemoveNode( T node ) - { - if( node == null ) - return; - - if( m_nodes.Contains( node ) ) - { - if( m_containerGraph != null ) - { - Undo.RegisterCompleteObjectUndo( m_containerGraph.ParentWindow, Constants.UndoUnregisterNodeId ); - Undo.RegisterCompleteObjectUndo( m_containerGraph, Constants.UndoUnregisterNodeId ); - } - - m_nodes.Remove( node ); - ReorderNodes(); - UpdateNodeArr(); - } - } - - public void ReorderNodes() - { - if( ReorderOnChange ) - { - m_nodes.Sort( ( x, y ) => ( x.DataToArray.CompareTo( y.DataToArray ) ) ); - if( OnReorderEventComplete != null ) - { - OnReorderEventComplete(); - } - } - } - - public void UpdateNodeArr() - { - int nodeCount = m_nodes.Count; - if( nodeCount != m_nodesArr.Length ) - { - m_nodesArr = new string[ nodeCount ]; - m_nodeIDs = new int[ nodeCount ]; - } - - for( int i = 0; i < nodeCount; i++ ) - { - m_nodesArr[ i ] = m_nodes[ i ].DataToArray; - m_nodeIDs[ i ] = m_nodes[ i ].UniqueId; - } - } - - public T GetNode( int idx ) - { - if( idx > -1 && idx < m_nodes.Count ) - { - return m_nodes[ idx ]; - } - return null; - } - - public T GetNodeByUniqueId( int uniqueId ) - { - return m_nodes.Find( x => x.UniqueId == uniqueId ); - } - - public T GetNodeByDataToArray( string data ) - { - return m_nodes.Find( x => x.DataToArray.Equals( data )); - } - - public int GetNodeRegisterIdx( int uniqueId ) - { - return m_nodes.FindIndex( x => x.UniqueId == uniqueId ); - } - - public void UpdateDataOnNode( int uniqueId, string data ) - { - if( ReorderOnChange ) - { - ReorderNodes(); - UpdateNodeArr(); - } - else - { - int index = m_nodes.FindIndex( x => x.UniqueId == uniqueId ); - if( index > -1 ) - { - m_nodesArr[ index ] = data; - m_nodeIDs[ index ] = uniqueId; - } - } - } - - public void Dump() - { - string data = string.Empty; - - for( int i = 0; i < m_nodesArr.Length; i++ ) - { - data += m_nodesArr[ i ] + " " + m_nodeIDs[ i ] + '\n'; - } - Debug.Log( data ); - } - - public string[] NodesArr { get { return m_nodesArr; } } - public int[] NodeIds { get { return m_nodeIDs; } } - public List<T> NodesList { get { return m_nodes; } } - public int Count { get { return m_nodes.Count; } } - public ParentGraph ContainerGraph { get { return m_containerGraph; } set { m_containerGraph = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs.meta deleted file mode 100644 index 9f7511e1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUsageRegister.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2aa06a21e7f64094c91da5dd60ef35cf -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs deleted file mode 100644 index 81219dd4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs +++ /dev/null @@ -1,293 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - public class NodeUtils - { - - public delegate void DrawPropertySection(); - - public static void DrawPropertyGroup( string sectionName, DrawPropertySection DrawSection ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( UIUtils.MenuItemToolbarStyle ); - GUI.color = cachedColor; - - GUILayout.Label( sectionName, UIUtils.MenuItemToggleStyle ); - - EditorGUILayout.EndHorizontal(); - - - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - DrawSection(); - EditorGUILayout.Separator(); - EditorGUILayout.EndVertical(); - } - - - public static void DrawNestedPropertyGroup( ref bool foldoutValue, string sectionName, DrawPropertySection DrawSection, int horizontalSpacing = 15 ) - { - GUILayout.BeginHorizontal(); - { - GUILayout.Space( horizontalSpacing ); - EditorGUILayout.BeginVertical( EditorStyles.helpBox ); - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal(); - { - GUI.color = cachedColor; - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - } - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel--; - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - { - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - { - GUI.color = cachedColor; - DrawSection(); - } - EditorGUILayout.EndVertical(); - EditorGUILayout.Separator(); - } - } - EditorGUI.indentLevel++; - } - EditorGUILayout.EndVertical(); - } - GUILayout.EndHorizontal(); - } - - public static void DrawNestedPropertyGroup( ref bool foldoutValue, Rect rect, string sectionName, DrawPropertySection DrawSection, int horizontalSpacing = 15 ) - { - var box = rect; - box.height -= 2; - GUI.Label( box, string.Empty, EditorStyles.helpBox ); - - var tog = rect; -#if UNITY_2019_3_OR_NEWER - tog.y -= ( tog.height - ( EditorGUIUtility.singleLineHeight + 5 ) ) * 0.5f; -#endif - tog.xMin += 2; - tog.xMax -= 2; - tog.yMin += 2; - bool value = GUI.Toggle( tog, foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - - if( foldoutValue ) - { - DrawSection(); - } - } - - - public static void DrawNestedPropertyGroup( ref bool foldoutValue, string sectionName, DrawPropertySection DrawSection, DrawPropertySection HeaderSection ) - { - GUILayout.BeginHorizontal(); - { - GUILayout.Space( 15 ); - EditorGUILayout.BeginVertical( EditorStyles.helpBox ); - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal(); - GUI.color = cachedColor; - - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - HeaderSection(); - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel--; - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - DrawSection(); - EditorGUILayout.EndVertical(); - EditorGUILayout.Separator(); - } - EditorGUI.indentLevel++; - EditorGUILayout.EndVertical(); - } - GUILayout.EndHorizontal(); - } - - public static void DrawNestedPropertyGroup( UndoParentNode owner, ref bool foldoutValue, ref bool enabledValue, string sectionName, DrawPropertySection DrawSection ) - { - GUILayout.BeginHorizontal(); - { - GUILayout.Space( 15 ); - EditorGUILayout.BeginVertical( EditorStyles.helpBox ); - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal(); - GUI.color = cachedColor; - - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - - value = ( (object)owner != null ) ? owner.GUILayoutToggle( enabledValue, string.Empty,UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ) : - GUILayout.Toggle( enabledValue, string.Empty, UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - enabledValue = value; - } - - - EditorGUILayout.EndHorizontal(); - EditorGUI.indentLevel--; - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - DrawSection(); - EditorGUILayout.EndVertical(); - EditorGUILayout.Separator(); - } - EditorGUI.indentLevel++; - EditorGUILayout.EndVertical(); - } - GUILayout.EndHorizontal(); - } - - - public static void DrawPropertyGroup( ref bool foldoutValue, string sectionName, DrawPropertySection DrawSection ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( UIUtils.MenuItemToolbarStyle ); - GUI.color = cachedColor; - - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - EditorGUILayout.EndHorizontal(); - - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - { - GUI.color = cachedColor; - EditorGUI.indentLevel++; - DrawSection(); - EditorGUI.indentLevel--; - EditorGUILayout.Separator(); - } - EditorGUILayout.EndVertical(); - } - } - - public static void DrawPropertyGroup( ref bool foldoutValue, string sectionName, DrawPropertySection DrawSection, DrawPropertySection HeaderSection ) - { - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( UIUtils.MenuItemToolbarStyle ); - GUI.color = cachedColor; - - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - HeaderSection(); - EditorGUILayout.EndHorizontal(); - - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - { - GUI.color = cachedColor; - EditorGUI.indentLevel++; - DrawSection(); - EditorGUI.indentLevel--; - EditorGUILayout.Separator(); - } - EditorGUILayout.EndVertical(); - } - } - - - public static bool DrawPropertyGroup( UndoParentNode owner, ref bool foldoutValue, ref bool enabledValue, string sectionName, DrawPropertySection DrawSection ) - { - bool enableChanged = false; - Color cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, 0.5f ); - EditorGUILayout.BeginHorizontal( UIUtils.MenuItemToolbarStyle ); - GUI.color = cachedColor; - bool value = GUILayout.Toggle( foldoutValue, sectionName, UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth( true ) ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - foldoutValue = value; - } - EditorGUI.BeginChangeCheck(); - value = ( (object)owner != null ) ? owner.EditorGUILayoutToggle( string.Empty, enabledValue, UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ) : - EditorGUILayout.Toggle( string.Empty, enabledValue, UIUtils.MenuItemEnableStyle, GUILayout.Width( 16 ) ); - if( Event.current.button == Constants.FoldoutMouseId ) - { - enabledValue = value; - } - if( EditorGUI.EndChangeCheck() ) - { - enableChanged = true; - } - - EditorGUILayout.EndHorizontal(); - - if( foldoutValue ) - { - cachedColor = GUI.color; - GUI.color = new Color( cachedColor.r, cachedColor.g, cachedColor.b, ( EditorGUIUtility.isProSkin ? 0.5f : 0.25f ) ); - EditorGUILayout.BeginVertical( UIUtils.MenuItemBackgroundStyle ); - GUI.color = cachedColor; - - EditorGUILayout.Separator(); - EditorGUI.BeginDisabledGroup( !enabledValue ); - - EditorGUI.indentLevel += 1; - - DrawSection(); - - EditorGUI.indentLevel -= 1; - EditorGUI.EndDisabledGroup(); - EditorGUILayout.Separator(); - EditorGUILayout.EndVertical(); - } - - return enableChanged; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs.meta deleted file mode 100644 index f60220a5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/NodeUtils.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9eb57a68790e6e343affe131e8a0f860 -timeCreated: 1487688956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators.meta deleted file mode 100644 index 6d6fbea5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: f2a66c410f1e56b418ec994b6f57c2eb -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs deleted file mode 100644 index 32fff2c9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "ACos", "Trigonometry Operators", "Arccosine of scalars and vectors" )] - public sealed class ACosOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "acos"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - m_previewShaderGUID = "710f3c0bbd7ba0c4aada6d7dfadd49c2"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs.meta deleted file mode 100644 index 74fdc7aa..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ACosOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8238f389c28938544b56035531b3f1be -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs deleted file mode 100644 index 936e1d19..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "ASin", "Trigonometry Operators", "Arcsine of scalars and vectors" )] - public sealed class ASinOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "asin"; - m_previewShaderGUID = "2b016c135284add4cb3364d4a0bd0638"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs.meta deleted file mode 100644 index 0e1aa0ab..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ASinOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 268ebf76d03c2e84f8c80a375773b46c -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs deleted file mode 100644 index 70f9fb73..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "ATan2", "Trigonometry Operators", "Arctangent of y/x" )] - public sealed class ATan2OpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_dynamicOutputType = true; - m_useInternalPortData = true; - m_previewShaderGUID = "02e3ff61784e38840af6313936b6a730"; - } - - 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 ); - string result = "atan2( " + m_inputA + " , " + m_inputB + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs.meta deleted file mode 100644 index 9109fe76..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATan2OpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f5957d9ac2cc12146bc862cd0c92815a -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs deleted file mode 100644 index c36c599a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "ATan", "Trigonometry Operators", "Arctangent of scalars and vectors" )] - public sealed class ATanOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "atan"; - m_previewShaderGUID = "7d7f3331a98831241b017364e80625ea"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs.meta deleted file mode 100644 index a382707b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ATanOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d84f7e90e793aaa4891b4c1fe400dc4c -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs deleted file mode 100644 index 18adcbd9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Abs", "Math Operators", "Absolute value of scalars and vectors" )] - public sealed class AbsOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "abs"; - m_previewShaderGUID = "cd6d6dfa3df214a479f68a490e177db6"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs.meta deleted file mode 100644 index 50ca8f58..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/AbsOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 46aea6c13d71ec74da7f23abba3704d6 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs deleted file mode 100644 index 6767231e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Ceil", "Math Operators", "Smallest integer not less than a scalar or each vector component" )] - public sealed class CeilOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "ceil"; - m_previewShaderGUID = "ce0588227a766a245a85291977c1f222"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs.meta deleted file mode 100644 index aba35895..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CeilOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 555db3754f84db947846519630ea303b -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs deleted file mode 100644 index fe15a01e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Clamp", "Math Operators", "Value clamped to the range [min,max]" )] - public sealed class ClampOpNode : ParentNode - { - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.FLOAT, false, "Min" ); - AddInputPort( WirePortDataType.FLOAT, false, "Max" ); - m_inputPorts[ m_inputPorts.Count - 1 ].FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_textLabelWidth = 55; - m_previewShaderGUID = "ab6163c4b10bfc84da8e3c486520490a"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if ( portId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - //else - //{ - // _inputPorts[ portId ].MatchPortToConnection(); - //} - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - if ( outputPortId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, 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 ); - - WirePortDataType valueType = m_inputPorts[ 0 ].ConnectionType(); - WirePortDataType minType = m_inputPorts[ 1 ].ConnectionType(); - WirePortDataType maxType = m_inputPorts[ 2 ].ConnectionType(); - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string min = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - if ( minType != valueType ) - { - min = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), null, m_inputPorts[ 1 ].DataType, m_inputPorts[ 0 ].DataType, min ); - } - - string max = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - if ( maxType != valueType ) - { - max = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), null, m_inputPorts[ 2 ].DataType, m_inputPorts[ 0 ].DataType, max ); - } - - string result = string.Empty; - switch ( valueType ) - { - case WirePortDataType.FLOAT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.INT: - case WirePortDataType.COLOR: - case WirePortDataType.OBJECT: - { - result = "clamp( " + value + " , " + min + " , " + max + " )"; - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - return UIUtils.InvalidParameter( this ); - } - } - - RegisterLocalVariable( 0, result, ref dataCollector, "clampResult" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs.meta deleted file mode 100644 index dd3c8f70..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClampOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5d7101830aa0c524f9519fef95c90dc3 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs deleted file mode 100644 index 606cb822..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Clip", "Miscellaneous", "Conditionally kill a pixel before output" )] - public sealed class ClipNode : ParentNode - { - private const string ClipOpFormat = "clip( {0} );"; - private const string ClipSubOpFormat = "clip( {0} - {1});"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.FLOAT, false, "Alpha" ); - AddInputPort( WirePortDataType.FLOAT, false, "Threshold" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - - m_previewShaderGUID = "1fca7774f364aee4d8c64e8634ef4be4"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ portId ].MatchPortToConnection(); - UpdatePortConnection( portId ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ outputPortId ].MatchPortToConnection(); - UpdatePortConnection( outputPortId ); - } - - void UpdatePortConnection( int portId ) - { - if( portId == 0 ) - { - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - else - { - int otherPortId = portId == 1 ? 2 : 1; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - WirePortDataType type1 = m_inputPorts[ portId ].DataType; - WirePortDataType type2 = m_inputPorts[ otherPortId ].DataType; - - WirePortDataType mainType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2; - - m_inputPorts[ portId ].ChangeType( mainType, false ); - m_inputPorts[ otherPortId ].ChangeType( mainType , false ); - } - else - { - m_inputPorts[ otherPortId ].ChangeType( m_inputPorts[ portId ].DataType,false ); - } - } - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( portId == 0 ) - return; - int otherPortId = portId == 1 ? 2 : 1; - if( m_inputPorts[ otherPortId ].IsConnected ) - { - m_inputPorts[ portId ].ChangeType( m_inputPorts[ otherPortId ].DataType, false ); - } - else - { - m_inputPorts[ portId ].ChangeType( WirePortDataType.FLOAT, false ); - m_inputPorts[ otherPortId ].ChangeType( WirePortDataType.FLOAT, false ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || - dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, "Clip can only be used in fragment functions", MessageSeverity.Warning ); - return GenerateErrorValue(); - } - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string alpha = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - if( m_inputPorts[ 2 ].IsConnected ) - { - string threshold = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, string.Format( ClipSubOpFormat, alpha , threshold) ); - } - else - { - if( m_inputPorts[ 2 ].IsZeroInternalData ) - { - dataCollector.AddLocalVariable( UniqueId, string.Format( ClipOpFormat, alpha ) ); - } - else - { - string threshold = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - dataCollector.AddLocalVariable( UniqueId, string.Format( ClipSubOpFormat, alpha, threshold ) ); - } - } - - return value; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs.meta deleted file mode 100644 index 0d24e6e4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ClipNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 78e9954f4d587b74fa38ae1dd9922d77 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs deleted file mode 100644 index 3ed727cd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs +++ /dev/null @@ -1,382 +0,0 @@ -// 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( "Component Mask", "Vector Operators", "Mask certain channels from vectors/color components", null, KeyCode.K )] - public sealed class ComponentMaskNode : ParentNode - { - private const string OutputLocalVarName = "componentMask"; - [SerializeField] - private bool[] m_selection = { true, true, true, true }; - - [SerializeField] - private int m_outputPortCount = 4; - - [SerializeField] - private string[] m_labels; - - private int m_cachedOrderId = -1; - private int m_cachedSingularId = -1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_selectedLocation = PreviewLocation.TopCenter; - m_labels = new string[] { "X", "Y", "Z", "W" }; - m_previewShaderGUID = "b78e2b295c265cd439c80d218fb3e88e"; - SetAdditonalTitleText( "Value( XYZW )" ); - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - Vector4 order = new Vector4(-1,-1,-1,-1); - int lastIndex = 0; - int singularId = -1; - var datatype = m_inputPorts[ 0 ].DataType; - - if( m_selection[ 0 ] ) - { - order.Set( lastIndex, order.y, order.z, order.w ); - lastIndex++; - singularId = 0; - } - if( m_selection[ 1 ] && datatype >= WirePortDataType.FLOAT2 ) - { - order.Set( order.x, lastIndex, order.z, order.w ); - lastIndex++; - singularId = 1; - } - if( m_selection[ 2 ] && datatype >= WirePortDataType.FLOAT3 ) - { - order.Set( order.x, order.y, lastIndex, order.w ); - lastIndex++; - singularId = 2; - } - if( m_selection[ 3 ] && ( datatype == WirePortDataType.FLOAT4 || datatype == WirePortDataType.COLOR ) ) - { - order.Set( order.x, order.y, order.z, lastIndex ); - lastIndex++; - singularId = 3; - } - - if ( lastIndex != 1 ) - singularId = -1; - - if ( m_cachedOrderId == -1 ) - m_cachedOrderId = Shader.PropertyToID( "_Order" ); - - if ( m_cachedSingularId == -1 ) - m_cachedSingularId = Shader.PropertyToID( "_Singular" ); - - PreviewMaterial.SetVector( m_cachedOrderId, order ); - PreviewMaterial.SetFloat( m_cachedSingularId, singularId ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdatePorts(); - UpdateTitle(); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - UpdatePorts(); - UpdateTitle(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - UpdateTitle(); - } - - void UpdatePorts() - { - m_inputPorts[ 0 ].MatchPortToConnection(); - int count = 0; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - count = 4; - } - break; - case WirePortDataType.FLOAT3: - { - count = 3; - } - break; - case WirePortDataType.FLOAT2: - { - count = 2; - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - int activeCount = 0; - if ( count > 0 ) - { - for ( int i = 0; i < count; i++ ) - { - if ( m_selection[ i ] ) - activeCount += 1; - } - } - - m_outputPortCount = activeCount; - switch ( activeCount ) - { - case 0: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break; - case 1: ChangeOutputType( WirePortDataType.FLOAT, false ); break; - case 2: ChangeOutputType( WirePortDataType.FLOAT2, false ); break; - case 3: ChangeOutputType( WirePortDataType.FLOAT3, false ); break; - case 4: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break; - } - - } - - private void UpdateTitle() - { - int count = 0; - string additionalText = string.Empty; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - count = 4; - } - break; - case WirePortDataType.FLOAT3: - { - count = 3; - } - break; - case WirePortDataType.FLOAT2: - { - count = 2; - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - { - count = 0; - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - if ( count > 0 ) - { - for ( int i = 0; i < count; i++ ) - { - if ( m_selection[ i ] ) - { - additionalText += UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType ).ToUpper(); - } - } - } - - if ( additionalText.Length > 0 ) - SetAdditonalTitleText( "Value( " + additionalText + " )" ); - else - SetAdditonalTitleText( string.Empty ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - - EditorGUILayout.BeginVertical(); - - int count = 0; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - count = 4; - } - break; - case WirePortDataType.FLOAT3: - { - count = 3; - } - break; - case WirePortDataType.FLOAT2: - { - count = 2; - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - int activeCount = 0; - if ( count > 0 ) - { - for ( int i = 0; i < count; i++ ) - { - m_selection[ i ] = EditorGUILayoutToggleLeft( m_labels[i], m_selection[ i ] ); - m_labels[ i ] = UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType ).ToUpper(); - if ( m_selection[ i ] ) - { - activeCount += 1; - } - } - } - - if ( activeCount != m_outputPortCount ) - { - m_outputPortCount = activeCount; - switch ( activeCount ) - { - case 0: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break; - case 1: ChangeOutputType( WirePortDataType.FLOAT, false ); break; - case 2: ChangeOutputType( WirePortDataType.FLOAT2, false ); break; - case 3: ChangeOutputType( WirePortDataType.FLOAT3, false ); break; - case 4: ChangeOutputType( m_inputPorts[ 0 ].DataType, false ); break; - } - UpdateTitle(); - SetSaveIsDirty(); - } - - EditorGUILayout.EndVertical(); - } - - 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 ); - - int count = 0; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - count = 4; - } - break; - case WirePortDataType.FLOAT3: - { - count = 3; - } - break; - case WirePortDataType.FLOAT2: - { - count = 2; - } - break; - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - { - count = 0; - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { } - break; - } - - if ( count > 0 ) - { - bool firstElement = true; - value = string.Format("({0})",value); - for ( int i = 0; i < count; i++ ) - { - if ( m_selection[ i ] ) - { - if( firstElement ) - { - firstElement = false; - value += "."; - } - value += UIUtils.GetComponentForPosition( i, m_inputPorts[ 0 ].DataType ); - } - } - } - - return CreateOutputLocalVariable( 0, value, ref dataCollector ); - } - - public string GetComponentForPosition( int i ) - { - switch ( i ) - { - case 0: - { - return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "r" : "x" ); - } - case 1: - { - return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "g" : "y" ); - } - case 2: - { - return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "b" : "z" ); - } - case 3: - { - return ( ( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) ? "a" : "w" ); - } - } - return string.Empty; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - for ( int i = 0; i < 4; i++ ) - { - m_selection[ i ] = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - UpdateTitle(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - for ( int i = 0; i < 4; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_selection[ i ] ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs.meta deleted file mode 100644 index fd1be0b3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ComponentMaskNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 85082b6932d1c9a4f8b64605534ef118 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs deleted file mode 100644 index a7f799f9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Cos", "Trigonometry Operators", "Cosine of scalars and vectors" )] - public sealed class CosOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "cos"; - m_previewShaderGUID = "3dde9e80389196f459eb94137268de4a"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs.meta deleted file mode 100644 index 132f1bfa..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CosOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ee9c446e7e41d524f8b4c93e6a8886c5 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs deleted file mode 100644 index 24b6205f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Cosh", "Trigonometry Operators", "Hyperbolic cosine of scalars and vectors" )] - public sealed class CoshOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "cosh"; - m_previewShaderGUID = "154a4c85fe88657489a54a02416402c0"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs.meta deleted file mode 100644 index 46ec8178..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CoshOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2b50a187f488a004aaa2dabbe558ab3a -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs deleted file mode 100644 index 354db0d2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Cross", "Vector Operators", "Cross product of two three-component vectors ( A x B )", null, KeyCode.X )] - public sealed class CrossProductOpNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Lhs" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Rhs" ); - AddOutputPort( WirePortDataType.FLOAT3, "Out" ); - m_useInternalPortData = true; - m_previewShaderGUID = "65a9be5cc7037654db8e148d669f03ee"; - } - - 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 lhsStr = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string rhsStr = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string result = "cross( " + lhsStr + " , " + rhsStr + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs.meta deleted file mode 100644 index 61758de7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/CrossProductOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 283bc0645ce925346b33c024ff5a7dad -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs deleted file mode 100644 index 53b8821d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "DDX", "Math Operators", "Approximate partial derivative with respect to window-space X" )] - public sealed class DdxOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "ddx"; - m_previewShaderGUID = "b54ea73d5568b3540977557813eb9c3c"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsFragmentCategory ) - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - else - return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs.meta deleted file mode 100644 index d83171e8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdxOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2e14c4a7c0be9f146ac912130c280b15 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs deleted file mode 100644 index 604a341b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "DDY", "Math Operators", "Approximate partial derivative with respect to window-space Y" )] - public sealed class DdyOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "ddy"; - m_previewShaderGUID = "197dcc7f05339da47b6b0e681c475c5e"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsFragmentCategory ) - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - else - return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs.meta deleted file mode 100644 index d32275f6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DdyOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 722a2ad531fefdc4d8782d5c7cdfd012 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs deleted file mode 100644 index 97afc8ba..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Degrees", "Trigonometry Operators", "Converts values of scalars and vectors from radians to degrees" )] - public sealed class DegreesOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "degrees"; - m_previewShaderGUID = "2a8eebb5566830c4a9d7c4b9021bb743"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs.meta deleted file mode 100644 index 93e8abe4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DegreesOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3d88a21f3ece742408c7748897a21c79 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs deleted file mode 100644 index d48f775d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Determinant", "Matrix Operators", "Scalar determinant of a square matrix" )] - public sealed class DeterminantOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "determinant"; - m_drawPreview = false; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4 ); - - m_autoUpdateOutputPort = false; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs.meta deleted file mode 100644 index 16d62ceb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DeterminantOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e5cded78687f09442895bc96cc5b683d -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs deleted file mode 100644 index 8e3a6dbc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Distance", "Vector Operators", "Euclidean distance between two points" )] - public sealed class DistanceOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT, false ); - m_dynamicOutputType = false; - m_useInternalPortData = true; - m_previewShaderGUID = "3be9a95031c0cb740ae982e465dfc242"; - } - - 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 ); - string result = "distance( " + m_inputA + " , " + m_inputB + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs.meta deleted file mode 100644 index 3d28c02d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DistanceOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4b8bd7fecbc728f4b89d398cef86ada8 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs deleted file mode 100644 index 892ae533..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Dot", "Vector Operators", "Scalar dot product of two vectors ( A . B )", null, KeyCode.Period )] - public sealed class DotProductOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_dynamicOutputType = false; - m_useInternalPortData = true; - m_allowMatrixCheck = true; - m_previewShaderGUID = "85f11fd5cb9bb954c8615a45c57a3784"; - } - - 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 ); - string result = "dot( " + m_inputA + " , " + m_inputB + " )"; - RegisterLocalVariable( 0, result, ref dataCollector, "dotResult" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs.meta deleted file mode 100644 index a84594ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/DotProductOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c2bf0375fb75ce245b2f30857a111972 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs deleted file mode 100644 index b94d5610..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Exp2", "Math Operators", "Base-2 exponential of scalars and vectors" )] - public sealed class Exp2OpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "exp2"; - m_previewShaderGUID = "ceb70ed5423a36647a504a41de7dbfe6"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs.meta deleted file mode 100644 index edea0de0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Exp2OpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a9881734e0217bc45bb422dc83f6ee1a -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs deleted file mode 100644 index 29bded7b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Exp", "Math Operators", "Base-e exponential of scalars and vectors" )] - public sealed class ExpOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "exp"; - m_previewShaderGUID = "6416ff506137d97479a7ebde790b45e5"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs.meta deleted file mode 100644 index f5989769..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ExpOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 81ef96bc69f897d4e8bc21e2731e065f -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs deleted file mode 100644 index 41f14b3f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "FWidth", "Math Operators", "Sum of approximate window-space partial derivatives magnitudes" )] - public sealed class FWidthOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "fwidth"; - m_previewShaderGUID = "81ea481faaef9c8459a555479ba64df7"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - //m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs.meta deleted file mode 100644 index f97901e5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FWidthOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2e17448829221b04bb3185bef727b19f -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs deleted file mode 100644 index 5fe190e6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Floor", "Math Operators", "Largest integer not greater than a scalar or each vector component" )] - public sealed class FloorOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "floor"; - m_previewShaderGUID = "46ae4a72a9a38de40a2d8f20cfccc67d"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs.meta deleted file mode 100644 index bd8bbdb0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FloorOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 176154e86c6c3544fab0d67e098c645d -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs deleted file mode 100644 index 698e3701..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Fmod", "Math Operators", "Floating point remainder of x/y with the same sign as x" )] - public sealed class FmodOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_previewShaderGUID = "65083930f9d7812479fd6ff203ad2992"; - } - - 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( m_inputPorts[ 0 ].DataType == WirePortDataType.INT ) - m_inputA = "(float)" + m_inputA; - - - if( m_inputPorts[ 1 ].DataType == WirePortDataType.INT ) - m_inputB = "(float)" + m_inputB; - - - string result = "fmod( " + m_inputA + " , " + m_inputB + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs.meta deleted file mode 100644 index c4d07b80..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FmodOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 599ae67e52ac45f46acc0efd9285b97c -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs deleted file mode 100644 index 62c54dcb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Fract", "Math Operators", "Fractional portion of a scalar or each vector component" )] - public sealed class FractNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "frac"; - m_previewShaderGUID = "53a335f8f18d4694b8d94e8aee21fdca"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs.meta deleted file mode 100644 index 004f9c6c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/FractNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fd6da00dbcdf3d04cb35a61cda01ae77 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs deleted file mode 100644 index 893521dc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using UnityEngine; -using UnityEditor; -using System.Collections; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Gradient Sample", "Miscellaneous", "Samples a gradient" )] - public sealed class GradientSampleNode : ParentNode - { - private string m_functionHeader = "SampleGradient( {0}, {1} )"; - private string m_functionBody = string.Empty; - - private GradientNode m_gradientNode = null; - private InputPort m_gradPort; - - private Gradient m_blankGrandient = new Gradient(); - - private int m_cachedTimeId = -1; - private int m_cachedTypeId = -1; - private int m_cachedColorNumId = -1; - private int m_cachedAlphaNumId = -1; - - private Vector4 m_auxVec4 = Vector4.zero; - - private string m_functionHeaderStruct = "Gradient( {0} )"; - private string m_functionBodyStruct = string.Empty; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.OBJECT, true, Constants.EmptyPortValue ); - AddInputPort( WirePortDataType.FLOAT, false, "Time" ); - AddOutputColorPorts( "RGBA", true ); - m_gradPort = m_inputPorts[ 0 ]; - m_useInternalPortData = true; - m_autoDrawInternalPortData = true; - m_drawPreviewExpander = false; - m_drawPreview = true; - m_showPreview = true; - m_selectedLocation = PreviewLocation.TopCenter; - m_previewShaderGUID = "8a09124cd6e4aa54a996e7487ec16b90"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( m_cachedTypeId == -1 ) - m_cachedTypeId = Shader.PropertyToID( "_GType" ); - - if( m_cachedTimeId == -1 ) - m_cachedTimeId = Shader.PropertyToID( "_GTime" ); - - if( m_cachedColorNumId == -1 ) - m_cachedColorNumId = Shader.PropertyToID( "_GColorNum" ); - - if( m_cachedAlphaNumId == -1 ) - m_cachedAlphaNumId = Shader.PropertyToID( "_GAlphaNum" ); - - PreviewMaterial.SetTexture( m_cachedTimeId, m_inputPorts[ 1 ].InputPreviewTexture( ContainerGraph ) ); - - Gradient curGrad = m_blankGrandient; - if( m_gradientNode != null ) - curGrad = m_gradientNode.Gradient; - - PreviewMaterial.SetInt( m_cachedTypeId, (int)curGrad.mode ); - PreviewMaterial.SetInt( m_cachedColorNumId, curGrad.colorKeys.Length ); - PreviewMaterial.SetInt( m_cachedAlphaNumId, curGrad.alphaKeys.Length ); - - for( int i = 0; i < 8; i++ ) - { - if( i < curGrad.colorKeys.Length ) - { - m_auxVec4.x = curGrad.colorKeys[ i ].color.r; - m_auxVec4.y = curGrad.colorKeys[ i ].color.g; - m_auxVec4.z = curGrad.colorKeys[ i ].color.b; - m_auxVec4.w = curGrad.colorKeys[ i ].time; - PreviewMaterial.SetVector( "_Col" + i, m_auxVec4 ); - } - else - { - PreviewMaterial.SetVector( "_Col" + i, Vector4.zero ); - } - } - - for( int i = 0; i < 8; i++ ) - { - if( i < curGrad.alphaKeys.Length ) - { - m_auxVec4.x = curGrad.alphaKeys[ i ].alpha; - m_auxVec4.y = curGrad.alphaKeys[ i ].time; - PreviewMaterial.SetVector( "_Alp" + i, m_auxVec4 ); - } - else - { - PreviewMaterial.SetVector( "_Alp" + i, Vector4.zero ); - } - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - - if( m_gradPort.IsConnected ) - { - m_gradientNode = RecursiveBackCheck( m_gradPort.GetOutputNode( 0 ) ); - } - else - { - m_gradientNode = null; - } - } - - GradientNode RecursiveBackCheck( ParentNode node ) - { - if( node is GradientNode ) - { - return node as GradientNode; - } - else - { - if( node is RelayNode || node is WireNode || node is RegisterLocalVarNode ) - { - return RecursiveBackCheck( node.InputPorts[ 0 ].GetOutputNode( 0 ) ); - } - else if( node is GetLocalVarNode) - { - var gnode = node as GetLocalVarNode; - if( gnode.CurrentSelected != null ) - return RecursiveBackCheck( gnode.CurrentSelected ); - else - return null; - } - else - { - return null; - } - } - - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - m_functionBodyStruct = string.Empty; - if( !dataCollector.IsSRP ) - { - GradientNode.GenerateGradientStruct( ref m_functionBodyStruct ); - dataCollector.AddFunctions( m_functionHeaderStruct, m_functionBodyStruct, "0" ); - } - else - { - dataCollector.AddToIncludes( UniqueId, "Packages/com.unity.shadergraph/ShaderGraphLibrary/Functions.hlsl" ); - } - - GenerateGradientSampler( dataCollector.IsSRP ); - - string gradient = "(Gradient)0"; - if( m_inputPorts[ 0 ].IsConnected && m_gradientNode != null ) - gradient = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string time = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, gradient, time ); - return GetOutputVectorItem( 0, outputId, functionResult ); - } - - void GenerateGradientSampler( bool isSrp ) - { - m_functionBody = string.Empty; - IOUtils.AddFunctionHeader( ref m_functionBody, "float4 SampleGradient( Gradient gradient, float time )" ); - IOUtils.AddFunctionLine( ref m_functionBody, "float3 color = gradient.colors[0].rgb;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "UNITY_UNROLL" ); - IOUtils.AddFunctionLine( ref m_functionBody, "for (int c = 1; c < 8; c++)" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - if( isSrp ) - IOUtils.AddFunctionLine( ref m_functionBody, "float colorPos = saturate((time - gradient.colors[c-1].w) / (gradient.colors[c].w - gradient.colors[c-1].w)) * step(c, gradient.colorsLength-1);" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, "float colorPos = saturate((time - gradient.colors[c-1].w) / (gradient.colors[c].w - gradient.colors[c-1].w)) * step(c, (float)gradient.colorsLength-1);" ); - IOUtils.AddFunctionLine( ref m_functionBody, "color = lerp(color, gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), gradient.type));" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - - IOUtils.AddFunctionLine( ref m_functionBody, "#ifndef UNITY_COLORSPACE_GAMMA" ); - if( isSrp ) - IOUtils.AddFunctionLine( ref m_functionBody, "color = SRGBToLinear(color);" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, "color = half3(GammaToLinearSpaceExact(color.r), GammaToLinearSpaceExact(color.g), GammaToLinearSpaceExact(color.b));" ); - IOUtils.AddFunctionLine( ref m_functionBody, "#endif" ); - - IOUtils.AddFunctionLine( ref m_functionBody, "float alpha = gradient.alphas[0].x;" ); - IOUtils.AddFunctionLine( ref m_functionBody, "UNITY_UNROLL" ); - IOUtils.AddFunctionLine( ref m_functionBody, "for (int a = 1; a < 8; a++)" ); - IOUtils.AddFunctionLine( ref m_functionBody, "{" ); - if( isSrp ) - IOUtils.AddFunctionLine( ref m_functionBody, "float alphaPos = saturate((time - gradient.alphas[a-1].y) / (gradient.alphas[a].y - gradient.alphas[a-1].y)) * step(a, gradient.alphasLength-1);" ); - else - IOUtils.AddFunctionLine( ref m_functionBody, "float alphaPos = saturate((time - gradient.alphas[a-1].y) / (gradient.alphas[a].y - gradient.alphas[a-1].y)) * step(a, (float)gradient.alphasLength-1);" ); - IOUtils.AddFunctionLine( ref m_functionBody, "alpha = lerp(alpha, gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), gradient.type));" ); - IOUtils.AddFunctionLine( ref m_functionBody, "}" ); - IOUtils.AddFunctionLine( ref m_functionBody, "return float4(color, alpha);" ); - IOUtils.CloseFunctionBody( ref m_functionBody ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs.meta deleted file mode 100644 index 51d0b9e5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/GradientSampleNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b90e416e2fa93a249952fabc78f659c8 -timeCreated: 1562847602 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs deleted file mode 100644 index 178fc545..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// 4x4 Invert by DBN in -// http://answers.unity3d.com/questions/218333/shader-inversefloat4x4-function.html?childToView=641391#answer-641391 - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Inverse", "Matrix Operators", "Inverse matrix of a matrix" )] - public sealed class InverseOpNode : SingleInputOp - { - private string Inverse4x4Header = "Inverse4x4( {0} )"; - - //4x4 - private string[] Inverse4x4Function = - { - "{0}4x4 Inverse4x4({0}4x4 input)\n", - "{\n", - "\t#define minor(a,b,c) determinant({0}3x3(input.a, input.b, input.c))\n", - "\t{0}4x4 cofactors = {0}4x4(\n", - "\tminor( _22_23_24, _32_33_34, _42_43_44 ),\n", - "\t-minor( _21_23_24, _31_33_34, _41_43_44 ),\n", - "\tminor( _21_22_24, _31_32_34, _41_42_44 ),\n", - "\t-minor( _21_22_23, _31_32_33, _41_42_43 ),\n", - "\n", - "\t-minor( _12_13_14, _32_33_34, _42_43_44 ),\n", - "\tminor( _11_13_14, _31_33_34, _41_43_44 ),\n", - "\t-minor( _11_12_14, _31_32_34, _41_42_44 ),\n", - "\tminor( _11_12_13, _31_32_33, _41_42_43 ),\n", - "\n", - "\tminor( _12_13_14, _22_23_24, _42_43_44 ),\n", - "\t-minor( _11_13_14, _21_23_24, _41_43_44 ),\n", - "\tminor( _11_12_14, _21_22_24, _41_42_44 ),\n", - "\t-minor( _11_12_13, _21_22_23, _41_42_43 ),\n", - "\n", - "\t-minor( _12_13_14, _22_23_24, _32_33_34 ),\n", - "\tminor( _11_13_14, _21_23_24, _31_33_34 ),\n", - "\t-minor( _11_12_14, _21_22_24, _31_32_34 ),\n", - "\tminor( _11_12_13, _21_22_23, _31_32_33 ));\n", - "\t#undef minor\n", - "\treturn transpose( cofactors ) / determinant( input );\n", - "}\n" - }; - - private bool[] Inverse4x4FunctionFlags = - { - true, - false, - true, - true, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false, - false - }; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "inverse"; - m_drawPreview = false; - - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4 ); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, 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 precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, WirePortDataType.FLOAT ); - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - if ( m_outputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 ) - { - GeneratorUtils.Add3x3InverseFunction( ref dataCollector, precisionString ); - RegisterLocalVariable( 0, string.Format( GeneratorUtils.Inverse3x3Header, value ), ref dataCollector, "invertVal" + OutputId ); - } - else - { - if ( !dataCollector.HasFunction( Inverse4x4Header ) ) - { - //Hack to be used util indent is properly used - int currIndent = UIUtils.ShaderIndentLevel; - - if ( dataCollector.IsTemplate ) - { - UIUtils.ShaderIndentLevel = 0; - } - else - { - UIUtils.ShaderIndentLevel = 1; - UIUtils.ShaderIndentLevel++; - } - - string finalFunction = string.Empty; - for ( int i = 0; i < Inverse4x4Function.Length; i++ ) - { - finalFunction += UIUtils.ShaderIndentTabs + ( Inverse4x4FunctionFlags[ i ] ? string.Format( Inverse4x4Function[ i ], precisionString ) : Inverse4x4Function[ i ] ); - } - - - UIUtils.ShaderIndentLevel = currIndent; - - dataCollector.AddFunction( Inverse4x4Header, finalFunction ); - } - - RegisterLocalVariable( 0, string.Format( Inverse4x4Header, value ), ref dataCollector, "invertVal" + OutputId ); - } - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs.meta deleted file mode 100644 index bc47ad0f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/InverseOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 785830160e033d24280df9c5b4cec368 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs deleted file mode 100644 index c67f26b4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Length", "Vector Operators", "Scalar Euclidean length of a vector" )] - public sealed class LengthOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "length"; - m_previewShaderGUID = "1c1f6d6512b758942a8b9dd1bea12f34"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_autoUpdateOutputPort = false; - } - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - switch( m_inputPorts[0].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - case WirePortDataType.UINT:m_previewMaterialPassId = 0;break; - case WirePortDataType.FLOAT2:m_previewMaterialPassId = 1;break; - case WirePortDataType.FLOAT3:m_previewMaterialPassId = 2;break; - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR:m_previewMaterialPassId = 3;break; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs.meta deleted file mode 100644 index c13dd4f4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LengthOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bb3fd570e41cfa24d93b53e80eac02d5 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs deleted file mode 100644 index 1ec7199d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Lerp", "Math Operators", "Linear interpolation of two scalars or vectors based on a weight", null, KeyCode.L )] - public sealed class LerpOp : ParentNode - { - private const string LertOpFormat = "lerp( {0} , {1} , {2})"; - - [UnityEngine.SerializeField] - private WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_textLabelWidth = 55; - AddInputPort( WirePortDataType.FLOAT, false, "A" ); - AddInputPort( WirePortDataType.FLOAT, false, "B" ); - AddInputPort( WirePortDataType.FLOAT, false, "Alpha" ); - AddOutputPort( WirePortDataType.FLOAT,Constants.EmptyPortValue); - m_useInternalPortData = true; - m_previewShaderGUID = "34d9c4cdcf1fadb49af2de3f90bbc57d"; - } - - 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 ); - UpdateConnection( portId ); - } - - void UpdateConnection( int portId ) - { - WirePortDataType type1 = WirePortDataType.FLOAT; - if( m_inputPorts[ 0 ].IsConnected ) - type1 = m_inputPorts[ 0 ].GetOutputConnection( 0 ).DataType; - - WirePortDataType type2 = WirePortDataType.FLOAT; - if( m_inputPorts[ 1 ].IsConnected ) - type2 = m_inputPorts[ 1 ].GetOutputConnection( 0 ).DataType; - - WirePortDataType typealpha = WirePortDataType.FLOAT; - if( m_inputPorts[ 2 ].IsConnected ) - typealpha = m_inputPorts[ 2 ].GetOutputConnection( 0 ).DataType; - - m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2; - - if( !m_inputPorts[ 0 ].IsConnected && !m_inputPorts[ 1 ].IsConnected && m_inputPorts[ 2 ].IsConnected ) - m_mainDataType = m_inputPorts[ 2 ].GetOutputConnection( 0 ).DataType; - - m_inputPorts[ 0 ].ChangeType( m_mainDataType, false ); - - m_inputPorts[ 1 ].ChangeType( m_mainDataType, false ); - if( m_inputPorts[ 2 ].IsConnected && ( typealpha == WirePortDataType.FLOAT || typealpha == WirePortDataType.INT ) ) - m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT, false ); - else - m_inputPorts[ 2 ].ChangeType( m_mainDataType, false ); - - m_outputPorts[ 0 ].ChangeType( m_mainDataType, false ); - } - - //void UpdateDisconnection( int portId ) - //{ - // int otherPortId = ( portId + 1 ) % 2; - // if ( m_inputPorts[ otherPortId ].IsConnected ) - // { - // m_mainDataType = m_inputPorts[ otherPortId ].DataType; - // m_inputPorts[ portId ].ChangeType( m_mainDataType, false ); - // m_outputPorts[ 0 ].ChangeType( m_mainDataType, 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 aValue = m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar, true ); - string bValue = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar, true ); - string interp = string.Empty; - if( m_inputPorts[ 2 ].DataType == WirePortDataType.FLOAT ) - interp = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - else - interp = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_mainDataType, ignoreLocalVar,true ); - string result = string.Format( LertOpFormat, aValue,bValue,interp); - - RegisterLocalVariable( 0, result, ref dataCollector, "lerpResult"+OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - //public override void RefreshExternalReferences() - //{ - // if ( m_inputPorts[ 2 ].DataType != WirePortDataType.FLOAT ) - // { - // m_inputPorts[ 2 ].ChangeType( WirePortDataType.FLOAT, false ); - // } - //} - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs.meta deleted file mode 100644 index 22b8eec4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LerpOp.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1e38abf6e3c7dfa409a5fe40d2ce8a19 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs deleted file mode 100644 index 35914c34..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Log10", "Math Operators", "Base-10 logarithm of scalars and vectors" )] - public sealed class Log10OpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "log10"; - m_previewShaderGUID = "9e7cfa357dd261f499d0ba8637ff2614"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs.meta deleted file mode 100644 index e9ae3c31..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log10OpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: be47a76f1f42fbe47bf2568584c31196 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs deleted file mode 100644 index 614a82a2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Log2", "Math Operators", "Base-2 logarithm of scalars and vectors" )] - public sealed class Log2OpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "log2"; - m_previewShaderGUID = "5975a154432d4c64cacd78d015ed08ba"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs.meta deleted file mode 100644 index 9511991b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/Log2OpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b9489308aad1f794982afc1faf646013 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs deleted file mode 100644 index ff7d7863..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Log", "Math Operators", "Natural logarithm of scalars and vectors" )] - public sealed class LogOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "log"; - m_previewShaderGUID = "a3293e0a73834b24682775f5d8ee1e7c"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs.meta deleted file mode 100644 index 7aab4f70..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/LogOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1ed2c12cea61a8c4fa67eebdc10d2a2a -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs deleted file mode 100644 index 9cb64e97..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs +++ /dev/null @@ -1,3 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// Deprecated file diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs.meta deleted file mode 100644 index 597824ca..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/MultipleInputOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8804c7e5888738547b5a704f788fc18b -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs deleted file mode 100644 index 00c174dc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Negate", "Math Operators", "Negate or invert an input value" )] - public sealed class NegateNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_previewShaderGUID = "b035bc40da1ac7c4eafad4116382ec79"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - if ( result.StartsWith( "-" ) ) - { - return result.Remove( 0, 1 ); - } - else - { - return "-" + result; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs.meta deleted file mode 100644 index 83f5922e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NegateNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 01c91005470f6b94eba168a127cecd6c -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs deleted file mode 100644 index 140a1173..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Normalize", "Vector Operators", "Normalizes a vector", null, KeyCode.N )] - public sealed class NormalizeNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_selectedLocation = PreviewLocation.TopCenter; - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT, WirePortDataType.FLOAT2, WirePortDataType.FLOAT3, WirePortDataType.FLOAT4, WirePortDataType.COLOR, WirePortDataType.OBJECT, WirePortDataType.INT ); - m_previewShaderGUID = "a51b11dfb6b32884e930595e5f9defa8"; - } - 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 result = string.Empty; - switch ( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT4: - case WirePortDataType.OBJECT: - case WirePortDataType.COLOR: - { - result = "normalize( " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )"; - } - break; - case WirePortDataType.INT: - { - return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - } - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - { - result = UIUtils.InvalidParameter( this ); - } - break; - } - RegisterLocalVariable( 0, result, ref dataCollector, "normalizeResult" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs.meta deleted file mode 100644 index 8bec377b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/NormalizeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fa6682c371754094f88b3c2a7e96ae26 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs deleted file mode 100644 index 10792114..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "One Minus", "Math Operators", "1 - input value", null, KeyCode.O )] - public sealed class OneMinusNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_previewShaderGUID = "bed5300b92e7bb0419d0f4accb853312"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, 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 result = "( 1.0 - " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs.meta deleted file mode 100644 index ff94c53d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/OneMinusNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 727743b66e17d7b4f9c2fbe7dde98bd9 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs deleted file mode 100644 index 82357b67..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Power", "Math Operators", "Base to the Exp-th power of scalars and vectors", null, KeyCode.E )] - public sealed class PowerNode : ParentNode - { - public const string SafePowerStr = "max( {0} , 0.0001 )"; - public const string SafePowerLabel = "Safe Power"; - - [SerializeField] - private bool m_safePower = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Base" ); - AddInputPort( WirePortDataType.FLOAT, false, "Exp" ); - m_inputPorts[ 1 ].FloatInternalData = 1; - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_textLabelWidth = 85; - m_previewShaderGUID = "758cc2f8b537b4e4b93d9833075d138c"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnections( portId ); - } - - public override void OnConnectedOutputNodeChanges( int inputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( inputPortId, otherNodeId, otherPortId, name, type ); - UpdateConnections( inputPortId ); - } - - void UpdateConnections( int inputPort ) - { - m_inputPorts[ inputPort ].MatchPortToConnection(); - if ( inputPort == 0 ) - { - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_safePower = EditorGUILayoutToggle( SafePowerLabel, m_safePower ); - } - - 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 x = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - if( m_safePower ) - { - string safePowerName = "saferPower" + OutputId; - string safePowerValue = string.Format( SafePowerStr, x ); - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_inputPorts[ 0 ].DataType, safePowerName, safePowerValue ); - x = safePowerName; - } - - string y = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true ); - string result = "pow( " + x + " , " + y + " )"; - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 17502 ) - m_safePower = 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_safePower ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs.meta deleted file mode 100644 index bedc464e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/PowerNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 520a55839e863ce47b3558be612f4691 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs deleted file mode 100644 index 659c86cd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Rsqrt", "Math Operators", "Reciprocal square root of scalars and vectors" )] - public sealed class RSqrtOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "rsqrt"; - m_previewShaderGUID = "c58c17cb1f7f6e6429a2c7a6cdaef87d"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs.meta deleted file mode 100644 index e124e47a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RSqrtOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 513de50bd4766d0448bb471ca272608f -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs deleted file mode 100644 index 19f478ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Radians", "Trigonometry Operators", "Converts values of scalars and vectors from degrees to radians" )] - public sealed class RadiansOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "radians"; - m_previewShaderGUID = "d27d189eaf6eeb04fae9913d9617ece5"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs.meta deleted file mode 100644 index f90ec876..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RadiansOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b6ca01d5c16f73c42996318c140eddb7 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs deleted file mode 100644 index 1488cb1c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Reflect", "Vector Operators", "Reflection vector given an incidence vector and a normal vector" )] - public sealed class ReflectOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].ChangeProperties( "Incident", WirePortDataType.FLOAT4, false ); - m_inputPorts[ 1 ].ChangeProperties( "Normal", WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - - m_textLabelWidth = 67; - m_previewShaderGUID = "fb520f2145c0fa0409320a9e6d720758"; - } - - 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 ); - string result = "reflect( " + m_inputA + " , " + m_inputB + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs.meta deleted file mode 100644 index 2b7f085f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ReflectOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bcd77715f8db1564abc96d502312d476 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs deleted file mode 100644 index ba59e2ca..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Refract", "Vector Operators", "Computes a refraction vector" )] - public sealed class RefractOpVec : ParentNode - { - [UnityEngine.SerializeField] - private WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false , "Incident" ); - AddInputPort( WirePortDataType.FLOAT4, false , "Normal" ); - AddInputPort( WirePortDataType.FLOAT, false, "Eta" ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - m_textLabelWidth = 67; - m_previewShaderGUID = "5ab44ca484bed8b4884b03b1c00fdc3d"; - } - - 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 ); - UpdateConnection( portId ); - } - - void UpdateConnection( int portId ) - { - if( portId == 2 ) - return; - - bool hasConnection = false; - - WirePortDataType type1 = WirePortDataType.FLOAT; - if( m_inputPorts[ 0 ].IsConnected ) - { - type1 = m_inputPorts[ 0 ].GetOutputConnection( 0 ).DataType; - hasConnection = true; - } - WirePortDataType type2 = WirePortDataType.FLOAT; - if( m_inputPorts[ 1 ].IsConnected ) - { - type2 = m_inputPorts[ 1 ].GetOutputConnection( 0 ).DataType; - hasConnection = true; - } - - if( hasConnection ) - { - m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2; - } - else - { - m_mainDataType = WirePortDataType.FLOAT4; - } - - m_inputPorts[ 0 ].ChangeType( m_mainDataType, false ); - m_inputPorts[ 1 ].ChangeType( m_mainDataType, false ); - m_outputPorts[ 0 ].ChangeType( m_mainDataType, 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 incident = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string normal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string interp = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string result = "refract( " + incident + " , " + normal + " , " + interp + " )"; - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs.meta deleted file mode 100644 index 58b705a4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RefractOpVec.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c5bb608b83cdc894cab572c72baa5f84 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs deleted file mode 100644 index 95b1dd8f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Round", "Math Operators", "Rounded value of scalars or vectors" )] - public sealed class RoundOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "round"; - m_previewShaderGUID = "554d561417b207c4bb3cd4a0c86b6907"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs.meta deleted file mode 100644 index 9b3740db..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/RoundOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f7b5f29bc7f6bb844ae4ea698404adc3 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs deleted file mode 100644 index ed91f4d4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Saturate", "Math Operators", "Saturate clamps the input values into the [0,1] range" )] - public sealed class SaturateNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "saturate"; - m_previewShaderGUID = "d9e53418dc8b9d34fb395e3ea3c75985"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs.meta deleted file mode 100644 index e199e9cf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SaturateNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9d56f68d94c889443af651140ef86948 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: 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 <info@amplify.pt> -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Scale And Offset", "Math Operators", "Scales and offsets an input value\n( ( <b>Value</b> * <b>Scale</b> ) + <b>Offset</b> )" )] - 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 ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs.meta deleted file mode 100644 index 4a508a82..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleAndOffsetNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b594feaa69ad03449b563f834fe0c18e -timeCreated: 1484582091 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs deleted file mode 100644 index 7445a10d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs +++ /dev/null @@ -1,152 +0,0 @@ -// 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( "Scale", "Math Operators", "Scales input value by a float factor" )] - public sealed class ScaleNode : ParentNode - { - private const string ScaleFactorStr = "Scale"; - - [SerializeField] - private float m_scaleFactor = 1; - - private int m_cachedPropertyId = -1; - - private const float LabelWidth = 8; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, " " ); - AddOutputPort( WirePortDataType.FLOAT, " " ); - m_insideSize.Set( 50, 10 ); - m_autoWrapProperties = true; - m_previewShaderGUID = "6d8ec9d9dab62c44aa2dcc0e3987760d"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_ScaleFloat" ); - - PreviewMaterial.SetFloat( m_cachedPropertyId, m_scaleFactor ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_scaleFactor = EditorGUILayoutFloatField( ScaleFactorStr, m_scaleFactor ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - m_outputPorts[ 0 ].ChangeType( InputPorts[ 0 ].DataType, false ); - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_propertyDrawPos.x = m_remainingBox.x + Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * 0.5f; - m_propertyDrawPos.y = m_remainingBox.y + Constants.INPUT_PORT_DELTA_Y * drawInfo.InvertedZoom * 0.5f; - m_propertyDrawPos.width = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE; - m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if ( drawInfo.CurrentEventType != EventType.MouseDown ) - return; - - Rect hitBox = m_remainingBox; - hitBox.xMin -= LabelWidth * drawInfo.InvertedZoom; - bool insideBox = hitBox.Contains( drawInfo.MousePosition ); - - if ( insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = true; - } - else if ( m_isEditingFields && !insideBox ) - { - GUI.FocusControl( null ); - m_isEditingFields = false; - } - } - - private bool m_isEditingFields; - private float m_previousValue; - private string m_fieldText = "0"; - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if ( !m_isVisible ) - return; - - if ( m_isEditingFields ) - { - UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_scaleFactor, LabelWidth ); - } - else if ( drawInfo.CurrentEventType == EventType.Repaint ) - { - Rect fakeField = m_propertyDrawPos; - fakeField.xMin += LabelWidth * drawInfo.InvertedZoom; - Rect fakeLabel = m_propertyDrawPos; - fakeLabel.xMax = fakeField.xMin; - EditorGUIUtility.AddCursorRect( fakeLabel, MouseCursor.SlideArrow ); - EditorGUIUtility.AddCursorRect( fakeField, MouseCursor.Text ); - - if ( m_previousValue != m_scaleFactor ) - { - m_previousValue = m_scaleFactor; - m_fieldText = m_scaleFactor.ToString(); - } - - GUI.Label( fakeField, m_fieldText, UIUtils.MainSkin.textField ); - } - } - - 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 portResult = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string result = "( " + portResult + " * " + m_scaleFactor + " )"; - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_scaleFactor ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_scaleFactor = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs.meta deleted file mode 100644 index 49bd4b82..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/ScaleNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ec926b11f9c698c458f746e4e55fd7df -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs deleted file mode 100644 index 90f83dcf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Sign", "Math Operators", "Sign of scalar or each vector component" )] - public sealed class SignOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "sign"; - m_previewShaderGUID = "3aca80b49aadf5046b7133730818e18f"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT , - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR , - WirePortDataType.INT); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs.meta deleted file mode 100644 index 1a1d0ff6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SignOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 429f407c2b590df45b215f0edfa49b97 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs deleted file mode 100644 index 4726b848..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Simplified Fmod", "Math Operators", "Floating point remainder of x/y" )] - public sealed class SimplifiedFModOpNode : DynamicTypeNode - { - private const string FmodCustomOp = "frac({0}/{1})*{1}"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_previewShaderGUID = "2688236fb4f37ce47b81cc818c53321d"; - } - - 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 ); - RegisterLocalVariable( 0, string.Format( FmodCustomOp, m_inputA, m_inputB ), ref dataCollector, ( "fmodResult" + OutputId ) ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs.meta deleted file mode 100644 index 77efda87..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SimplifiedFModOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f186e1b03a8ee2b4b9e45918576e8cf6 -timeCreated: 1484731588 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs deleted file mode 100644 index 6d0d363b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Sin", "Trigonometry Operators", "Sine of scalars and vectors" )] - public sealed class SinOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "sin"; - m_previewShaderGUID = "bcd9f8749ddd3ac4f94f4c2071c1d0d4"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs.meta deleted file mode 100644 index 24e23e66..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: be2a11b08ee8cbb458dbcc4c1a61ad1b -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs deleted file mode 100644 index 4af0cba4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - - -namespace AmplifyShaderEditor -{ - [Serializable] - public class SingleInputOp : ParentNode - { - - [SerializeField] - protected string m_opName; - //[SerializeField] - //protected int m_validTypes; - - protected bool m_autoUpdateOutputPort = true; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - //m_validTypes = 0; - m_useInternalPortData = true; - - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - m_inputPorts[ 0 ].MatchPortToConnection(); - if ( m_autoUpdateOutputPort ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - m_inputPorts[ 0 ].MatchPortToConnection(); - if ( m_autoUpdateOutputPort ) - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, 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 result = "0"; - if ( m_inputPorts[ 0 ].IsConnected ) - { - ParentNode node = m_inputPorts[ 0 ].GetOutputNode(); - int localOutputId = m_inputPorts[ 0 ].ExternalReferences[ 0 ].PortId; - result = m_opName + "( " + node.GenerateShaderForOutput( localOutputId, ref dataCollector, ignoreLocalvar ) + " )"; - } - else - { - result = m_opName + "( " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + " )"; - } - - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs.meta deleted file mode 100644 index 751db40f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SingleInputOp.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ed03e964ff9aa274cbf392769b61170b -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs deleted file mode 100644 index f38a192a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Sinh", "Trigonometry Operators", "Hyperbolic sine of scalars and vectors" )] - public sealed class SinhOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "sinh"; - m_previewShaderGUID = "4e9c00e6dceb4024f80d4e3d7786abad"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs.meta deleted file mode 100644 index 292ae67c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SinhOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 52092e3985c556943895f86c585bcd25 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs deleted file mode 100644 index 09d86cb0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Smoothstep", "Math Operators", "Returns a smooth Hermite interpolation between 0 and 1, if input is in the range [min, max]." )] - public sealed class SmoothstepOpNode : ParentNode - { - //[UnityEngine.SerializeField] - //private WirePortDataType m_mainDataType = WirePortDataType.FLOAT; - - private int m_alphaPortId = 0; - private int m_minPortId = 0; - private int m_maxPortId = 0; - private const string SmoothstepOpFormat = "smoothstep( {0} , {1} , {2})";//min max alpha - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, Constants.EmptyPortValue, -1, MasterNodePortCategory.Fragment, 0 ); - m_alphaPortId = m_inputPorts.Count - 1; - AddInputPort( WirePortDataType.FLOAT, false, "Min", -1, MasterNodePortCategory.Fragment, 1 ); - m_minPortId = m_inputPorts.Count - 1; - AddInputPort( WirePortDataType.FLOAT, false, "Max", -1, MasterNodePortCategory.Fragment, 2 ); - m_maxPortId = m_inputPorts.Count - 1; - - GetInputPortByUniqueId( m_maxPortId ).FloatInternalData = 1; - - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_useInternalPortData = true; - m_textLabelWidth = 55; - m_previewShaderGUID = "954cdd40a7a528344a0a4d3ff1db5176"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( portId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - if( outputPortId == 0 ) - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - } - - //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 ); - // UpdateConnection( portId ); - //} - - //void UpdateConnection( int portId ) - //{ - // WirePortDataType type1 = WirePortDataType.FLOAT; - // if( m_inputPorts[ m_minPortId ].IsConnected ) - // type1 = m_inputPorts[ m_minPortId ].GetOutputConnection( 0 ).DataType; - - // WirePortDataType type2 = WirePortDataType.FLOAT; - // if( m_inputPorts[ m_maxPortId ].IsConnected ) - // type2 = m_inputPorts[ m_maxPortId ].GetOutputConnection( 0 ).DataType; - - // m_mainDataType = UIUtils.GetPriority( type1 ) > UIUtils.GetPriority( type2 ) ? type1 : type2; - - // if( !m_inputPorts[ m_minPortId ].IsConnected && !m_inputPorts[ m_maxPortId ].IsConnected && m_inputPorts[ m_alphaPortId ].IsConnected ) - // m_mainDataType = m_inputPorts[ m_alphaPortId ].GetOutputConnection( 0 ).DataType; - - // m_inputPorts[ m_minPortId ].ChangeType( m_mainDataType, false ); - - // m_inputPorts[ m_maxPortId ].ChangeType( m_mainDataType, false ); - // if( m_inputPorts[ m_alphaPortId ].IsConnected && m_inputPorts[ m_alphaPortId ].GetOutputConnection( 0 ).DataType == WirePortDataType.FLOAT ) - // m_inputPorts[ m_alphaPortId ].ChangeType( WirePortDataType.FLOAT, false ); - // else - // m_inputPorts[ m_alphaPortId ].ChangeType( m_mainDataType, false ); - - // m_outputPorts[ 0 ].ChangeType( m_mainDataType, 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 aValue = m_inputPorts[ m_minPortId ].GeneratePortInstructions( ref dataCollector ); - string bValue = m_inputPorts[ m_maxPortId ].GeneratePortInstructions( ref dataCollector ); - string interp = m_inputPorts[ m_alphaPortId ].GeneratePortInstructions( ref dataCollector ); - - string result = string.Format( SmoothstepOpFormat, aValue, bValue, interp ); - - RegisterLocalVariable( 0, result, ref dataCollector, "smoothstepResult" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs.meta deleted file mode 100644 index 98387ebd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SmoothstepOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0f64eb769f843a349a0d249beacc6fc3 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs deleted file mode 100644 index e35c1b25..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Sqrt", "Math Operators", "Square root of scalars and vectors" )] - public sealed class SqrtOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "sqrt"; - m_previewShaderGUID = "1791e2fbf36af084da7ecfc289e89b6e"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs.meta deleted file mode 100644 index 164b7c59..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/SqrtOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4820b591b73a7fe4ab13261deebf76f7 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs deleted file mode 100644 index ab1a1b86..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Step", "Math Operators", "Step function returning either zero or one" )] - public sealed class StepOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_previewShaderGUID = "2c757add7f97ecd4abd9ce6ec4659697"; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - return "step( " + m_inputA + " , " + m_inputB + " )"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs.meta deleted file mode 100644 index 52155547..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/StepOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c4305e64271097249a198b2e8aed3046 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs deleted file mode 100644 index 1b77ed5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Remap -// Donated by The Four Headed Cat - @fourheadedcat -using UnityEngine; -using System; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Remap", "Math Operators", "Remap value from old min - max range to new min - max range", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCRemapNode : DynamicTypeNode - { - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].Name = Constants.EmptyPortValue; - m_inputPorts[ 1 ].Name = "Min Old"; - AddInputPort( WirePortDataType.FLOAT, false, "Max Old" ); - m_inputPorts[ 2 ].FloatInternalData = 1; - AddInputPort( WirePortDataType.FLOAT, false, "Min New" ); - AddInputPort( WirePortDataType.FLOAT, false, "Max New" ); - m_inputPorts[ 4 ].FloatInternalData = 1; - m_textLabelWidth = 100; - m_useInternalPortData = true; - m_previewShaderGUID = "72dd1cbea889fa047b929d5191e360c0"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - UpdateConnections(); - } - - public override void OnConnectedOutputNodeChanges( int outputPortId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( outputPortId, otherNodeId, otherPortId, name, type ); - UpdateConnections(); - } - - void UpdateConnections() - { - m_inputPorts[ 0 ].MatchPortToConnection(); - m_inputPorts[ 1 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 2 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 3 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_inputPorts[ 4 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - m_outputPorts[ 0 ].ChangeType( m_inputPorts[ 0 ].DataType, false ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string oldMin = m_inputPorts[ 1 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true ); - string oldMax = m_inputPorts[ 2 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true ); - string newMin = m_inputPorts[ 3 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true ); - string newMax = m_inputPorts[ 4 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar, true ); - string strout = "(" + newMin + " + (" + value + " - " + oldMin + ") * (" + newMax + " - " + newMin + ") / (" + oldMax + " - " + oldMin + "))"; - - return CreateOutputLocalVariable( 0, strout, ref dataCollector ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs.meta deleted file mode 100644 index e255ee66..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TFHCRemapNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 637508d44a97b5449a3d7223c461e58c -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs deleted file mode 100644 index 409937ea..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Tan", "Trigonometry Operators", "Tangent of scalars and vectors" )] - public sealed class TanOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "tan"; - m_previewShaderGUID = "312e291832cac5749a3626547dfc8607"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs.meta deleted file mode 100644 index e78333f8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 535b4367719ca2146bb7ddac217dad94 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs deleted file mode 100644 index e9f88faf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Tanh", "Trigonometry Operators", "Hyperbolic tangent of scalars and vectors" )] - public sealed class TanhOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "tanh"; - m_previewShaderGUID = "52f78d3a1c66d1c489cd63b0a9300b38"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs.meta deleted file mode 100644 index e2a2ef7f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TanhOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 792e48b83a6387a4d826d6445417372f -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs deleted file mode 100644 index c4c7e325..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - public enum CoordinateSpaces - { - Tangent, - Local, - World, - View, - Clip, - Screen - } - - [Serializable] - [NodeAttributes( "Transform Vector", "Math Operators", "Transforma a vector into another", null, KeyCode.None, false )] - public sealed class TransformVectorOpNode : ParentNode - { - [SerializeField] - private CoordinateSpaces m_source = CoordinateSpaces.Tangent; - [SerializeField] - private CoordinateSpaces m_destination = CoordinateSpaces.World; - - private const string InputTangentrStr = "float4 tangent: TANGENT"; - private const string ColorValueStr = ".tangent"; - - private const string InputNormalStr = "float3 normal : NORMAL"; - private const string NormalValueStr = ".normal"; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, Constants.EmptyPortValue ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - m_useInternalPortData = true; - } - - void AddTangentInfo( ref MasterNodeDataCollector dataCollector ) - { - dataCollector.AddToInput( UniqueId, InputTangentrStr, true ); - dataCollector.AddToInput( UniqueId, InputTangentrStr, true ); - dataCollector.AddToInput( UniqueId, InputNormalStr, true ); - dataCollector.AddToLocalVariables( UniqueId, "float3 binormal = cross( normalize( v.normal ), normalize( v.tangent.xyz ) ) * v.tangent.w;" ); - dataCollector.AddToLocalVariables( UniqueId, "float3x3 rotation = float3x3( v.tangent.xyz, binormal, v.normal );" ); - - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - - //if ( !InputPorts[ 0 ].IsConnected ) - //{ - // return UIUtils.NoConnection( this ); - //} - - string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - - - - switch ( m_source ) - { - case CoordinateSpaces.Tangent: - { - AddTangentInfo( ref dataCollector ); - switch ( m_destination ) - { - case CoordinateSpaces.Tangent: - { - return value; - } - //case eCoordinateSpaces.Local: - //{ - //} - //case eCoordinateSpaces.World: - //{ - //} - //case eCoordinateSpaces.View: - //{ - //} - } - } - break; - case CoordinateSpaces.Local: - { - switch ( m_destination ) - { - case CoordinateSpaces.Tangent: - { - AddTangentInfo( ref dataCollector ); - return "float4(mul( rotation , " + value + ".xyz ),1)"; - } - case CoordinateSpaces.Local: - { - return value; - } - case CoordinateSpaces.World: - { - return "mul( _Object2World , " + value + " )"; - } - case CoordinateSpaces.View: - { - return "mul( UNITY_MATRIX_MV , " + value + " )"; - } - } - } - break; - case CoordinateSpaces.World: - { - switch ( m_destination ) - { - //case eCoordinateSpaces.Tangent: - //{ - //} - case CoordinateSpaces.Local: - { - return "mul( _World2Object , " + value + " )"; - } - case CoordinateSpaces.World: - { - return value; - } - case CoordinateSpaces.View: - { - return "mul( UNITY_MATRIX_V , " + value + " )"; - } - } - } - break; - case CoordinateSpaces.View: - { - UIUtils.ShowMessage( UniqueId, "View as Source is not supported", MessageSeverity.Warning ); - return value; - } - } - - return UIUtils.UnknownError( this ); - } - - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_source = ( CoordinateSpaces ) Enum.Parse( typeof( CoordinateSpaces ), GetCurrentParam( ref nodeParams ) ); - m_destination = ( CoordinateSpaces ) Enum.Parse( typeof( CoordinateSpaces ), GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_source ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_destination ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs.meta deleted file mode 100644 index 3169b4e9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransformVectorOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 928c21155a9c1a74b953da2d24269035 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs deleted file mode 100644 index 6e83e512..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Transpose", "Matrix Operators", "Transpose matrix of a matrix" )] - public sealed class TransposeOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "transpose"; - m_drawPreview = false; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4 ); - m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false ); - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4x4, false ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs.meta deleted file mode 100644 index 1df556ee..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TransposeOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ba1613dad4af0da4b9f4619b90916cbf -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs deleted file mode 100644 index f190b0c8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Trunc", "Math Operators", "Largest integer not greater than a scalar or each vector component" )] - public sealed class TruncOpNode : SingleInputOp - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_opName = "trunc"; - m_previewShaderGUID = "c717aaa68f4ac9e469b15763e82933e1"; - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.INT ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs.meta deleted file mode 100644 index 9b873107..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/TruncOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5f78e9a796a94d54482caa15d4971feb -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs deleted file mode 100644 index f5610899..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public class VariablePortTypeOpNode : ParentNode - { - private const string InputTypeStr = "Input type"; - - [SerializeField] - protected WirePortDataType m_selectedType = WirePortDataType.FLOAT; - - [SerializeField] - protected WirePortDataType m_lastSelectedType = WirePortDataType.FLOAT; - - [SerializeField] - protected int _inputAmount = 1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddPorts(); - } - - void AddPorts() - { - for ( int i = 0; i < _inputAmount; i++ ) - { - AddInputPort( m_selectedType, true, i.ToString() ); - } - AddOutputPort( m_selectedType, Constants.EmptyPortValue ); - m_sizeIsDirty = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - { - EditorGUILayout.LabelField( InputTypeStr ); - m_selectedType = ( WirePortDataType ) EditorGUILayoutEnumPopup( m_selectedType ); - } - EditorGUILayout.EndVertical(); - if ( m_selectedType != m_lastSelectedType ) - { - m_lastSelectedType = m_selectedType; - - DeleteAllInputConnections( true ); - DeleteAllOutputConnections( true ); - - AddPorts(); - - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedType ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedType = ( WirePortDataType ) Enum.Parse( typeof( WirePortDataType ), GetCurrentParam( ref nodeParams ) ); - m_lastSelectedType = m_selectedType; - DeleteAllInputConnections( true ); - DeleteAllOutputConnections( true ); - AddPorts(); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs.meta deleted file mode 100644 index f0328b05..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Operators/VariablePortTypeOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 97be7adea7b8ae44c9bebb753277e0c2 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs deleted file mode 100644 index 179413d5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs +++ /dev/null @@ -1,3778 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - public enum PreviewLocation - { - Auto, - TopCenter, - BottomCenter, - Left, - Right - } - - public enum NodeMessageType - { - Error, - Warning, - Info - } - - [Serializable] - public class ParentNode : UndoParentNode, ISerializationCallbackReceiver - { - public const int PreviewWidth = 128; - public const int PreviewHeight = 128; - - protected readonly string[] PrecisionLabels = { "Float", "Half" }; - protected readonly string[] PrecisionLabelsExtra = { "Float", "Half", "Inherit" }; - - private const double NodeClickTime = 0.2; - protected GUIContent PrecisionContent = new GUIContent( "Precision", "Changes the precision of internal calculations, using lower types saves some performance\nDefault: Float" ); - private const int MoveCountBuffer = 3;// When testing for stopped movement we need to take Layout and Repaint into account for them not to interfere with tests - private const float MinInsideBoxWidth = 20; - private const float MinInsideBoxHeight = 10; - - private const string WikiLinkStr = "online reference"; - - public delegate void OnNodeEvent( ParentNode node, bool testOnlySelected, InteractionMode interactionMode ); - public delegate void OnNodeGenericEvent( ParentNode node ); - public delegate void OnNodeReOrder( ParentNode node, int index ); - public delegate void DrawPropertySection(); - public delegate void OnSRPAction( int outputId, ref MasterNodeDataCollector dataCollector ); - - [SerializeField] - protected PrecisionType m_currentPrecisionType = PrecisionType.Inherit; - - [SerializeField] - protected bool m_customPrecision = false; - - [SerializeField] - protected InteractionMode m_defaultInteractionMode = InteractionMode.Other; - - public event OnNodeEvent OnNodeStoppedMovingEvent; - public OnNodeGenericEvent OnNodeChangeSizeEvent; - public OnNodeGenericEvent OnNodeDestroyedEvent; - public event OnNodeReOrder OnNodeReOrderEvent; - public OnSRPAction OnLightweightAction; - public OnSRPAction OnHDAction; - - [SerializeField] - private int m_uniqueId; - - [SerializeField] - protected Rect m_position; - - [SerializeField] - protected Rect m_unpreviewedPosition; - - [SerializeField] - protected GUIContent m_content; - - [SerializeField] - protected GUIContent m_additionalContent; - - [SerializeField] - protected bool m_initialized; - - [SerializeField] - protected NodeConnectionStatus m_connStatus; - protected bool m_selfPowered = false; - - [SerializeField] - protected int m_activeConnections; - - [SerializeField] - protected System.Type m_activeType; - - [SerializeField] - protected int m_activePort; - - [SerializeField] - protected int m_activeNode; - - protected NodeRestrictions m_restrictions; - - [SerializeField] - protected Color m_statusColor; - - [SerializeField] - protected Rect m_propertyDrawPos; - - // Ports - [SerializeField] - protected List<InputPort> m_inputPorts = new List<InputPort>(); - - protected Dictionary<int, InputPort> m_inputPortsDict = new Dictionary<int, InputPort>(); - - [SerializeField] - protected List<OutputPort> m_outputPorts = new List<OutputPort>(); - - protected Dictionary<int, OutputPort> m_outputPortsDict = new Dictionary<int, OutputPort>(); - - [SerializeField] - protected Rect m_globalPosition; - - [SerializeField] - protected Rect m_headerPosition; - - //private Vector2 m_tooltipOffset; - - [SerializeField] - protected bool m_sizeIsDirty = false; - - [SerializeField] - protected Vector2 m_extraSize; - - [SerializeField] - protected Vector2 m_insideSize; - - [SerializeField] - protected float m_fontHeight; - - // Editor State save on Play Button - [SerializeField] - protected bool m_isDirty; - - [SerializeField] - private int m_isMoving = 0; - [SerializeField] - private Rect m_lastPosition; - - // Live Shader Gen - [SerializeField] - private bool m_saveIsDirty; - - [SerializeField] - protected bool m_requireMaterialUpdate = false; - - [SerializeField] - protected int m_commentaryParent = -1; - - [SerializeField] - protected int m_depth = -1; - - [SerializeField] - protected bool m_materialMode = false; - - [SerializeField] - protected bool m_showPreview = false; - - [SerializeField] - protected int m_previewMaterialPassId = -1; - - protected bool m_useSquareNodeTitle = false; - - [SerializeField] - protected bool m_continuousPreviewRefresh = false; - private bool m_previewIsDirty = true; - - // Error Box Messages - private Rect m_errorBox; - private bool m_previousErrorMessage = false; - protected bool m_showErrorMessage = false; - protected NodeMessageType m_errorMessageTypeIsError = NodeMessageType.Error; - protected string m_errorMessageTooltip = string.Empty; - - private GUIContent m_errorIcon = new GUIContent(); - private GUIContent m_errorMessage = new GUIContent(); - private GUIStyle m_errorCurrentStyle; - - private const string ErrorTitle = "ERROR"; - private const string WarningTitle = "WARNING"; - private const string InfoTitle = "INFO"; - - // Drawing Node - protected PreviewLocation m_selectedLocation = PreviewLocation.Auto; - private int m_extraHeaderHeight = 0; - protected bool m_isVisible; - protected bool m_selected = false; - protected bool m_rmbIgnore; - protected GUIContent m_sizeContentAux; - - protected uint m_currentReadParamIdx = 1; - protected bool m_reorderLocked = false; - - protected Rect m_cachedPos; - protected Vector2 m_accumDelta = Vector2.zero; - - private bool m_isOnGrid = false; - protected bool m_useInternalPortData = false; - protected bool m_autoDrawInternalPortData = true; - protected DrawOrder m_drawOrder = DrawOrder.Default; - - protected bool m_movingInFrame = false; - protected float m_anchorAdjust = -1; - - protected Color m_headerColor; - - [SerializeField] // needs to be serialized because of Undo - protected Color m_headerColorModifier = Color.white; - - protected bool m_infiniteLoopDetected = false; - protected int m_textLabelWidth = -1; - - private bool m_linkVisibility = false; - [SerializeField] - protected bool m_hasTooltipLink = true; - - protected int m_category = 0; - - protected double m_lastTimeSelected; - private double m_tooltipTimestamp; - protected string m_tooltipText; - - protected Rect m_unscaledRemainingBox; - protected Rect m_remainingBox; - - private int m_visibleInputs = 0; - private int m_visibleOutputs = 0; - - private double m_doubleClickTimestamp; - private const double DoubleClickTime = 0.25; - - protected bool m_canExpand = true; - - protected bool m_firstDraw = true; - - protected int m_matrixId = -1; - - private float m_paddingTitleLeft = 0; - private float m_paddingTitleRight = 0; - - // Preview Fields - private Material m_previewMaterial = null; - private Shader m_previewShader = null; - protected string m_previewShaderGUID = string.Empty; - protected float m_marginPreviewLeft = 0; - protected bool m_globalShowPreview = false; - protected Rect m_unscaledPreviewRect; - protected Rect m_previewRect; - protected bool m_drawPreviewMaskButtons = true; - private int m_channelNumber = 0; - protected bool m_firstPreviewDraw = true; - [SerializeField] - protected bool m_drawPreview = true; - protected bool m_drawPreviewExpander = true; - private bool m_spherePreview = false; - protected bool m_drawPreviewAsSphere = false; - protected bool m_forceDrawPreviewAsPlane = false; - private bool m_finishPreviewRender = false; - - private int m_cachedMainTexId = -1; - private int m_cachedMaskTexId = -1; - private int m_cachedPortsId = -1; - private int m_cachedPortId = -1; - - private int m_cachedDrawSphereId = -1; - private int m_cachedInvertedZoomId = -1; - //private int m_cachedIsLinearId = -1; - - private bool[] m_previewChannels = { true, true, true, false }; - - // Others - protected bool m_hasSubtitle = false; - protected bool m_showSubtitle = true; - protected bool m_hasLeftDropdown = false; - protected bool m_autoWrapProperties = false; - protected bool m_internalDataFoldout = true; - protected bool m_propertiesFoldout = true; - protected bool m_repopulateDictionaries = true; - - protected Vector2 m_lastInputBottomRight = Vector2.zero; - protected Vector2 m_lastOutputBottomLeft = Vector2.zero; - - private Vector4 m_portMask = Vector4.zero; - - private Vector2 m_auxVector2 = Vector4.zero; - protected Rect m_auxRect; - - protected PreviewLocation m_autoLocation; - protected Rect m_titlePos; - protected Rect m_addTitlePos; - protected Rect m_expandRect; - protected Rect m_dropdownRect; - protected Rect m_currInputPortPos; - protected Rect m_currOutputPortPos; - protected Color m_colorBuffer; - - [SerializeField] - protected bool m_docking = false; - - [SerializeField] - protected int m_visiblePorts = 0; - - protected int m_graphDepth = 0; - - protected int m_oldInputCount = -1; - - protected bool m_dropdownEditing = false; - - protected bool m_isNodeBeingCopied = false; - - protected string m_previousTitle = string.Empty; - - protected string m_previousAdditonalTitle = string.Empty; - - private bool m_alive = true; - - private double m_timedUpdateInitialValue; - private double m_timedUpdateInterval; - private bool m_fireTimedUpdateRequest = false; - - public ParentNode() - { - m_position = new Rect( 0, 0, 0, 0 ); - m_content = new GUIContent( GUIContent.none ); - m_additionalContent = new GUIContent( GUIContent.none ); - CommonInit( -1 ); - } - - public ParentNode( int uniqueId, float x, float y, float width, float height ) - { - m_position = new Rect( x, y, width, height ); - m_content = new GUIContent( GUIContent.none ); - m_additionalContent = new GUIContent( GUIContent.none ); - CommonInit( uniqueId ); - } - - public virtual void OnEnable() - { - hideFlags = HideFlags.HideAndDontSave; - if( m_nodeAttribs != null ) - { - if( UIUtils.HasColorCategory( m_nodeAttribs.Category ) ) - { - m_headerColor = UIUtils.GetColorFromCategory( m_nodeAttribs.Category ); - } - else - { - if( !string.IsNullOrEmpty( m_nodeAttribs.CustomCategoryColor ) ) - { - m_headerColor = UIUtils.AddColorCategory( m_nodeAttribs.Category, m_nodeAttribs.CustomCategoryColor ); - } - } - } - - m_tooltipTimestamp = Time.realtimeSinceStartup; - hideFlags = HideFlags.DontSave; - } - - protected virtual void CommonInit( int uniqueId ) - { - m_uniqueId = uniqueId; - - m_isOnGrid = false; - ConnStatus = NodeConnectionStatus.Not_Connected; - m_inputPorts = new List<InputPort>(); - m_inputPortsDict = new Dictionary<int, InputPort>(); - - m_outputPorts = new List<OutputPort>(); - m_outputPortsDict = new Dictionary<int, OutputPort>(); - - System.Reflection.MemberInfo info = this.GetType(); - m_nodeAttribs = info.GetCustomAttributes( true )[ 0 ] as NodeAttributes; - if( m_nodeAttribs != null ) - { - m_content.text = m_nodeAttribs.Name; - //m_content.tooltip = m_nodeAttribs.Description; - m_tooltipText = m_nodeAttribs.Description; - m_selected = false; - } - - m_sizeContentAux = new GUIContent(); - m_extraSize = new Vector2( 0, 0 ); - m_insideSize = new Vector2( 0, 0 ); - m_sizeIsDirty = true; - m_initialized = true; - m_restrictions = new NodeRestrictions(); - - m_propertyDrawPos = new Rect(); - } - - public virtual void AfterCommonInit() - { - if( PreviewShader && !HasPreviewShader ) - { - m_drawPreview = false; - m_drawPreviewExpander = false; - m_canExpand = false; - } - - if( m_drawPreviewExpander || m_hasLeftDropdown ) - { - m_paddingTitleRight += Constants.PreviewExpanderWidth + Constants.IconsLeftRightMargin; - m_paddingTitleLeft = Constants.PreviewExpanderWidth + Constants.IconsLeftRightMargin; - } - } - - public virtual void Destroy() - { - m_alive = false; - if( OnNodeDestroyedEvent != null ) - { - OnNodeDestroyedEvent( this ); - OnNodeDestroyedEvent = null; - } - - OnLightweightAction = null; - OnHDAction = null; - - OnNodeStoppedMovingEvent = null; - OnNodeChangeSizeEvent = null; - OnNodeReOrderEvent = null; - if( m_restrictions != null ) - m_restrictions.Destroy(); - m_restrictions = null; - - if( m_inputPorts != null ) - { - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - m_inputPorts[ i ].Destroy(); - } - m_inputPorts.Clear(); - m_inputPorts = null; - } - - if( m_outputPorts != null ) - { - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPorts[ i ].Destroy(); - } - m_outputPorts.Clear(); - m_outputPorts = null; - } - - if( m_inputPortsDict != null ) - m_inputPortsDict.Clear(); - - m_inputPortsDict = null; - - if( m_outputPortsDict != null ) - m_outputPortsDict.Clear(); - - m_outputPortsDict = null; - - if( m_previewMaterial != null ) - DestroyImmediate( m_previewMaterial ); - m_previewMaterial = null; - - m_previewShader = null; - //m_containerGraph = null; - } - - public virtual void Move( Vector2 delta ) - { - if( m_docking ) - return; - - Move( delta, false ); - } - - public virtual void Move( Vector2 delta, bool snap ) - { - if( m_docking ) - return; - - if( m_isMoving == 0 ) - { - m_cachedPos = m_position; - m_accumDelta = Vector2.zero; - } - - m_isMoving = MoveCountBuffer; - m_accumDelta += delta; - - if( snap ) - { - m_position.x = Mathf.Round( ( m_cachedPos.x + m_accumDelta.x ) / 16 ) * 16; - m_position.y = Mathf.Round( ( m_cachedPos.y + m_accumDelta.y ) / 16 ) * 16; - } - else - { - m_position.x += delta.x; - m_position.y += delta.y; - } - //if(Event.current.type == EventType.Layout) - m_movingInFrame = true; - } - - public virtual void UpdateMaterial( Material mat ) - { - m_requireMaterialUpdate = false; - } - - public virtual void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - m_materialMode = ( mat != null ); - } - - public virtual bool UpdateShaderDefaults( ref Shader shader, ref TextureDefaultsDataColector defaultCol ) { return false; } - public virtual void ForceUpdateFromMaterial( Material material ) { } - public void SetSaveIsDirty() - { - if( m_connStatus == NodeConnectionStatus.Connected ) - { - SaveIsDirty = true; - } - } - - public void ActivateNodeReordering( int index ) - { - if( OnNodeReOrderEvent != null ) - OnNodeReOrderEvent( this, index ); - } - - void RecalculateInputPortIdx() - { - m_inputPortsDict.Clear(); - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - int nodeId = m_inputPorts[ i ].ExternalReferences[ 0 ].NodeId; - int portId = m_inputPorts[ i ].ExternalReferences[ 0 ].PortId; - ParentNode node = UIUtils.GetNode( nodeId ); - if( node != null ) - { - OutputPort outputPort = node.GetOutputPortByUniqueId( portId ); - int outputCount = outputPort.ExternalReferences.Count; - for( int j = 0; j < outputCount; j++ ) - { - if( outputPort.ExternalReferences[ j ].NodeId == m_uniqueId && - outputPort.ExternalReferences[ j ].PortId == m_inputPorts[ i ].PortId ) - { - outputPort.ExternalReferences[ j ].PortId = i; - } - } - } - } - m_inputPorts[ i ].PortId = i; - m_inputPortsDict.Add( i, m_inputPorts[ i ] ); - } - } - - public void SwapInputPorts( int fromIdx, int toIdx ) - { - InputPort port = m_inputPorts[ fromIdx ]; - //if( toIdx > fromIdx ) - // toIdx--; - m_inputPorts.Remove( port ); - m_inputPorts.Insert( toIdx, port ); - RecalculateInputPortIdx(); - SetSaveIsDirty(); - } - - public void RemoveInputPort( int idx ) - { - if( idx < m_inputPorts.Count ) - { - m_inputPortsDict.Remove( m_inputPorts[ idx ].PortId ); - m_inputPorts.RemoveAt( idx ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - } - - public void RemoveOutputPort( string name ) - { - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].Name.Equals( name ) ) - { - if( m_outputPorts[ i ].IsConnected ) - { - m_containerGraph.DeleteConnection( false, m_uniqueId, m_outputPorts[ i ].PortId, false, true ); - m_outputPortsDict.Remove( m_outputPorts[ i ].PortId ); - m_outputPorts.RemoveAt( i ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - } - } - } - - public void RemoveOutputPort( int idx, bool isArrayIndex = true ) - { - if( isArrayIndex ) - { - // idx represents a position on the output port array - if( idx < m_outputPorts.Count ) - { - if( m_outputPorts[ idx ].IsConnected ) - { - m_containerGraph.DeleteConnection( false, m_uniqueId, m_outputPorts[ idx ].PortId, false, true ); - } - - m_outputPortsDict.Remove( m_outputPorts[ idx ].PortId ); - m_outputPorts.RemoveAt( idx ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - } - else - { - // idx represents a port unique id - int count = m_outputPorts.Count; - int arrIdx = -1; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].PortId == idx ) - { - arrIdx = i; - break; - } - } - - if( arrIdx >= 0 ) - { - if( m_outputPorts[ arrIdx ].IsConnected ) - { - m_containerGraph.DeleteConnection( false, m_uniqueId, idx, false, true ); - } - - m_outputPortsDict.Remove( idx ); - m_outputPorts.RemoveAt( arrIdx ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - } - } - - // Manually add Ports - public InputPort AddInputPort( WirePortDataType type, bool typeLocked, string name, int orderId = -1, MasterNodePortCategory category = MasterNodePortCategory.Fragment, int uniquePortId = -1 ) - { - InputPort port = new InputPort( m_uniqueId, ( uniquePortId < 0 ? m_inputPorts.Count : uniquePortId ), type, name, typeLocked, ( orderId >= 0 ? orderId : m_inputPorts.Count ), category ); - m_inputPorts.Add( port ); - m_inputPortsDict.Add( port.PortId, port ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - return port; - } - - public InputPort AddInputPort( WirePortDataType type, bool typeLocked, string name, string dataName, int orderId = -1, MasterNodePortCategory category = MasterNodePortCategory.Fragment, int uniquePortId = -1 ) - { - InputPort port = new InputPort( m_uniqueId, ( uniquePortId < 0 ? m_inputPorts.Count : uniquePortId ), type, name, dataName, typeLocked, ( orderId >= 0 ? orderId : m_inputPorts.Count ), category ); - m_inputPorts.Add( port ); - m_inputPortsDict.Add( port.PortId, port ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - return port; - } - - public InputPort AddInputPortAt( int idx, WirePortDataType type, bool typeLocked, string name, int orderId = -1, MasterNodePortCategory category = MasterNodePortCategory.Fragment, int uniquePortId = -1 ) - { - InputPort port = new InputPort( m_uniqueId, ( uniquePortId < 0 ? m_inputPorts.Count : uniquePortId ), type, name, typeLocked, ( orderId >= 0 ? orderId : m_inputPorts.Count ), category ); - m_inputPorts.Insert( idx, port ); - m_inputPortsDict.Add( port.PortId, port ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - RecalculateInputPortIdx(); - return port; - } - - public void AddOutputPort( WirePortDataType type, string name, int uniquePortId = -1 ) - { - m_outputPorts.Add( new OutputPort( this, m_uniqueId, ( uniquePortId < 0 ? m_outputPorts.Count : uniquePortId ), type, name ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - - public void AddOutputPortAt( int idx, WirePortDataType type, string name, int uniquePortId = -1 ) - { - OutputPort port = new OutputPort( this, m_uniqueId, ( uniquePortId < 0 ? m_outputPorts.Count : uniquePortId ), type, name ); - m_outputPorts.Insert( idx, port ); - m_outputPortsDict.Add( port.PortId, port ); - SetSaveIsDirty(); - m_sizeIsDirty = true; - } - - public void AddOutputVectorPorts( WirePortDataType type, string name ) - { - m_sizeIsDirty = true; - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, type, name ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - - switch( type ) - { - case WirePortDataType.FLOAT2: - { - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "X" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "Y" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - } - break; - case WirePortDataType.FLOAT3: - { - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "X" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "Y" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "Z" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - } - break; - case WirePortDataType.FLOAT4: - { - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "X" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "Y" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "Z" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "W" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - } - break; - } - SetSaveIsDirty(); - } - - public void SetPreviewDirtyFromOutputs() - { - PreviewIsDirty = true; - } - - public string GetOutputVectorItem( int vectorPortId, int currentPortId, string result ) - { - if( m_outputPorts[ 0 ].DataType == WirePortDataType.COLOR ) - { - switch( currentPortId - vectorPortId ) - { - case 1: result += ".r"; break; - case 2: result += ".g"; break; - case 3: result += ".b"; break; - case 4: result += ".a"; break; - } - } - else - { - switch( currentPortId - vectorPortId ) - { - case 1: result += ".x"; break; - case 2: result += ".y"; break; - case 3: result += ".z"; break; - case 4: result += ".w"; break; - } - } - return result; - } - - public void AddOutputColorPorts( string name, bool addAlpha = true ) - { - m_sizeIsDirty = true; - //Main port - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, addAlpha ? WirePortDataType.COLOR : WirePortDataType.FLOAT3, name ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - - //Color components port - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "R" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts[ m_outputPorts.Count - 1 ].CustomColor = Color.red; - - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "G" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts[ m_outputPorts.Count - 1 ].CustomColor = Color.green; - - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "B" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts[ m_outputPorts.Count - 1 ].CustomColor = Color.blue; - - if( addAlpha ) - { - m_outputPorts.Add( new OutputPort( this, m_uniqueId, m_outputPorts.Count, WirePortDataType.FLOAT, "A" ) ); - m_outputPortsDict.Add( m_outputPorts[ m_outputPorts.Count - 1 ].PortId, m_outputPorts[ m_outputPorts.Count - 1 ] ); - m_outputPorts[ m_outputPorts.Count - 1 ].CustomColor = Color.white; - } - } - - public void ConvertFromVectorToColorPorts() - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.COLOR, false ); - - m_outputPorts[ 1 ].Name = "R"; - m_outputPorts[ 1 ].CustomColor = Color.red; - - m_outputPorts[ 2 ].Name = "G"; - m_outputPorts[ 2 ].CustomColor = Color.green; - - m_outputPorts[ 3 ].Name = "B"; - m_outputPorts[ 3 ].CustomColor = Color.blue; - - m_outputPorts[ 4 ].Name = "A"; - m_outputPorts[ 4 ].CustomColor = Color.white; - } - - - public string GetOutputColorItem( int vectorPortId, int currentPortId, string result ) - { - switch( currentPortId - vectorPortId ) - { - case 1: result += ".r"; break; - case 2: result += ".g"; break; - case 3: result += ".b"; break; - case 4: result += ".a"; break; - } - return result; - } - - public void ChangeOutputType( WirePortDataType type, bool invalidateConnections ) - { - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPorts[ i ].ChangeType( type, invalidateConnections ); - } - } - - public void ChangeInputType( WirePortDataType type, bool invalidateConnections ) - { - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - m_inputPorts[ i ].ChangeType( type, invalidateConnections ); - } - } - - public void ChangeOutputProperties( int outputID, string newName, WirePortDataType newType, bool invalidateConnections = true ) - { - if( outputID < m_outputPorts.Count ) - { - m_outputPorts[ outputID ].ChangeProperties( newName, newType, invalidateConnections ); - IsDirty = true; - m_sizeIsDirty = true; - SetSaveIsDirty(); - } - } - - public void ChangeOutputName( int outputArrayIdx, string newName ) - { - if( outputArrayIdx < m_outputPorts.Count ) - { - m_outputPorts[ outputArrayIdx ].Name = newName; - IsDirty = true; - m_sizeIsDirty = true; - } - } - - public InputPort CheckInputPortAt( Vector3 pos ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].InsideActiveArea( pos ) ) - return m_inputPorts[ i ]; - } - return null; - } - - public InputPort GetFirstInputPortOfType( WirePortDataType dataType, bool countObjectTypeAsValid ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( ( m_inputPorts[ i ].CheckValidType( dataType ) ) || ( countObjectTypeAsValid && m_inputPorts[ i ].DataType == WirePortDataType.OBJECT ) ) - return m_inputPorts[ i ]; - } - return null; - } - - public OutputPort CheckOutputPortAt( Vector3 pos ) - { - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].InsideActiveArea( pos ) ) - return m_outputPorts[ i ]; - } - return null; - } - - public OutputPort GetFirstOutputPortOfType( WirePortDataType dataType, bool checkForCasts ) - { - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( ( m_outputPorts[ i ].CheckValidType( dataType ) ) || ( checkForCasts && UIUtils.CanCast( dataType, m_outputPorts[ i ].DataType ) ) ) - return m_outputPorts[ i ]; - } - return null; - } - - virtual protected void ChangeSizeFinished() { m_firstPreviewDraw = true; /*MarkForPreviewUpdate();*/ } - protected void ChangeSize() - { - m_cachedPos = m_position; - //UIUtils.ResetMainSkin(); - - Vector2 inSize = Vector2.zero; - int inputCount = 0; - int inputSize = m_inputPorts.Count; - for( int i = 0; i < inputSize; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - if( m_inputPorts[ i ].DirtyLabelSize || m_inputPorts[ i ].LabelSize == Vector2.zero ) - { - m_inputPorts[ i ].DirtyLabelSize = false; - m_sizeContentAux.text = m_inputPorts[ i ].Name; - m_inputPorts[ i ].UnscaledLabelSize = UIUtils.UnZoomedInputPortStyle.CalcSize( m_sizeContentAux ); - } - - inSize.x = Mathf.Max( inSize.x, m_inputPorts[ i ].UnscaledLabelSize.x ); - inSize.y = Mathf.Max( inSize.y, m_inputPorts[ i ].UnscaledLabelSize.y ); - inputCount += 1; - } - } - if( inSize.x > 0 ) - inSize.x += UIUtils.PortsSize.x + Constants.PORT_TO_LABEL_SPACE_X * 2; - inSize.x += m_marginPreviewLeft; - inSize.y = Mathf.Max( inSize.y, UIUtils.PortsSize.y ); - - - Vector2 outSize = Vector2.zero; - int outputCount = 0; - int outputSize = m_outputPorts.Count; - for( int i = 0; i < outputSize; i++ ) - { - if( m_outputPorts[ i ].Visible ) - { - if( m_outputPorts[ i ].DirtyLabelSize || m_outputPorts[ i ].LabelSize == Vector2.zero ) - { - m_outputPorts[ i ].DirtyLabelSize = false; - m_sizeContentAux.text = m_outputPorts[ i ].Name; - m_outputPorts[ i ].UnscaledLabelSize = UIUtils.UnZoomedOutputPortPortStyle.CalcSize( m_sizeContentAux ); - } - - outSize.x = Mathf.Max( outSize.x, m_outputPorts[ i ].UnscaledLabelSize.x ); - outSize.y = Mathf.Max( outSize.y, m_outputPorts[ i ].UnscaledLabelSize.y ); - outputCount += 1; - } - } - if( outSize.x > 0 ) - outSize.x += UIUtils.PortsSize.x + Constants.PORT_TO_LABEL_SPACE_X * 2; - outSize.y = Mathf.Max( outSize.y, UIUtils.PortsSize.y ); - - if( m_additionalContent.text.Length > 0 ) - { - m_extraHeaderHeight = (int)Constants.NODE_HEADER_EXTRA_HEIGHT; - m_hasSubtitle = true && m_showSubtitle; - } - else - { - m_extraHeaderHeight = 0; - m_hasSubtitle = false; - } - - float headerWidth = Mathf.Max( UIUtils.UnZoomedNodeTitleStyle.CalcSize( m_content ).x + m_paddingTitleLeft + m_paddingTitleRight, UIUtils.UnZoomedPropertyValuesTitleStyle.CalcSize( m_additionalContent ).x + m_paddingTitleLeft + m_paddingTitleRight ); - m_position.width = Mathf.Max( headerWidth, Mathf.Max( MinInsideBoxWidth, m_insideSize.x ) + inSize.x + outSize.x ) + Constants.NODE_HEADER_LEFTRIGHT_MARGIN * 2; - //m_position.width += m_extraSize.x; - - m_fontHeight = Mathf.Max( inSize.y, outSize.y ); - - m_position.height = Mathf.Max( inputCount, outputCount ) * ( m_fontHeight + Constants.INPUT_PORT_DELTA_Y );// + Constants.INPUT_PORT_DELTA_Y; - m_position.height = Mathf.Max( m_position.height, Mathf.Max( MinInsideBoxHeight, m_insideSize.y ) ); - m_position.height += UIUtils.HeaderMaxHeight + m_extraHeaderHeight + Constants.INPUT_PORT_DELTA_Y;// + m_extraSize.y; - if( m_showErrorMessage ) - m_position.height += 24; - - m_unpreviewedPosition = m_position; - //UIUtils.CurrentWindow.CameraDrawInfo.InvertedZoom = cachedZoom; - if( OnNodeChangeSizeEvent != null ) - { - OnNodeChangeSizeEvent( this ); - } - ChangeSizeFinished(); - } - - public virtual void Reset() { } - public virtual void OnOutputPortConnected( int portId, int otherNodeId, int otherPortId ) { } - - public virtual void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - InputPort port = GetInputPortByUniqueId( portId ); - if( activateNode && m_connStatus == NodeConnectionStatus.Connected ) - { - port.GetOutputNode().ActivateNode( m_activeNode, m_activePort, m_activeType ); - } - - PreviewIsDirty = true; - OnNodeChange(); - SetSaveIsDirty(); - } - - public virtual void OnInputPortDisconnected( int portId ) { PreviewIsDirty = true; OnNodeChange(); } - public virtual void OnOutputPortDisconnected( int portId ) { } - - public virtual void OnNodeChange() - { - CheckSpherePreview(); - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - for( int f = 0; f < m_outputPorts[ i ].ExternalReferences.Count; f++ ) - { - ContainerGraph.GetNode( m_outputPorts[ i ].ExternalReferences[ f ].NodeId ).OnNodeChange(); - } - } - } - } - - public virtual void ActivateNode( int signalGenNodeId, int signalGenPortId, System.Type signalGenNodeType ) - { - if( m_selfPowered ) - return; - - ConnStatus = m_restrictions.GetRestiction( signalGenNodeType, signalGenPortId ) ? NodeConnectionStatus.Error : NodeConnectionStatus.Connected; - m_activeConnections += 1; - - if( m_activeConnections == 1 ) - { - m_activeType = signalGenNodeType; - m_activeNode = signalGenNodeId; - m_activePort = signalGenPortId; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].GetOutputNode().ActivateNode( signalGenNodeId, signalGenPortId, signalGenNodeType ); - } - } - } - // saveisdirty might be needed, gonna leave this here for now - // SetSaveIsDirty(); - } - - public virtual void DeactivateInputPortNode( int deactivatedPort, bool forceComplete ) - { - GetInputPortByUniqueId( deactivatedPort ).GetOutputNode().DeactivateNode( deactivatedPort, false ); - } - - public virtual void DeactivateNode( int deactivatedPort, bool forceComplete ) - { - if( m_selfPowered ) - return; - - // saveisdirty might be needed, gonna leave this here for now - // SetSaveIsDirty(); - m_activeConnections -= 1; - if( forceComplete || m_activeConnections <= 0 ) - { - m_activeConnections = 0; - ConnStatus = NodeConnectionStatus.Not_Connected; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - ParentNode node = m_inputPorts[ i ].GetOutputNode(); - if( node != null ) - node.DeactivateNode( deactivatedPort == -1 ? m_inputPorts[ i ].PortId : deactivatedPort, false ); - } - } - } - } - - public Rect GlobalToLocalPosition( DrawInfo drawInfo ) - { - float width = m_globalPosition.width / drawInfo.InvertedZoom; - float height = m_globalPosition.height / drawInfo.InvertedZoom; - - float x = m_globalPosition.x / drawInfo.InvertedZoom - drawInfo.CameraOffset.x; - float y = m_globalPosition.y / drawInfo.InvertedZoom - drawInfo.CameraOffset.y; - return new Rect( x, y, width, height ); - } - - protected void CalculatePositionAndVisibility( DrawInfo drawInfo ) - { - //m_movingInFrame = false; - m_globalPosition = m_position; - m_globalPosition.x = drawInfo.InvertedZoom * ( m_globalPosition.x + drawInfo.CameraOffset.x ); - m_globalPosition.y = drawInfo.InvertedZoom * ( m_globalPosition.y + drawInfo.CameraOffset.y ); - m_globalPosition.width *= drawInfo.InvertedZoom; - m_globalPosition.height *= drawInfo.InvertedZoom; - - m_isVisible = ( m_globalPosition.x + m_globalPosition.width > 0 ) && - ( m_globalPosition.x < drawInfo.CameraArea.width ) && - ( m_globalPosition.y + m_globalPosition.height > 0 ) && - ( m_globalPosition.y < drawInfo.CameraArea.height ); - - if( m_isMoving > 0 && drawInfo.CurrentEventType != EventType.MouseDrag ) - { - float deltaX = Mathf.Abs( m_lastPosition.x - m_position.x ); - float deltaY = Mathf.Abs( m_lastPosition.y - m_position.y ); - if( deltaX < 0.01f && deltaY < 0.01f ) - { - m_isMoving -= 1; - if( m_isMoving == 0 ) - { - OnSelfStoppedMovingEvent(); - } - } - else - { - m_isMoving = MoveCountBuffer; - } - m_lastPosition = m_position; - } - } - - public void FireStoppedMovingEvent( bool testOnlySelected, InteractionMode interactionMode ) - { - if( OnNodeStoppedMovingEvent != null ) - OnNodeStoppedMovingEvent( this, testOnlySelected, interactionMode ); - } - - public virtual void OnSelfStoppedMovingEvent() - { - FireStoppedMovingEvent( true, m_defaultInteractionMode ); - } - - protected void DrawPrecisionProperty( bool withInherit = true ) - { - if( withInherit ) - m_currentPrecisionType = (PrecisionType)EditorGUILayoutPopup( PrecisionContent.text, (int)m_currentPrecisionType, PrecisionLabelsExtra ); - else - m_currentPrecisionType = (PrecisionType)EditorGUILayoutPopup( PrecisionContent.text, (int)m_currentPrecisionType, PrecisionLabels ); - } - - public virtual void DrawTitle( Rect titlePos ) - { - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - GUI.Label( titlePos, m_content, UIUtils.GetCustomStyle( CustomStyle.NodeTitle ) ); - } - } - - public virtual void DrawPreview( DrawInfo drawInfo, Rect rect ) - { - //if ( !m_drawPreview ) - // return; - - if( m_cachedDrawSphereId == -1 ) - m_cachedDrawSphereId = Shader.PropertyToID( "_DrawSphere" ); - - if( m_cachedInvertedZoomId == -1 ) - m_cachedInvertedZoomId = Shader.PropertyToID( "_InvertedZoom" ); - - m_channelNumber = 0; - Vector4 mask = Vector4.one; - if( m_outputPorts.Count > 0 ) - { - switch( m_outputPorts[ 0 ].DataType ) - { - case WirePortDataType.FLOAT: - m_channelNumber = 1; - mask.Set( 1, 1, 1, 0 ); - break; - case WirePortDataType.FLOAT2: - m_channelNumber = 2; - mask.Set( m_previewChannels[ 0 ] ? 1 : 0, m_previewChannels[ 1 ] ? 1 : 0, 1, 0 ); - break; - case WirePortDataType.COLOR: - case WirePortDataType.FLOAT4: - case WirePortDataType.SAMPLER1D: - case WirePortDataType.SAMPLER2D: - case WirePortDataType.SAMPLER3D: - case WirePortDataType.SAMPLERCUBE: - m_channelNumber = 4; - mask.Set( m_previewChannels[ 0 ] ? 1 : 0, m_previewChannels[ 1 ] ? 1 : 0, m_previewChannels[ 2 ] ? 1 : 0, m_previewChannels[ 3 ] ? 1 : 0 ); - break; - default: - m_channelNumber = 3; - mask.Set( m_previewChannels[ 0 ] ? 1 : 0, m_previewChannels[ 1 ] ? 1 : 0, m_previewChannels[ 2 ] ? 1 : 0, 0 ); - break; - } - } - - UIUtils.LinearMaterial.SetFloat( m_cachedDrawSphereId, ( SpherePreview ? 1 : 0 ) ); - UIUtils.LinearMaterial.SetFloat( m_cachedInvertedZoomId, drawInfo.InvertedZoom ); - UIUtils.LinearMaterial.SetVector( "_Mask", mask ); - - bool cached = GL.sRGBWrite; - GL.sRGBWrite = true; - //EditorGUI.DrawPreviewTexture( rect, PreviewTexture, UIUtils.LinearMaterial ); - int pass = 0; - if( SpherePreview ) - { - if( mask.w == 1 ) - pass = 3; - else - pass = 1; - } - else if( mask.w == 1 ) - pass = 2; - - Graphics.DrawTexture( rect, PreviewTexture, UIUtils.LinearMaterial, pass ); - GL.sRGBWrite = cached; - //Preview buttons - if( m_drawPreviewMaskButtons ) - DrawPreviewMaskButtonsRepaint( drawInfo, rect ); - } - - protected void DrawPreviewMaskButtonsLayout( DrawInfo drawInfo, Rect rect ) - { - if( rect.Contains( drawInfo.MousePosition ) && m_channelNumber > 1 && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - Rect buttonRect = rect; - buttonRect.height = 14 * drawInfo.InvertedZoom; - buttonRect.y = rect.yMax - buttonRect.height; - buttonRect.width = 14 * drawInfo.InvertedZoom; - - if( m_channelNumber == 2 ) - { - m_previewChannels[ 0 ] = GUI.Toggle( buttonRect, m_previewChannels[ 0 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 1 ] = GUI.Toggle( buttonRect, m_previewChannels[ 1 ], string.Empty, GUIStyle.none ); - } - else if( m_channelNumber == 3 ) - { - m_previewChannels[ 0 ] = GUI.Toggle( buttonRect, m_previewChannels[ 0 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 1 ] = GUI.Toggle( buttonRect, m_previewChannels[ 1 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 2 ] = GUI.Toggle( buttonRect, m_previewChannels[ 2 ], string.Empty, GUIStyle.none ); - } - else if( m_channelNumber == 4 ) - { - m_previewChannels[ 0 ] = GUI.Toggle( buttonRect, m_previewChannels[ 0 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 1 ] = GUI.Toggle( buttonRect, m_previewChannels[ 1 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 2 ] = GUI.Toggle( buttonRect, m_previewChannels[ 2 ], string.Empty, GUIStyle.none ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - m_previewChannels[ 3 ] = GUI.Toggle( buttonRect, m_previewChannels[ 3 ], string.Empty, GUIStyle.none ); - } - } - } - - protected void DrawPreviewMaskButtonsRepaint( DrawInfo drawInfo, Rect rect ) - { - if( drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 && rect.Contains( drawInfo.MousePosition ) && m_channelNumber > 1 ) - { - Rect buttonRect = rect; - buttonRect.height = 14 * drawInfo.InvertedZoom; - buttonRect.y = rect.yMax - buttonRect.height; - buttonRect.width = 14 * drawInfo.InvertedZoom; - - if( m_channelNumber == 2 ) - { - UIUtils.MiniButtonTopMid.Draw( buttonRect, "R", false, false, m_previewChannels[ 0 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopRight.Draw( buttonRect, "G", false, false, m_previewChannels[ 1 ], false ); - } - else if( m_channelNumber == 3 ) - { - UIUtils.MiniButtonTopMid.Draw( buttonRect, "R", false, false, m_previewChannels[ 0 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopMid.Draw( buttonRect, "G", false, false, m_previewChannels[ 1 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopRight.Draw( buttonRect, "B", false, false, m_previewChannels[ 2 ], false ); - } - else if( m_channelNumber == 4 ) - { - UIUtils.MiniButtonTopMid.Draw( buttonRect, "R", false, false, m_previewChannels[ 0 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopMid.Draw( buttonRect, "G", false, false, m_previewChannels[ 1 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopMid.Draw( buttonRect, "B", false, false, m_previewChannels[ 2 ], false ); - buttonRect.x += 14 * drawInfo.InvertedZoom; - UIUtils.MiniButtonTopRight.Draw( buttonRect, "A", false, false, m_previewChannels[ 3 ], false ); - } - } - } - - public void SetTimedUpdate( double timerInterval ) - { - m_timedUpdateInitialValue = EditorApplication.timeSinceStartup; - m_timedUpdateInterval = timerInterval; - m_fireTimedUpdateRequest = true; - } - - public virtual void FireTimedUpdate() { } - /// <summary> - /// - /// </summary> - /// <param name="drawInfo"></param> - public virtual void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - if( m_fireTimedUpdateRequest && ( EditorApplication.timeSinceStartup - m_timedUpdateInitialValue ) > m_timedUpdateInterval ) - { - m_fireTimedUpdateRequest = false; - FireTimedUpdate(); - } - - if( m_repopulateDictionaries ) - { - m_repopulateDictionaries = false; - - m_inputPortsDict.Clear(); - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - m_inputPortsDict.Add( m_inputPorts[ i ].PortId, m_inputPorts[ i ] ); - } - - m_outputPortsDict.Clear(); - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPortsDict.Add( m_outputPorts[ i ].PortId, m_outputPorts[ i ] ); - } - } - } - - /// <summary> - /// This method should only be called to calculate layouts of elements to be draw later, only runs once per frame and before wires are drawn - /// </summary> - /// <param name="drawInfo"></param> - public virtual void OnNodeLayout( DrawInfo drawInfo ) - { - - if( ContainerGraph.ChangedLightingModel ) - { - m_sizeIsDirty = true; - m_firstPreviewDraw = true; - } - - if( m_firstDraw ) - { - m_firstDraw = false; - AfterCommonInit(); - OnNodeChange(); - } - - if( m_previousErrorMessage != m_showErrorMessage ) - { - m_sizeIsDirty = true; - } - - if( m_sizeIsDirty ) - { - m_sizeIsDirty = false; - ChangeSize(); - } - - CalculatePositionAndVisibility( drawInfo ); - - m_unscaledRemainingBox = m_position; - m_remainingBox = m_globalPosition; - - m_lastInputBottomRight = m_position.position; - m_lastOutputBottomLeft = m_position.position; - m_lastOutputBottomLeft.x += m_position.width; - - m_visibleInputs = 0; - m_visibleOutputs = 0; - - if( m_hasSubtitle ) - m_extraHeaderHeight = (int)Constants.NODE_HEADER_EXTRA_HEIGHT; - else - m_extraHeaderHeight = 0; - - m_lastInputBottomRight.y += UIUtils.HeaderMaxHeight + m_extraHeaderHeight; - m_lastOutputBottomLeft.y += UIUtils.HeaderMaxHeight + m_extraHeaderHeight; - m_unscaledRemainingBox.y += UIUtils.HeaderMaxHeight + m_extraHeaderHeight; - - if( m_isVisible ) - { - // Header - m_headerPosition = m_globalPosition; - m_headerPosition.height = UIUtils.CurrentHeaderHeight + m_extraHeaderHeight * drawInfo.InvertedZoom; - - // Title - m_titlePos = m_globalPosition; - m_titlePos.height = m_headerPosition.height; - if( m_hasSubtitle ) - m_titlePos.yMin += ( 4 * drawInfo.InvertedZoom ); - else - m_titlePos.yMin += ( 7 * drawInfo.InvertedZoom ); - m_titlePos.width -= ( m_paddingTitleLeft + m_paddingTitleRight ) * drawInfo.InvertedZoom; - m_titlePos.x += m_paddingTitleLeft * drawInfo.InvertedZoom; - - // Additional Title - if( m_hasSubtitle ) - { - m_addTitlePos = m_titlePos; - m_addTitlePos.y = m_globalPosition.y; - m_addTitlePos.yMin += ( 19 * drawInfo.InvertedZoom ); - } - - // Left Dropdown - if( m_hasLeftDropdown && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - m_dropdownRect = m_headerPosition; - m_dropdownRect.width = Constants.NodeButtonSizeX * drawInfo.InvertedZoom; - m_dropdownRect.x = m_globalPosition.x + ( Constants.IconsLeftRightMargin + 1 ) * drawInfo.InvertedZoom; - m_dropdownRect.height = Constants.NodeButtonSizeY * drawInfo.InvertedZoom; - m_dropdownRect.y = m_globalPosition.y + m_headerPosition.height * 0.5f - 14 * drawInfo.InvertedZoom * 0.5f; - } - - // Expander - if( m_drawPreviewExpander && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - m_expandRect = m_globalPosition; - m_expandRect.width = Constants.PreviewExpanderWidth * drawInfo.InvertedZoom; - m_expandRect.x = m_globalPosition.x + m_globalPosition.width - ( Constants.IconsLeftRightMargin + Constants.PreviewExpanderWidth ) * drawInfo.InvertedZoom; //titlePos.x + titlePos.width; - m_expandRect.height = Constants.PreviewExpanderHeight * drawInfo.InvertedZoom; - m_expandRect.y = m_globalPosition.y + m_headerPosition.height * 0.5f - Constants.PreviewExpanderHeight * drawInfo.InvertedZoom * 0.5f; - } - } - - if( m_anchorAdjust < 0 ) - { - m_anchorAdjust = UIUtils.GetCustomStyle( CustomStyle.PortEmptyIcon ).normal.background.width; - } - - m_unscaledRemainingBox.y += Constants.INPUT_PORT_DELTA_Y; - m_lastOutputBottomLeft.y += Constants.INPUT_PORT_DELTA_Y; - m_lastInputBottomRight.y += Constants.INPUT_PORT_DELTA_Y; - - // Input Ports - { - m_currInputPortPos = m_globalPosition; - m_currInputPortPos.width = drawInfo.InvertedZoom * UIUtils.PortsSize.x; - m_currInputPortPos.height = drawInfo.InvertedZoom * UIUtils.PortsSize.y; - - m_currInputPortPos.x += drawInfo.InvertedZoom * Constants.PORT_INITIAL_X; - m_currInputPortPos.y += drawInfo.InvertedZoom * Constants.PORT_INITIAL_Y + m_extraHeaderHeight * drawInfo.InvertedZoom; - int inputCount = m_inputPorts.Count; - - float initialX = m_lastInputBottomRight.x; - - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - m_visibleInputs++; - // Button - m_inputPorts[ i ].Position = m_currInputPortPos; - - // Label - m_inputPorts[ i ].LabelPosition = m_currInputPortPos; - float deltaX = 1f * drawInfo.InvertedZoom * ( UIUtils.PortsSize.x + Constants.PORT_TO_LABEL_SPACE_X ); - m_auxRect = m_inputPorts[ i ].LabelPosition; - m_auxRect.x += deltaX; - m_inputPorts[ i ].LabelPosition = m_auxRect; - - //if( m_inputPorts[ i ].DirtyLabelSize || m_inputPorts[ i ].LabelSize == Vector2.zero ) - //{ - // m_inputPorts[ i ].DirtyLabelSize = false; - // m_sizeContentAux.text = m_inputPorts[ i ].Name; - // m_inputPorts[ i ].UnscaledLabelSize = UIUtils.UnZoomedInputPortStyle.CalcSize( m_sizeContentAux ); - //} - - m_inputPorts[ i ].LabelSize = m_inputPorts[ i ].UnscaledLabelSize * drawInfo.InvertedZoom; - - m_lastInputBottomRight.x = Mathf.Max( m_lastInputBottomRight.x, initialX + m_inputPorts[ i ].UnscaledLabelSize.x + Constants.PORT_INITIAL_X + Constants.PORT_TO_LABEL_SPACE_X + UIUtils.PortsSize.x ); - - if( !m_inputPorts[ i ].Locked ) - { - float overflow = 2; - float scaledOverflow = 4 * drawInfo.InvertedZoom; - m_auxRect = m_currInputPortPos; - m_auxRect.yMin -= scaledOverflow + overflow; - m_auxRect.yMax += scaledOverflow + overflow; - m_auxRect.xMin -= Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - if( m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid ) - m_auxRect.xMax += m_inputPorts[ i ].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - else - m_auxRect.xMax += Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_inputPorts[ i ].ActivePortArea = m_auxRect; - } - m_currInputPortPos.y += drawInfo.InvertedZoom * ( m_fontHeight + Constants.INPUT_PORT_DELTA_Y ); - //GUI.Label( m_inputPorts[ i ].ActivePortArea, string.Empty, UIUtils.Box ); - } - } - if( m_visibleInputs > 0 ) - m_lastInputBottomRight.y += m_fontHeight * m_visibleInputs + Constants.INPUT_PORT_DELTA_Y * ( m_visibleInputs - 1 ); - } - - // Output Ports - { - m_currOutputPortPos = m_globalPosition; - m_currOutputPortPos.width = drawInfo.InvertedZoom * UIUtils.PortsSize.x; - m_currOutputPortPos.height = drawInfo.InvertedZoom * UIUtils.PortsSize.y; - - m_currOutputPortPos.x += ( m_globalPosition.width - drawInfo.InvertedZoom * ( Constants.PORT_INITIAL_X + m_anchorAdjust ) ); - m_currOutputPortPos.y += drawInfo.InvertedZoom * Constants.PORT_INITIAL_Y + m_extraHeaderHeight * drawInfo.InvertedZoom; - int outputCount = m_outputPorts.Count; - - float initialX = m_lastOutputBottomLeft.x; - - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].Visible ) - { - m_visibleOutputs++; - //Button - m_outputPorts[ i ].Position = m_currOutputPortPos; - - // Label - m_outputPorts[ i ].LabelPosition = m_currOutputPortPos; - float deltaX = 1f * drawInfo.InvertedZoom * ( UIUtils.PortsSize.x + Constants.PORT_TO_LABEL_SPACE_X ); - m_auxRect = m_outputPorts[ i ].LabelPosition; - m_auxRect.x -= deltaX; - m_outputPorts[ i ].LabelPosition = m_auxRect; - - m_outputPorts[ i ].LabelSize = m_outputPorts[ i ].UnscaledLabelSize * drawInfo.InvertedZoom; - - m_lastOutputBottomLeft.x = Mathf.Min( m_lastOutputBottomLeft.x, initialX - m_outputPorts[ i ].UnscaledLabelSize.x - Constants.PORT_INITIAL_X - Constants.PORT_TO_LABEL_SPACE_X - UIUtils.PortsSize.x ); - - if( !m_outputPorts[ i ].Locked ) - { - float overflow = 2; - float scaledOverflow = 4 * drawInfo.InvertedZoom; - m_auxRect = m_currOutputPortPos; - m_auxRect.yMin -= scaledOverflow + overflow; - m_auxRect.yMax += scaledOverflow + overflow; - if( m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.IsValid ) - m_auxRect.xMin -= m_outputPorts[ i ].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - else - m_auxRect.xMin -= Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_auxRect.xMax += Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow; - m_outputPorts[ i ].ActivePortArea = m_auxRect; - } - m_currOutputPortPos.y += drawInfo.InvertedZoom * ( m_fontHeight + Constants.INPUT_PORT_DELTA_Y ); - //GUI.Label( m_outputPorts[ i ].ActivePortArea, string.Empty, UIUtils.Box ); - } - } - if( m_visibleOutputs > 0 ) - m_lastOutputBottomLeft.y += m_fontHeight * m_visibleOutputs + Constants.INPUT_PORT_DELTA_Y * ( m_visibleOutputs - 1 ); - } - - m_lastInputBottomRight.x += m_marginPreviewLeft; - - //Vector2 scaledLastOutputBottomLeft = ( m_lastOutputBottomLeft + drawInfo.CameraOffset ) * drawInfo.InvertedZoom; - //GUI.Label( new Rect( scaledLastOutputBottomLeft, Vector2.one * 2 ), string.Empty, UIUtils.CurrentWindow.CustomStylesInstance.Box ); - - m_unscaledRemainingBox.xMin = m_lastInputBottomRight.x; - //m_unscaledRemainingBox.yMin = m_lastInputBottomRight.y; - m_unscaledRemainingBox.xMax = m_lastOutputBottomLeft.x; - m_unscaledRemainingBox.yMax = Mathf.Max( m_lastOutputBottomLeft.y, m_lastInputBottomRight.y ); - - m_remainingBox.position = ( m_unscaledRemainingBox.position + drawInfo.CameraOffset ) * drawInfo.InvertedZoom; - m_remainingBox.size = m_unscaledRemainingBox.size * drawInfo.InvertedZoom; - - //GUI.Label( m_remainingBox, string.Empty, UIUtils.Box ); - - if( m_visibleInputs == 0 ) - { - m_remainingBox.x += Constants.PORT_INITIAL_X * drawInfo.InvertedZoom; - m_remainingBox.width -= Constants.PORT_INITIAL_X * drawInfo.InvertedZoom; - } - - if( m_visibleOutputs == 0 ) - { - m_remainingBox.width -= Constants.PORT_INITIAL_X * drawInfo.InvertedZoom; - } - - if( ContainerGraph.ParentWindow.GlobalPreview != m_globalShowPreview ) - { - m_globalShowPreview = ContainerGraph.ParentWindow.GlobalPreview; - m_sizeIsDirty = true; - ContainerGraph.ParentWindow.RequestRepaint(); - } - - // Generate Proper Preview Rect - float marginAround = 10; - float scaledMarginAround = marginAround * drawInfo.InvertedZoom; - float previewSize = 128; - PreviewLocation m_autoLocation = m_selectedLocation; - if( m_selectedLocation == PreviewLocation.Auto ) - { - if( m_visibleOutputs > m_visibleInputs ) - { - m_autoLocation = PreviewLocation.Left; - } - else if( m_visibleOutputs < m_visibleInputs ) - { - m_autoLocation = PreviewLocation.Right; - } - else if( m_unscaledRemainingBox.width > previewSize ) - { - m_autoLocation = PreviewLocation.TopCenter; - } - else - { - m_autoLocation = PreviewLocation.BottomCenter; - } - } - - if( m_canExpand && ( m_showPreview || m_globalShowPreview ) ) - { - if( m_autoLocation == PreviewLocation.TopCenter ) - { - m_unscaledPreviewRect.y = m_unscaledRemainingBox.y; - m_unscaledPreviewRect.x = m_unscaledRemainingBox.center.x - 0.5f * ( previewSize + 2 * marginAround ); - } - else if( m_autoLocation == PreviewLocation.BottomCenter ) - { - m_unscaledPreviewRect.y = Mathf.Max( m_lastOutputBottomLeft.y, m_lastInputBottomRight.y ); - m_unscaledPreviewRect.x = m_position.x + 0.5f * m_position.width - 0.5f * ( previewSize + 2 * marginAround ); - } - else if( m_autoLocation == PreviewLocation.Left ) - { - m_unscaledPreviewRect.y = m_lastInputBottomRight.y; - m_unscaledPreviewRect.x = m_position.x; - } - else if( m_autoLocation == PreviewLocation.Right ) - { - m_unscaledPreviewRect.y = m_lastOutputBottomLeft.y; - m_unscaledPreviewRect.x = m_lastInputBottomRight.x; - } - if( m_autoLocation == PreviewLocation.BottomCenter ) - m_unscaledPreviewRect.height = previewSize + 2 * marginAround; - else if( m_autoLocation == PreviewLocation.TopCenter ) - m_unscaledPreviewRect.height = previewSize + marginAround; - else - m_unscaledPreviewRect.height = previewSize + ( m_visibleInputs > 0 && m_visibleOutputs > 0 ? 2 * marginAround : marginAround ); - m_unscaledPreviewRect.width = previewSize + 2 * marginAround; - - m_previewRect = m_unscaledPreviewRect; - m_previewRect.position = ( m_previewRect.position + drawInfo.CameraOffset ) * drawInfo.InvertedZoom; - m_auxVector2.Set( previewSize * drawInfo.InvertedZoom, previewSize * drawInfo.InvertedZoom ); - m_previewRect.size = m_auxVector2; - - if( m_autoLocation == PreviewLocation.BottomCenter ) - { - m_auxVector2.Set( m_previewRect.position.x + scaledMarginAround, m_previewRect.position.y + scaledMarginAround ); - m_previewRect.position = m_auxVector2; - } - else if( m_autoLocation == PreviewLocation.TopCenter ) - { - m_auxVector2.Set( m_previewRect.position.x + scaledMarginAround, m_previewRect.position.y ); - m_previewRect.position = m_auxVector2; - } - else - { - m_previewRect.position += new Vector2( scaledMarginAround, ( m_visibleInputs > 0 && m_visibleOutputs > 0 ? scaledMarginAround : 0 ) ); - } - } - - // Adjust node rect after preview - if( m_firstPreviewDraw ) - { - m_firstPreviewDraw = false; - ContainerGraph.ParentWindow.RequestRepaint(); - if( m_canExpand && ( m_showPreview || m_globalShowPreview ) ) - { - if( m_autoLocation == PreviewLocation.TopCenter ) - { - float fillWidth = m_unscaledRemainingBox.width - m_unscaledPreviewRect.width; - m_extraSize.x = Mathf.Max( -fillWidth, 0 ); - float fillHeight = m_position.yMax - m_unscaledPreviewRect.yMax; - m_extraSize.y = Mathf.Max( -fillHeight, 0 ); - } - if( m_autoLocation == PreviewLocation.BottomCenter ) - { - float fillWidth = m_position.width - m_unscaledPreviewRect.width; - m_extraSize.x = Mathf.Max( -fillWidth, 0 ); - float fillHeight = m_position.yMax - m_unscaledPreviewRect.yMax; - m_extraSize.y = Mathf.Max( -fillHeight, 0 ); - } - else if( m_autoLocation == PreviewLocation.Left ) - { - float fillWidth = m_lastOutputBottomLeft.x - m_unscaledPreviewRect.xMax; - m_extraSize.x = Mathf.Max( -fillWidth, 0 ); - float fillHeight = m_position.yMax - m_unscaledPreviewRect.yMax; - m_extraSize.y = Mathf.Max( -fillHeight, 0 ); - } - else if( m_autoLocation == PreviewLocation.Right ) - { - float fillWidth = m_position.xMax - m_unscaledPreviewRect.xMax; - m_extraSize.x = Mathf.Max( -fillWidth, 0 ); - float fillHeight = m_position.yMax - m_unscaledPreviewRect.yMax; - m_extraSize.y = Mathf.Max( -fillHeight, 0 ); - } - - if( m_showErrorMessage ) - m_extraSize.y += 24; - } - else if( m_canExpand ) - { - m_extraSize.y = 0; - m_extraSize.x = 0; - } - - m_position.width = m_unpreviewedPosition.width + m_extraSize.x; - m_position.height = m_unpreviewedPosition.height + m_extraSize.y; - } - - - if( m_showErrorMessage ) - { - m_errorBox = m_globalPosition; - m_errorBox.y = ( m_globalPosition.yMax - 28 * drawInfo.InvertedZoom ) + 3 * drawInfo.InvertedZoom; - m_errorBox.height = 25 * drawInfo.InvertedZoom; - } - - m_previousErrorMessage = m_showErrorMessage; - } - - /// <summary> - /// This method should only be called to draw elements, runs once per frame and after wires are drawn - /// </summary> - /// <param name="drawInfo"></param> - public virtual void OnNodeRepaint( DrawInfo drawInfo ) - { - if( !m_isVisible ) - return; - - m_colorBuffer = GUI.color; - // Background - GUI.color = m_infiniteLoopDetected ? Constants.InfiniteLoopColor : Constants.NodeBodyColor; - if( m_useSquareNodeTitle || ContainerGraph.LodLevel >= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( m_globalPosition, string.Empty, UIUtils.NodeWindowOffSquare ); - else - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeWindowOff ) ); - - // Header - //GUI - GUI.color = m_headerColor * m_headerColorModifier; - if( m_useSquareNodeTitle || ContainerGraph.LodLevel >= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( m_headerPosition, string.Empty, UIUtils.NodeHeaderSquare ); - else - GUI.Label( m_headerPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeHeader ) ); - GUI.color = m_colorBuffer; - - // Title - DrawTitle( m_titlePos ); - - // Additional Tile - if( m_hasSubtitle && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - GUI.Label( m_addTitlePos, m_additionalContent, UIUtils.GetCustomStyle( CustomStyle.PropertyValuesTitle ) ); - - // Dropdown - if( m_hasLeftDropdown && !m_dropdownEditing && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - GUI.Label( m_dropdownRect, string.Empty, UIUtils.PropertyPopUp ); - - // Expander - if( m_drawPreviewExpander && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - GUI.Label( m_expandRect, string.Empty, ( m_showPreview ? UIUtils.PreviewCollapser : UIUtils.PreviewExpander ) ); - - // Input Ports - int inputCount = m_inputPorts.Count; - - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Visible ) - { - // Input Port Icon - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - if( m_inputPorts[ i ].Locked ) - GUI.color = Constants.LockedPortColor; - else if( ContainerGraph.ParentWindow.Options.ColoredPorts ) - GUI.color = UIUtils.GetColorForDataType( m_inputPorts[ i ].DataType, false, true ); - else - GUI.color = m_inputPorts[ i ].HasCustomColor ? m_inputPorts[ i ].CustomColor : UIUtils.GetColorForDataType( m_inputPorts[ i ].DataType, true, true ); - - GUIStyle style = m_inputPorts[ i ].IsConnected ? UIUtils.GetCustomStyle( CustomStyle.PortFullIcon ) : UIUtils.GetCustomStyle( CustomStyle.PortEmptyIcon ); - GUI.Label( m_inputPorts[ i ].Position, string.Empty, style ); - - GUI.color = m_colorBuffer; - } - - // Input Port Label - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( m_inputPorts[ i ].Locked ) - { - GUI.color = Constants.PortLockedTextColor; - GUI.Label( m_inputPorts[ i ].LabelPosition, m_inputPorts[ i ].Name, UIUtils.InputPortLabel ); - GUI.color = m_colorBuffer; - } - else - { - if( m_containerGraph.ParentWindow.GlobalShowInternalData && !m_inputPorts[ i ].IsConnected && UIUtils.InternalDataOnPort.fontSize > 1f && ( m_inputPorts[ i ].AutoDrawInternalData || ( m_autoDrawInternalPortData && m_useInternalPortData ) ) && m_inputPorts[ i ].DisplayInternalData.Length > 4 && m_inputPorts[ i ].DataType != WirePortDataType.OBJECT ) - { - GUI.color = Constants.NodeBodyColor/* * new Color( 1f, 1f, 1f, 0.75f )*/; - Rect internalBox = m_inputPorts[ i ].LabelPosition; - m_sizeContentAux.text = m_inputPorts[ i ].DisplayInternalData; - Vector2 portText = UIUtils.InternalDataOnPort.CalcSize( m_sizeContentAux ); - internalBox.width = portText.x; - internalBox.height = portText.y; - internalBox.y = m_inputPorts[ i ].LabelPosition.center.y - internalBox.height * 0.5f; - internalBox.x = GlobalPosition.x - internalBox.width - 4 * drawInfo.InvertedZoom - 1; - Rect backBox = new Rect( internalBox ); - backBox.xMin -= 4 * drawInfo.InvertedZoom; - backBox.xMax += 4 * drawInfo.InvertedZoom; - backBox.yMin -= 2 * drawInfo.InvertedZoom; - backBox.yMax += 2 * drawInfo.InvertedZoom; - GUI.Label( backBox, string.Empty, UIUtils.InternalDataBackground ); - GUI.color *= new Color( 1f, 1f, 1f, 0.5f ); - GUI.Label( internalBox, m_sizeContentAux, UIUtils.InternalDataOnPort ); - GUI.color = m_colorBuffer; - } - GUI.Label( m_inputPorts[ i ].LabelPosition, m_inputPorts[ i ].Name, UIUtils.InputPortLabel ); - } - } - } - } - - // Output Ports - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].Visible ) - { - // Output Port Icon - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4 ) - { - if( m_outputPorts[ i ].Locked ) - GUI.color = Constants.LockedPortColor; - else if( ContainerGraph.ParentWindow.Options.ColoredPorts ) - GUI.color = UIUtils.GetColorForDataType( m_outputPorts[ i ].DataType, false, false ); - else - GUI.color = m_outputPorts[ i ].HasCustomColor ? m_outputPorts[ i ].CustomColor : UIUtils.GetColorForDataType( m_outputPorts[ i ].DataType, true, false ); - - GUIStyle style = m_outputPorts[ i ].IsConnected ? UIUtils.GetCustomStyle( CustomStyle.PortFullIcon ) : UIUtils.GetCustomStyle( CustomStyle.PortEmptyIcon ); - GUI.Label( m_outputPorts[ i ].Position, string.Empty, style ); - - GUI.color = m_colorBuffer; - } - - // Output Port Label - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3 ) - { - if( m_outputPorts[ i ].Locked ) - { - GUI.color = Constants.PortLockedTextColor; - GUI.Label( m_outputPorts[ i ].LabelPosition, m_outputPorts[ i ].Name, UIUtils.OutputPortLabel ); - GUI.color = m_colorBuffer; - } - else - { - GUI.Label( m_outputPorts[ i ].LabelPosition, m_outputPorts[ i ].Name, UIUtils.OutputPortLabel ); - } - } - } - } - - // Preview - if( ( m_showPreview || m_globalShowPreview ) && m_drawPreview ) - DrawPreview( drawInfo, m_previewRect ); - - // Error and Warning bottom message - if( m_showErrorMessage ) - { - GUI.color = new Color( 0.0f, 0.0f, 0.0f, 0.5f ); - GUI.Label( m_errorBox, string.Empty, UIUtils.Separator ); - GUI.color = m_colorBuffer; - - switch( m_errorMessageTypeIsError ) - { - default: - case NodeMessageType.Error: - { - m_errorMessage.text = ErrorTitle; - m_errorIcon.image = UIUtils.SmallErrorIcon; - m_errorCurrentStyle = UIUtils.BoldErrorStyle; - } - break; - case NodeMessageType.Warning: - { - m_errorMessage.text = WarningTitle; - m_errorIcon.image = UIUtils.SmallWarningIcon; - m_errorCurrentStyle = UIUtils.BoldWarningStyle; - } - break; - case NodeMessageType.Info: - { - m_errorMessage.text = InfoTitle; - m_errorIcon.image = UIUtils.SmallInfoIcon; - m_errorCurrentStyle = UIUtils.BoldInfoStyle; - } - break; - } - - Rect textBox = m_errorBox; - textBox.y += 1 * drawInfo.InvertedZoom; - textBox.height = 24 * drawInfo.InvertedZoom; - - float textWidth = m_errorCurrentStyle.CalcSize( m_errorMessage ).x; - - GUI.Label( textBox, m_errorMessage, m_errorCurrentStyle ); - textBox.x -= textWidth * 0.5f + 12 * drawInfo.InvertedZoom; - GUI.Label( textBox, m_errorIcon, m_errorCurrentStyle ); - textBox.x += textWidth + 24 * drawInfo.InvertedZoom; - GUI.Label( textBox, m_errorIcon, m_errorCurrentStyle ); - } - - // Selection Box - if( m_selected ) - { - GUI.color = Constants.NodeSelectedColor; - if( m_useSquareNodeTitle || ContainerGraph.LodLevel >= ParentGraph.NodeLOD.LOD2 ) - GUI.Label( m_globalPosition, string.Empty, UIUtils.NodeWindowOnSquare ); - else - GUI.Label( m_globalPosition, string.Empty, UIUtils.GetCustomStyle( CustomStyle.NodeWindowOn ) ); - GUI.color = m_colorBuffer; - } - - // Debug Visualizers - //if( FinishPreviewRender || m_continuousPreviewRefresh ) - //{ - // GUI.color = new Color( 0, 1, 0.5f, 1f ); - // Rect r = m_globalPosition; - // r.width = 8; - // r.height = 8; - // r.x -= 5 * drawInfo.InvertedZoom; - // r.y -= 5 * drawInfo.InvertedZoom; - // GUI.Label( r, string.Empty, UIUtils.GetCustomStyle( CustomStyle.PortFullIcon ) ); - // GUI.color = m_colorBuffer; - // FinishPreviewRender = false; - //} - //GUI.Label( m_remainingBox, string.Empty, UIUtils.Box ); - } - - public bool DropdownEditing { get { return m_dropdownEditing; } set { m_dropdownEditing = value; PreviewIsDirty = true; } } - /// <summary> - /// Handles gui controls, runs before node layout - /// </summary> - /// <param name="drawInfo"></param> - public virtual void DrawGUIControls( DrawInfo drawInfo ) - { - if( !m_initialized ) - return; - - if( !m_isVisible ) - return; - - if( drawInfo.CurrentEventType == EventType.MouseDown && drawInfo.LeftMouseButtonPressed ) - { - if( m_expandRect.Contains( drawInfo.MousePosition ) ) - { - m_showPreview = !m_showPreview; - m_sizeIsDirty = true; - ContainerGraph.ParentWindow.MouseInteracted = true; - } - - if( m_hasLeftDropdown && m_dropdownRect.Contains( drawInfo.MousePosition ) ) - { - m_dropdownEditing = true; - } - else if( m_dropdownEditing ) - { - DropdownEditing = false; - } - } - - DrawGuiPorts( drawInfo ); - } - - //public static bool MyRepeatButton( DrawInfo drawInfo, Rect position, string text, GUIStyle style ) - //{ - // if(/* drawInfo.CurrentEventType == EventType.MouseDown &&*/ position.Contains( drawInfo.MousePosition ) ) - // { - // UIUtils.CurrentWindow.MouseInteracted = true; - // return true; - // } - // return false; - //} - - public void DrawGuiPorts( DrawInfo drawInfo ) - { - if( !m_initialized ) - return; - - if( !m_isVisible ) - return; - - if( drawInfo.CurrentEventType == EventType.MouseDown ) - { - int inputCount = m_inputPorts.Count; - int outputCount = m_outputPorts.Count; - - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Visible && !m_inputPorts[ i ].Locked && m_isVisible && m_inputPorts[ i ].ActivePortArea.Contains( drawInfo.MousePosition ) && drawInfo.LeftMouseButtonPressed ) - { - UIUtils.CurrentWindow.MouseInteracted = true; - m_inputPorts[ i ].Click(); - // need to put the mouse button on a hot state so it will detect the Mouse Up event correctly on the Editor Window - int controlID = GUIUtility.GetControlID( FocusType.Passive ); - //int controlID = GUIUtility.GetControlID( "repeatButton".GetHashCode(), FocusType.Passive, m_inputPorts[ i ].ActivePortArea ); - GUIUtility.hotControl = controlID; - - bool saveReference = true; - if( m_inputPorts[ i ].IsConnected ) - { - double doubleTapTime = EditorApplication.timeSinceStartup; - bool doubleTap = ( doubleTapTime - m_doubleClickTimestamp ) < DoubleClickTime; - m_doubleClickTimestamp = doubleTapTime; - - if( doubleTap ) - { - m_containerGraph.DeleteConnection( true, UniqueId, m_inputPorts[ i ].PortId, true, true ); - Event.current.Use(); - } - else - //if ( AppyModifierToPort( _inputPorts[ i ], true ) ) - //{ - //saveReference = false; - //} - if( !ApplyModifierToPort( m_inputPorts[ i ], true ) ) - { - UIUtils.ShowContextOnPick = false; - PickInput( m_inputPorts[ i ] ); - } - saveReference = false; - } - - if( saveReference && !m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.IsValid ) - //if ( !modifierApplied && !UIUtils.InputPortReference.IsValid ) - { - m_containerGraph.ParentWindow.WireReferenceUtils.SetInputReference( m_uniqueId, m_inputPorts[ i ].PortId, m_inputPorts[ i ].DataType, m_inputPorts[ i ].TypeLocked ); - } - - IsDirty = true; - inputCount = m_inputPorts.Count; - } - } - - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].Visible && m_outputPorts[ i ].ActivePortArea.Contains( drawInfo.MousePosition ) && drawInfo.LeftMouseButtonPressed ) - { - UIUtils.CurrentWindow.MouseInteracted = true; - m_outputPorts[ i ].Click(); - // need to put the mouse button on a hot state so it will detect the Mouse Up event correctly on the Editor Window - int controlID = GUIUtility.GetControlID( FocusType.Passive ); - //int controlID = GUIUtility.GetControlID( "aseRepeatButton".GetHashCode(), FocusType.Passive, m_outputPorts[ i ].ActivePortArea ); - GUIUtility.hotControl = controlID; - - bool saveReference = true; - if( m_outputPorts[ i ].IsConnected ) - { - if( ApplyModifierToPort( m_outputPorts[ i ], false ) ) - { - saveReference = false; - } - } - - if( saveReference && !m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.IsValid ) - { - m_containerGraph.ParentWindow.WireReferenceUtils.SetOutputReference( m_uniqueId, m_outputPorts[ i ].PortId, m_outputPorts[ i ].DataType, false ); - } - - IsDirty = true; - outputCount = m_outputPorts.Count; - } - } - } - - //Preview buttons - if( m_drawPreviewMaskButtons && ( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp ) ) - DrawPreviewMaskButtonsLayout( drawInfo, m_previewRect ); - } - - /// <summary> - /// Can be used to draw an entire node, runs after wires - /// </summary> - /// <param name="drawInfo"></param> - public virtual void Draw( DrawInfo drawInfo ) - { - if( !m_initialized ) - return; - - if( drawInfo.CurrentEventType == EventType.Repaint ) - OnNodeRepaint( drawInfo ); - } - - public virtual void SetPreviewInputs() - { - if( !HasPreviewShader || !m_initialized ) - return; - - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected && m_inputPorts[ i ].InputNodeHasPreview( ContainerGraph ) ) - { - m_inputPorts[ i ].SetPreviewInputTexture( ContainerGraph ); - } - else - { - m_inputPorts[ i ].SetPreviewInputValue( ContainerGraph ); - } - } - } - - - public bool SafeDraw( DrawInfo drawInfo ) - { - EditorGUI.BeginChangeCheck(); - Draw( drawInfo ); - if( EditorGUI.EndChangeCheck() ) - { - SaveIsDirty = true; - return true; - } - return false; - } - - public bool ShowTooltip( DrawInfo drawInfo ) - { - if( string.IsNullOrEmpty( m_tooltipText ) ) - return false; - - if( m_globalPosition.Contains( drawInfo.MousePosition ) || m_linkVisibility ) - { - if( m_tooltipTimestamp + 0.6f < Time.realtimeSinceStartup || m_linkVisibility ) - { - bool errorTooltip = false; - if( m_showErrorMessage && m_errorBox.Contains( drawInfo.MousePosition ) && !string.IsNullOrEmpty( m_errorMessageTooltip ) ) - errorTooltip = true; - - Rect globalTooltipPos = m_globalPosition; - GUIContent temp = new GUIContent( errorTooltip ? m_errorMessageTooltip : m_tooltipText ); - UIUtils.TooltipBox.wordWrap = false; - Vector2 optimal = UIUtils.TooltipBox.CalcSize( temp ); - if( optimal.x > 300f ) - { - UIUtils.TooltipBox.wordWrap = true; - optimal.x = 300f; - optimal.y = UIUtils.TooltipBox.CalcHeight( temp, 300f ); - } - - globalTooltipPos.width = Mathf.Max( 120, optimal.x ); - globalTooltipPos.height = optimal.y; - globalTooltipPos.center = m_globalPosition.center; - - if( !errorTooltip && m_hasTooltipLink ) - globalTooltipPos.height += 16; - - if( errorTooltip ) - globalTooltipPos.y = 10 + m_globalPosition.yMax; - else - globalTooltipPos.y = m_globalPosition.yMin - 10 - globalTooltipPos.height; - - if ( globalTooltipPos.x < 10 ) - globalTooltipPos.x = 10; - - if( globalTooltipPos.x + globalTooltipPos.width > Screen.width - 10 ) - globalTooltipPos.x = Screen.width - globalTooltipPos.width - 10; - - //UNCOMMENT this for auto adjust tooltip to the top window box - //if( globalTooltipPos.y < 40 ) - // globalTooltipPos.y = 40; - - if( errorTooltip && globalTooltipPos.y + globalTooltipPos.height > Screen.height - 32 ) - globalTooltipPos.y = Screen.height - 32 - globalTooltipPos.height; - - GUI.Label( globalTooltipPos, temp, UIUtils.TooltipBox ); - - if( !errorTooltip && m_hasTooltipLink ) - { - Rect link = globalTooltipPos; - link.y = globalTooltipPos.yMax - 16; - link.height = 16; - link.width = 86; - link.x = globalTooltipPos.center.x - 43; - Rect hover = globalTooltipPos; - hover.yMax += 15;// m_globalPosition.yMax; - m_linkVisibility = hover.Contains( drawInfo.MousePosition ); - if( link.Contains( drawInfo.MousePosition ) ) - { - if( drawInfo.CurrentEventType == EventType.MouseDown ) - { - if( m_tooltipTimestamp + 1.25f < Time.realtimeSinceStartup ) - { - Application.OpenURL( Attributes.NodeUrl ); - } - } - else - { - UIUtils.MainSkin.customStyles[ 52 ].Draw( link, WikiLinkStr, true, false, false, false ); - } - } - else - { - GUI.Label( link, WikiLinkStr, UIUtils.MainSkin.customStyles[ 52 ] ); - } - } - ContainerGraph.ParentWindow.RequestRepaint(); - return true; - } - } - else - { - if( !m_linkVisibility ) - m_tooltipTimestamp = Time.realtimeSinceStartup; - } - - return false; - } - - public virtual bool SafeDrawProperties() - { - EditorGUI.BeginChangeCheck(); - PreDrawProperties(); - if( m_autoWrapProperties ) - { - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, DrawProperties ); - } - else - { - DrawProperties(); - } - if( EditorGUI.EndChangeCheck() ) - { - PreviewIsDirty = true; - //UIUtils.RecordObject(this); - //MarkForPreviewUpdate(); - return true; - } - return false; - } - - - public void PreDrawProperties() - { - if( m_useInternalPortData && m_autoDrawInternalPortData ) - { - DrawInternalDataGroup(); - } - } - - virtual public void DrawProperties() { } - - protected void DrawInternalDataGroup() - { - bool drawInternalDataUI = false; - int inputCount = m_inputPorts.Count; - if( inputCount > 0 ) - { - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].Available && m_inputPorts[ i ].ValidInternalData && !m_inputPorts[ i ].IsConnected /*&& ( m_inputPorts[ i ].AutoDrawInternalData || ( m_autoDrawInternalPortData && m_useInternalPortData ) )*/ /*&& m_inputPorts[ i ].AutoDrawInternalData*/ ) - { - drawInternalDataUI = true; - break; - } - } - } - - if( drawInternalDataUI ) - NodeUtils.DrawPropertyGroup( ref m_internalDataFoldout, Constants.InternalDataLabelStr, () => - { - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].ValidInternalData && !m_inputPorts[ i ].IsConnected && m_inputPorts[ i ].Visible /*&& m_inputPorts[ i ].AutoDrawInternalData*/ ) - { - m_inputPorts[ i ].ShowInternalData( this ); - } - } - } ); - } - - protected void PickInput( InputPort port ) - { - WireReference connection = port.GetConnection( 0 ); - OutputPort from = port.GetOutputConnection( 0 ); - - m_containerGraph.ParentWindow.WireReferenceUtils.OutputPortReference.SetReference( from.NodeId, from.PortId, from.DataType, connection.TypeLocked ); - m_containerGraph.DeleteConnection( true, UniqueId, port.PortId, true, true ); - //TODO: check if not necessary - Event.current.Use(); - IsDirty = true; - SetSaveIsDirty(); - } - - protected bool ApplyModifierToPort( WirePort port, bool isInput ) - { - bool modifierApplied = false; - switch( Event.current.modifiers ) - { - case EventModifiers.Alt: - { - m_containerGraph.DeleteConnection( isInput, UniqueId, port.PortId, true, true ); - modifierApplied = true; - m_containerGraph.ParentWindow.InvalidateAlt(); - } - break; - case EventModifiers.Control: - { - //WireReference connection = port.GetConnection( 0 ); - //if ( isInput ) - //{ - // UIUtils.OutputPortReference.SetReference( connection.NodeId, connection.PortId, connection.DataType, connection.TypeLocked ); - //} - //else - //{ - // UIUtils.InputPortReference.SetReference( connection.NodeId, connection.PortId, connection.DataType, connection.TypeLocked ); - //} - - //UIUtils.DeleteConnection( isInput, UniqueId, port.PortId, true ); - //modifierApplied = true; - - if( !isInput ) - { - WireReference connection = port.GetConnection( 0 ); - m_containerGraph.ParentWindow.WireReferenceUtils.InputPortReference.SetReference( connection.NodeId, connection.PortId, connection.DataType, connection.TypeLocked ); - m_containerGraph.DeleteConnection( isInput, UniqueId, port.PortId, true, true ); - modifierApplied = true; - } - } - break; - } - - if( isInput ) - m_containerGraph.ParentWindow.WireReferenceUtils.SwitchPortReference.SetReference( port.NodeId, port.PortId, port.DataType, false ); //always save last connection - else - m_containerGraph.ParentWindow.WireReferenceUtils.SwitchPortReference.SetReference( -1, -1, WirePortDataType.OBJECT, false ); //invalidate connection - - if( modifierApplied ) - { - Event.current.Use(); - IsDirty = true; - SetSaveIsDirty(); - } - return modifierApplied; - } - - public void DeleteAllInputConnections( bool alsoDeletePorts , bool inhibitWireNodeAutoDel = false ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - ParentNode connNode = null; - if( inhibitWireNodeAutoDel ) - { - connNode = m_inputPorts[ i ].GetOutputNode(); - connNode.Alive = false; - } - m_containerGraph.DeleteConnection( true, UniqueId, m_inputPorts[ i ].PortId, false, true ); - if( inhibitWireNodeAutoDel ) - { - connNode.Alive = true; - } - } - - } - if( alsoDeletePorts ) - { - m_inputPorts.Clear(); - m_inputPortsDict.Clear(); - } - SetSaveIsDirty(); - } - - public void DeleteAllOutputConnections( bool alsoDeletePorts ) - { - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - m_containerGraph.DeleteConnection( false, UniqueId, m_outputPorts[ i ].PortId, false, true ); - } - - if( alsoDeletePorts ) - { - m_outputPorts.Clear(); - m_outputPortsDict.Clear(); - } - SetSaveIsDirty(); - } - - public void DeleteInputPortByArrayIdx( int arrayIdx ) - { - if( arrayIdx >= m_inputPorts.Count ) - return; - - m_containerGraph.DeleteConnection( true, UniqueId, m_inputPorts[ arrayIdx ].PortId, false, true ); - m_inputPortsDict.Remove( m_inputPorts[ arrayIdx ].PortId ); - m_inputPorts.RemoveAt( arrayIdx ); - - m_sizeIsDirty = true; - SetSaveIsDirty(); - RecalculateInputPortIdx(); - } - - public void DeleteOutputPortByArrayIdx( int portIdx ) - { - if( portIdx >= m_outputPorts.Count ) - return; - - m_containerGraph.DeleteConnection( false, UniqueId, m_outputPorts[ portIdx ].PortId, false, true ); - m_outputPortsDict.Remove( m_outputPorts[ portIdx ].PortId ); - m_outputPorts.RemoveAt( portIdx ); - m_sizeIsDirty = true; - } - - public InputPort GetInputPortByArrayId( int id ) - { - if( id < m_inputPorts.Count ) - return m_inputPorts[ id ]; - - return null; - } - - public OutputPort GetOutputPortByArrayId( int id ) - { - if( id < m_outputPorts.Count ) - return m_outputPorts[ id ]; - - return null; - } - - public InputPort GetInputPortByUniqueId( int id ) - { - if( m_inputPortsDict.ContainsKey( id ) ) - return m_inputPortsDict[ id ]; - - if( m_inputPortsDict.Count != m_inputPorts.Count ) - m_repopulateDictionaries = true; - - int inputCount = m_inputPorts.Count; - for( int i = 0; i < inputCount; i++ ) - { - if( m_inputPorts[ i ].PortId == id ) - { - return m_inputPorts[ i ]; - } - } - return null; - } - - public OutputPort GetOutputPortByUniqueId( int id ) - { - if( m_outputPortsDict.ContainsKey( id ) ) - return m_outputPortsDict[ id ]; - - if( m_outputPortsDict.Count != m_outputPorts.Count ) - m_repopulateDictionaries = true; - - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - if( m_outputPorts[ i ].PortId == id ) - return m_outputPorts[ i ]; - } - return null; - } - - public virtual void AfterDuplication(){} - - public override string ToString() - { - string dump = ""; - dump += ( "Type: " + GetType() ); - dump += ( " Unique Id: " + UniqueId + "\n" ); - dump += ( " Inputs: \n" ); - - int inputCount = m_inputPorts.Count; - int outputCount = m_outputPorts.Count; - - for( int inputIdx = 0; inputIdx < inputCount; inputIdx++ ) - { - dump += ( m_inputPorts[ inputIdx ] + "\n" ); - } - dump += ( "Outputs: \n" ); - for( int outputIdx = 0; outputIdx < outputCount; outputIdx++ ) - { - dump += ( m_outputPorts[ outputIdx ] + "\n" ); - } - return dump; - } - - public string GetValueFromOutputStr( int outputId, WirePortDataType inputPortType, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( ignoreLocalvar ) - { - return GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - } - OutputPort outPort = GetOutputPortByUniqueId( outputId ); - if( outPort.IsLocalValue( dataCollector.PortCategory ) ) - { - if( outPort.DataType != WirePortDataType.OBJECT && outPort.DataType != inputPortType ) - { - return UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( m_uniqueId, outputId ), null, outPort.DataType, inputPortType, outPort.LocalValue( dataCollector.PortCategory ) ); - } - else - { - return outPort.LocalValue( dataCollector.PortCategory ); - } - } - - string result = GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - result = CreateOutputLocalVariable( outputId, result, ref dataCollector ); - - if( outPort.DataType != WirePortDataType.OBJECT && outPort.DataType != inputPortType ) - { - result = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( m_uniqueId, outputId ), null, outPort.DataType, inputPortType, result ); - } - return result; - } - - public virtual string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsSRP ) - { - switch( dataCollector.CurrentSRPType ) - { - case TemplateSRPType.HD: if(OnHDAction!=null) OnHDAction( outputId, ref dataCollector ); break; - case TemplateSRPType.Lightweight:if(OnLightweightAction != null) OnLightweightAction( outputId, ref dataCollector ); break; - } - } - return string.Empty; - } - - public string GenerateValueInVertex( ref MasterNodeDataCollector dataCollector, WirePortDataType dataType, string dataValue, string dataName, bool createInterpolator ) - { - - if( !dataCollector.IsFragmentCategory ) - return dataValue; - - //TEMPLATES - if( dataCollector.IsTemplate ) - { - if( createInterpolator && dataCollector.TemplateDataCollectorInstance.HasCustomInterpolatedData( dataName ) ) - return dataName; - - MasterNodePortCategory category = dataCollector.PortCategory; - dataCollector.PortCategory = MasterNodePortCategory.Vertex; - - dataCollector.PortCategory = category; - - if( createInterpolator ) - { - dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( dataName, dataType, CurrentPrecisionType, dataValue ); - } - else - { - dataCollector.AddToVertexLocalVariables( -1, CurrentPrecisionType, dataType, dataName, dataValue ); - } - - return dataName; - } - - //SURFACE - { - if( dataCollector.TesselationActive ) - { - UIUtils.ShowMessage( UniqueId, "Unable to use Vertex to Frag when Tessellation is active" ); - return m_outputPorts[ 0 ].ErrorValue; - } - - if( createInterpolator ) - dataCollector.AddToInput( UniqueId, dataName, dataType, CurrentPrecisionType ); - - MasterNodePortCategory portCategory = dataCollector.PortCategory; - dataCollector.PortCategory = MasterNodePortCategory.Vertex; - if( createInterpolator ) - { - dataCollector.AddLocalVariable( UniqueId, Constants.VertexShaderOutputStr + "." + dataName, dataValue + ";" ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, dataType, dataName, dataValue ); - } - dataCollector.PortCategory = portCategory; - return createInterpolator ? Constants.InputVarStr + "." + dataName : dataName; - } - } - - public string GenerateInputInVertex( ref MasterNodeDataCollector dataCollector, int inputPortUniqueId, string varName, bool createInterpolator ) - { - InputPort inputPort = GetInputPortByUniqueId( inputPortUniqueId ); - if( !dataCollector.IsFragmentCategory) - return inputPort.GeneratePortInstructions( ref dataCollector ); - - //TEMPLATES - if( dataCollector.IsTemplate ) - { - if( createInterpolator && dataCollector.TemplateDataCollectorInstance.HasCustomInterpolatedData( varName ) ) - return varName; - - MasterNodePortCategory category = dataCollector.PortCategory; - dataCollector.PortCategory = MasterNodePortCategory.Vertex; - //bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; - //ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - - string data = inputPort.GeneratePortInstructions( ref dataCollector ); - - dataCollector.PortCategory = category; - //if( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables ) - //{ - // dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariablesFromList, UniqueId, false ); - // dataCollector.ClearVertexLocalVariables(); - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - //} - - //ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Fragment ); - - if( createInterpolator ) - { - dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( varName, inputPort.DataType, CurrentPrecisionType, data ); - } - else - { - dataCollector.AddToVertexLocalVariables( -1, CurrentPrecisionType, inputPort.DataType, varName, data ); - } - - return varName; - } - - //SURFACE - { - if( dataCollector.TesselationActive ) - { - UIUtils.ShowMessage( UniqueId, "Unable to use Vertex to Frag when Tessellation is active" ); - return m_outputPorts[ 0 ].ErrorValue; - } - - if( createInterpolator ) - dataCollector.AddToInput( UniqueId, varName, inputPort.DataType, CurrentPrecisionType ); - - MasterNodePortCategory portCategory = dataCollector.PortCategory; - dataCollector.PortCategory = MasterNodePortCategory.Vertex; - - //bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; - - //ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - - string vertexVarValue = inputPort.GeneratePortInstructions( ref dataCollector ); - if( createInterpolator ) - { - dataCollector.AddLocalVariable( UniqueId, Constants.VertexShaderOutputStr + "." + varName, vertexVarValue + ";" ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, inputPort.DataType, varName, vertexVarValue ); - } - - dataCollector.PortCategory = portCategory; - - //if( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables ) - //{ - // dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariables, UniqueId, false ); - // dataCollector.ClearVertexLocalVariables(); - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - //} - - //ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Fragment ); - - return createInterpolator ? Constants.InputVarStr + "." + varName : varName; - } - } - - - protected virtual void OnUniqueIDAssigned() { } - - public string CreateOutputLocalVariable( int outputArrayId, string value, ref MasterNodeDataCollector dataCollector ) - { - OutputPort port = GetOutputPortByUniqueId( outputArrayId ); - - if( port.IsLocalValue( dataCollector.PortCategory ) ) - return port.LocalValue( dataCollector.PortCategory ); - - if( port.ConnectionCount > 1 ) - { - RegisterLocalVariable( outputArrayId, value, ref dataCollector ); - return port.LocalValue( dataCollector.PortCategory ); - } - else - { - // revisit later (break to components case) - port.SetLocalValue( value, dataCollector.PortCategory ); - } - - return value; - } - - public void RegisterLocalVariable( int outputArrayId, string value, ref MasterNodeDataCollector dataCollector, string customName = null ) - { - OutputPort port = GetOutputPortByUniqueId( outputArrayId ); - if( (int)port.DataType >= (int)( 1 << 10 ) ) //10 is the flag start of sampler types - { - port.SetLocalValue( value, dataCollector.PortCategory ); - return; - } - - bool vertexMode = dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation; - string localVar = port.ConfigOutputLocalValue( CurrentPrecisionType, value, customName, dataCollector.PortCategory ); - - if( vertexMode ) - { - dataCollector.AddToVertexLocalVariables( m_uniqueId, localVar ); - } - else - { - dataCollector.AddToLocalVariables( m_uniqueId, localVar ); - } - } - - public void InvalidateConnections() - { - int inputCount = m_inputPorts.Count; - int outputCount = m_outputPorts.Count; - - for( int i = 0; i < inputCount; i++ ) - { - m_inputPorts[ i ].InvalidateAllConnections(); - } - - for( int i = 0; i < outputCount; i++ ) - { - m_outputPorts[ i ].InvalidateAllConnections(); - } - } - - public virtual bool OnClick( Vector2 currentMousePos2D ) - { - bool singleClick = true; - if( ( EditorApplication.timeSinceStartup - m_lastTimeSelected ) < NodeClickTime ) - { - OnNodeDoubleClicked( currentMousePos2D ); - singleClick = false; - } - - m_lastTimeSelected = EditorApplication.timeSinceStartup; - return singleClick; - } - - public virtual void OnNodeDoubleClicked( Vector2 currentMousePos2D ) - { - ContainerGraph.ParentWindow.ParametersWindow.IsMaximized = !ContainerGraph.ParentWindow.ParametersWindow.IsMaximized; - } - - public virtual void OnNodeSelected( bool value ) - { - if( !value ) - { - if( m_inputPorts != null ) - { - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - m_inputPorts[ i ].ResetEditing(); - } - } - - if( m_outputPorts != null ) - { - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - m_outputPorts[ i ].ResetEditing(); - } - } - } - } - - public void ResetOutputLocals() - { - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - m_outputPorts[ i ].ResetLocalValue(); - } - } - - - public void ResetOutputLocalsIfNot( MasterNodePortCategory category ) - { - int outputCount = m_outputPorts.Count; - for( int i = 0; i < outputCount; i++ ) - { - //if( !m_outputPorts[ i ].IsLocalOnCategory( category ) ) - // m_outputPorts[ i ].ResetLocalValue(); - m_outputPorts[ i ].ResetLocalValueIfNot( category ); - } - } - - public virtual void Rewire() { } - - //public virtual List<int> NodeReferences { get { return null; } } - - public int UniqueId - { - get { return m_uniqueId; } - - set - { - m_uniqueId = value; - - int inputCount = m_inputPorts.Count; - int outputCount = m_outputPorts.Count; - - for( int inputIdx = 0; inputIdx < inputCount; inputIdx++ ) - { - m_inputPorts[ inputIdx ].NodeId = value; - } - - for( int outputIdx = 0; outputIdx < outputCount; outputIdx++ ) - { - m_outputPorts[ outputIdx ].NodeId = value; - } - OnUniqueIDAssigned(); - } - } - public void SetBaseUniqueId( int uniqueId, bool setOnPorts = false ) - { - m_uniqueId = uniqueId; - if( setOnPorts ) - { - int inputCount = m_inputPorts.Count; - int outputCount = m_outputPorts.Count; - - for( int inputIdx = 0; inputIdx < inputCount; inputIdx++ ) - { - m_inputPorts[ inputIdx ].NodeId = uniqueId; - } - - for( int outputIdx = 0; outputIdx < outputCount; outputIdx++ ) - { - m_outputPorts[ outputIdx ].NodeId = uniqueId; - } - } - } - - public string OutputId - { - get - { - if( ContainerGraph.GraphId > 0 ) - return UniqueId + "_g" + ContainerGraph.GraphId; - else - return UniqueId.ToString(); - } - } - - - public virtual Rect Position { get { return m_position; } } - public Rect TruePosition { get { return m_position; } } - - public Vector2 CenterPosition { get { return new Vector2( m_position.x + m_position.width * 0.5f, m_position.y + m_position.height * 0.5f ); ; } } - - public Rect GlobalPosition { get { return m_globalPosition; } } - - public Vector2 Corner { get { return new Vector2( m_position.x + m_position.width, m_position.y + m_position.height ); } } - public Vector2 Vec2Position - { - get { return new Vector2( m_position.x, m_position.y ); } - - set - { - m_position.x = value.x; - m_position.y = value.y; - } - } - - public Vector3 Vec3Position - { - get { return new Vector3( m_position.x, m_position.y, 0f ); } - - set - { - m_position.x = value.x; - m_position.y = value.y; - } - } - - - public bool Selected - { - get { return m_selected; } - set - { - m_infiniteLoopDetected = false; - m_selected = value; - OnNodeSelected( value ); - } - } - - public List<InputPort> InputPorts { get { return m_inputPorts; } } - - public List<OutputPort> OutputPorts - { - get { return m_outputPorts; } - } - - public bool IsConnected { get { return m_connStatus == NodeConnectionStatus.Connected; } } - public NodeConnectionStatus ConnStatus - { - get { return m_connStatus; } - set - { - if( m_selfPowered ) - { - m_connStatus = NodeConnectionStatus.Connected; - } - else - { - m_connStatus = value; - } - - switch( m_connStatus ) - { - case NodeConnectionStatus.Island: - case NodeConnectionStatus.Not_Connected: m_statusColor = Constants.NodeDefaultColor; break; - case NodeConnectionStatus.Connected: m_statusColor = Constants.NodeConnectedColor; break; - case NodeConnectionStatus.Error: m_statusColor = Constants.NodeErrorColor; break; - } - - } - } - - public bool SelfPowered - { - set - { - m_selfPowered = value; - if( value ) - { - ConnStatus = NodeConnectionStatus.Connected; - } - } - } - - // This is also called when recording on Undo - public virtual void OnBeforeSerialize() { } - public virtual void OnAfterDeserialize() - { - m_selected = false; - m_isOnGrid = false; - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].ResetWireReferenceStatus(); - } - m_repopulateDictionaries = true; - m_sizeIsDirty = true; - } - - public virtual void ReadFromDeprecated( ref string[] nodeParams, Type oldType = null ) { } - - //Inherited classes must call this base method in order to setup id and position - public virtual void ReadFromString( ref string[] nodeParams ) - { - ParentReadFromString( ref nodeParams ); - } - - public void ParentReadFromString( ref string[] nodeParams ) - { - m_currentReadParamIdx = IOUtils.NodeTypeId + 1; - - UniqueId = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] ); - - string[] posCoordinates = nodeParams[ m_currentReadParamIdx++ ].Split( IOUtils.VECTOR_SEPARATOR ); - - m_position.x = Convert.ToSingle( posCoordinates[ 0 ] ); - m_position.y = Convert.ToSingle( posCoordinates[ 1 ] ); - - if( UIUtils.CurrentShaderVersion() > 22 ) - { - string val = GetCurrentParam( ref nodeParams ); - if( m_customPrecision ) - { - if( val.Equals("Fixed") ) - m_currentPrecisionType = PrecisionType.Half; - else - m_currentPrecisionType = (PrecisionType)Enum.Parse( typeof( PrecisionType ), val ); - } - else - { - m_currentPrecisionType = PrecisionType.Inherit; - } - } - - if( UIUtils.CurrentShaderVersion() > 5004 ) - m_showPreview = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - - } - - //should be called after ReadFromString - public virtual void ReadInputDataFromString( ref string[] nodeParams ) - { - int count = 0; - if( UIUtils.CurrentShaderVersion() > 7003 ) - { - try - { - count = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] ); - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - else - { - count = ( m_oldInputCount < 0 ) ? m_inputPorts.Count : m_oldInputCount; - } - - for( int i = 0; i < count && i < nodeParams.Length && m_currentReadParamIdx < nodeParams.Length; i++ ) - { - if( UIUtils.CurrentShaderVersion() < 5003 ) - { - int newId = VersionConvertInputPortId( i ); - if( UIUtils.CurrentShaderVersion() > 23 ) - { - m_inputPorts[ newId ].DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] ); - } - - m_inputPorts[ newId ].InternalData = nodeParams[ m_currentReadParamIdx++ ]; - if( m_inputPorts[ newId ].IsEditable && UIUtils.CurrentShaderVersion() >= 3100 && m_currentReadParamIdx < nodeParams.Length ) - { - m_inputPorts[ newId ].Name = nodeParams[ m_currentReadParamIdx++ ]; - } - m_inputPorts[ newId ].UpdatePreviewInternalData(); - } - else - { - string portIdStr = nodeParams[ m_currentReadParamIdx++ ]; - int portId = -1; - try - { - portId = Convert.ToInt32( portIdStr ); - } - catch( Exception e ) - { - Debug.LogException( e ); - } - - WirePortDataType DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] ); - string InternalData = nodeParams[ m_currentReadParamIdx++ ]; - bool isEditable = Convert.ToBoolean( nodeParams[ m_currentReadParamIdx++ ] ); - string Name = string.Empty; - if( isEditable && m_currentReadParamIdx < nodeParams.Length ) - { - Name = nodeParams[ m_currentReadParamIdx++ ]; - } - - InputPort inputPort = GetInputPortByUniqueId( portId ); - if( inputPort != null ) - { - if( UIUtils.IsValidType( DataType ) ) - inputPort.DataType = DataType; - - inputPort.InternalData = InternalData; - if( !string.IsNullOrEmpty( Name ) ) - { - inputPort.Name = Name; - } - inputPort.UpdatePreviewInternalData(); - } - } - } - } - - public virtual void ReadOutputDataFromString( ref string[] nodeParams ) - { - int count = 0; - if( UIUtils.CurrentShaderVersion() > 7003 ) - { - count = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] ); - } - else - { - count = m_outputPorts.Count; - } - - for( int i = 0; i < count && i < nodeParams.Length && m_currentReadParamIdx < nodeParams.Length; i++ ) - { - try - { - WirePortDataType dataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] ); - int portId = -1; - if( UIUtils.CurrentShaderVersion() > 13903 ) - { - portId = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] ); ; - } - else - { - portId = i; - } - - OutputPort port = GetOutputPortByUniqueId( portId ); - if( port != null && UIUtils.IsValidType( dataType ) ) - { - port.DataType = dataType; - } - - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - } - - public virtual void ReadAdditionalClipboardData( ref string[] nodeParams ) { } - - protected string GetCurrentParam( ref string[] nodeParams ) - { - if( m_currentReadParamIdx < nodeParams.Length ) - { - return nodeParams[ m_currentReadParamIdx++ ]; - } - - UIUtils.ShowMessage( UniqueId, "Invalid params number in node " + m_uniqueId + " of type " + GetType(), MessageSeverity.Error ); - return string.Empty; - } - - protected string GetCurrentParam( int index, ref string[] nodeParams ) - { - if( m_currentReadParamIdx < nodeParams.Length ) - { - return nodeParams[ index ]; - } - - UIUtils.ShowMessage( UniqueId, "Invalid params number in node " + m_uniqueId + " of type " + GetType(), MessageSeverity.Error ); - return string.Empty; - } - - - public virtual void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - IOUtils.AddTypeToString( ref nodeInfo, IOUtils.NodeParam ); - IOUtils.AddFieldValueToString( ref nodeInfo, GetType() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_uniqueId ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_position.x.ToString() + IOUtils.VECTOR_SEPARATOR + m_position.y.ToString() ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentPrecisionType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_showPreview ); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - m_inputPorts[ i ].WriteToString( ref connectionsInfo ); - } - } - - public virtual void WriteInputDataToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts.Count ); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ i ].PortId ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ i ].DataType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ i ].InternalData ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ i ].IsEditable ); - if( m_inputPorts[ i ].IsEditable ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_inputPorts[ i ].Name ); - } - } - } - - public void WriteOutputDataToString( ref string nodeInfo ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_outputPorts.Count ); - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - IOUtils.AddFieldValueToString( ref nodeInfo, m_outputPorts[ i ].DataType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_outputPorts[ i ].PortId ); - } - } - - public virtual void WriteAdditionalClipboardData( ref string nodeInfo ) { } - - public virtual string GetIncludes() { return string.Empty; } - public virtual void OnObjectDropped( UnityEngine.Object obj ) { } - public virtual void SetupFromCastObject( UnityEngine.Object obj ) { } - public virtual bool OnNodeInteraction( ParentNode node ) { return false; } - public virtual void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) { } - public virtual void OnConnectedInputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) { } - - public Rect CachedPos { get { return m_cachedPos; } } - - public bool IsOnGrid - { - set { m_isOnGrid = value; } - get { return m_isOnGrid; } - } - - public uint CurrentReadParamIdx - { - get { return m_currentReadParamIdx++; } - set { m_currentReadParamIdx = value; } - } - - public Dictionary<string, InputPort> InputPortsDict - { - get - { - Dictionary<string, InputPort> dict = new Dictionary<string, InputPort>(); - for( int i = 0; i < m_inputPorts.Count; i++ ) - { - dict.Add( m_inputPorts[ i ].Name, m_inputPorts[ i ] ); - } - return dict; - } - } - - public bool IsDirty - { - set { m_isDirty = value && UIUtils.DirtyMask; } - get - { - bool value = m_isDirty; - m_isDirty = false; - return value; - } - } - - public virtual void ResetNodeData() - { - m_category = 0; - m_graphDepth = 0; - } - - public virtual void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - UIUtils.SetCategoryInBitArray( ref m_category, nodeData.Category ); - nodeData.GraphDepth += 1; - if( nodeData.GraphDepth > m_graphDepth ) - { - m_graphDepth = nodeData.GraphDepth; - } - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].GetOutputNode().PropagateNodeData( nodeData, ref dataCollector ); - } - } - } - - public void SetTitleTextOnCallback( string compareTitle, Action<ParentNode, string> callback ) - { - if( !m_previousTitle.Equals( compareTitle ) ) - { - m_previousTitle = compareTitle; - m_sizeIsDirty = true; - callback( this, compareTitle ); - } - } - - public void SetAdditonalTitleTextOnCallback( string compareTitle, Action<ParentNode, string> callback ) - { - if( !m_previousAdditonalTitle.Equals( compareTitle ) ) - { - m_previousAdditonalTitle = compareTitle; - m_sizeIsDirty = true; - callback( this, compareTitle ); - } - } - - public virtual void SetClippedTitle( string newText, int maxSize = 170, string endString = "..." ) - { - m_content.text = GenerateClippedTitle( newText,maxSize,endString ); - m_sizeIsDirty = true; - } - - public virtual void SetClippedAdditionalTitle( string newText, int maxSize = 170, string endString = "..." ) - { - m_additionalContent.text = GenerateClippedTitle( newText, maxSize, endString ); - m_sizeIsDirty = true; - } - - - public void SetTitleText( string newText ) - { - if( !newText.Equals( m_content.text ) ) - { - m_content.text = newText; - m_sizeIsDirty = true; - } - } - - public void SetAdditonalTitleText( string newText ) - { - if( !newText.Equals( m_additionalContent.text ) ) - { - m_additionalContent.text = newText; - m_sizeIsDirty = true; - } - } - - public string GenerateErrorValue( int outputIdx = 0 ) - { - switch( m_outputPorts[ outputIdx ].DataType ) - { - case WirePortDataType.FLOAT2: - { - return "(0).xx"; - } - case WirePortDataType.FLOAT3: - { - return "(0).xxx"; - } - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - return "(0).xxxx"; - } - } - return "0"; - } - - //Methods created to take into account new ports added on nodes newer versions - //This way we can convert connections from previous versions to newer ones and not brake shader graph - public virtual int VersionConvertInputPortId( int portId ) { return portId; } - public virtual int VersionConvertOutputPortId( int portId ) { return portId; } - - public virtual string DataToArray { get { return string.Empty; } } - - public bool SaveIsDirty - { - set { m_saveIsDirty = value && UIUtils.DirtyMask; } - get - { - bool value = m_saveIsDirty; - m_saveIsDirty = false; - return value; - } - } - - public GUIContent TitleContent { get { return m_content; } } - public GUIContent AdditonalTitleContent { get { return m_additionalContent; } } - public bool IsVisible { get { return m_isVisible; } } - public NodeAttributes Attributes { get { return m_nodeAttribs; } } - public bool ReorderLocked { get { return m_reorderLocked; } } - public bool RequireMaterialUpdate { get { return m_requireMaterialUpdate; } } - public bool RMBIgnore { get { return m_rmbIgnore; } } - public float TextLabelWidth { get { return m_textLabelWidth; } } - public bool IsMoving { get { return m_isMoving > 0; } } - public bool MovingInFrame { get { return m_movingInFrame; } set { m_movingInFrame = value; } } - public bool SizeIsDirty { get { return m_sizeIsDirty; } set { m_sizeIsDirty = value; } } - public int Category { get { return m_category; } } - public int CommentaryParent - { - get { return m_commentaryParent; } - set { m_commentaryParent = value; } - } - - public int Depth - { - get { return m_depth; } - set { m_depth = value; } - } - - public int MatrixId - { - get { return m_matrixId; } - set { m_matrixId = value; } - } - - public float PaddingTitleRight - { - get { return m_paddingTitleRight; } - set { m_paddingTitleRight += value; } - } - - public float PaddingTitleLeft - { - get { return m_paddingTitleLeft; } - set { m_paddingTitleLeft += value; } - } - - public int CachedPortsId - { - get - { - return m_cachedPortsId; - } - } - - public virtual bool RecursivePreviewUpdate( Dictionary<string,bool> duplicatesDict = null ) - { - if( duplicatesDict == null ) - { - duplicatesDict = ContainerGraph.ParentWindow.VisitedChanged; - } - - for( int i = 0; i < InputPorts.Count; i++ ) - { - ParentNode outNode = null; - if( InputPorts[ i ].ExternalReferences.Count > 0 ) - { - outNode = ContainerGraph.GetNode( InputPorts[ i ].ExternalReferences[ 0 ].NodeId ); - } - if( outNode != null ) - { - if( !duplicatesDict.ContainsKey( outNode.OutputId ) ) - { - bool result = outNode.RecursivePreviewUpdate(); - if( result ) - PreviewIsDirty = true; - } else if( duplicatesDict[ outNode.OutputId ] ) - { - PreviewIsDirty = true; - } - } - } - - bool needsUpdate = PreviewIsDirty; - RenderNodePreview(); - if( !duplicatesDict.ContainsKey( OutputId ) ) - duplicatesDict.Add( OutputId, needsUpdate ); - return needsUpdate; - } - - public virtual void RenderNodePreview() - { - //Runs at least one time - if( !HasPreviewShader || !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty && !m_continuousPreviewRefresh ) - return; - - //Debug.Log( "PREVIEW " + this ); - - SetPreviewInputs(); - - if( m_cachedMainTexId == -1 ) - m_cachedMainTexId = Shader.PropertyToID( "_MainTex" ); - - if( m_cachedMaskTexId == -1 ) - m_cachedMaskTexId = Shader.PropertyToID( "_MaskTex" ); - - if( m_cachedPortsId == -1 ) - m_cachedPortsId = Shader.PropertyToID( "_Ports" ); - - if( m_cachedPortId == -1 ) - m_cachedPortId = Shader.PropertyToID( "_Port" ); - - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( i == 0 ) - { - RenderTexture temp = RenderTexture.active; - RenderTexture beforeMask = RenderTexture.GetTemporary( PreviewWidth, PreviewHeight, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear ); - RenderTexture.active = beforeMask; - Graphics.Blit( null, beforeMask, PreviewMaterial, m_previewMaterialPassId ); - - m_portMask.Set( 0, 0, 0, 0 ); - - switch( m_outputPorts[ i ].DataType ) - { - case WirePortDataType.INT: - case WirePortDataType.FLOAT: - m_portMask.Set( 1, 1, 1, 1 ); - break; - case WirePortDataType.FLOAT2: - m_portMask.Set( 1, 1, 0, 0 ); - break; - case WirePortDataType.FLOAT3: - m_portMask.Set( 1, 1, 1, 0 ); - break; - case WirePortDataType.COLOR: - case WirePortDataType.FLOAT4: - m_portMask.Set( 1, 1, 1, 1 ); - break; - default: - m_portMask.Set( 1, 1, 1, 1 ); - break; - } - - if( m_outputPorts[ i ].DataType == WirePortDataType.FLOAT3x3 || m_outputPorts[ i ].DataType == WirePortDataType.FLOAT4x4 ) - { - m_outputPorts[ i ].MaskingMaterial.SetTexture( m_cachedMainTexId, EditorGUIUtility.whiteTexture ); - } - else - { - m_outputPorts[ i ].MaskingMaterial.SetTexture( m_cachedMainTexId, beforeMask ); - } - m_outputPorts[ i ].MaskingMaterial.SetVector( m_cachedPortsId, m_portMask ); - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, m_outputPorts[ i ].MaskingMaterial, 0 ); - - RenderTexture.ReleaseTemporary( beforeMask ); - RenderTexture.active = temp; - } - else - { - RenderTexture temp = RenderTexture.active; - m_outputPorts[ i ].MaskingMaterial.SetTexture( m_cachedMaskTexId, PreviewTexture ); - m_outputPorts[ i ].MaskingMaterial.SetFloat( m_cachedPortId, i ); - - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, m_outputPorts[ i ].MaskingMaterial, 1 ); - RenderTexture.active = temp; - } - } - - PreviewIsDirty = m_continuousPreviewRefresh; - - FinishPreviewRender = true; - } - - protected void ShowTab( NodeMessageType type, string tooltip ) - { - m_showErrorMessage = true; - m_errorMessageTypeIsError = type; - m_errorMessageTooltip = tooltip; - } - - protected void ShowTab() - { - m_showErrorMessage = true; - } - - protected void HideTab() - { - m_showErrorMessage = false; - } - - public virtual RenderTexture PreviewTexture - { - get - { - if( m_outputPorts.Count > 0 ) - return m_outputPorts[ 0 ].OutputPreviewTexture; - else - return null; - } - } - - public void FullWriteToString( ref string nodesInfo, ref string connectionsInfo ) - { - WriteToString( ref nodesInfo, ref connectionsInfo ); - WriteInputDataToString( ref nodesInfo ); - WriteOutputDataToString( ref nodesInfo ); - } - - public void ClipboardFullWriteToString( ref string nodesInfo, ref string connectionsInfo ) - { - FullWriteToString( ref nodesInfo, ref connectionsInfo ); - WriteAdditionalClipboardData( ref nodesInfo ); - } - - public void FullReadFromString( ref string[] parameters ) - { - try - { - ReadFromString( ref parameters ); - ReadInputDataFromString( ref parameters ); - ReadOutputDataFromString( ref parameters ); - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - - public void ClipboardFullReadFromString( ref string[] parameters ) - { - try - { - FullReadFromString( ref parameters ); - ReadAdditionalClipboardData( ref parameters ); - } - catch( Exception e ) - { - Debug.LogException( e ); - } - } - - public string GenerateClippedTitle( string original , int maxSize = 170, string endString = "..." ) - { - if( UIUtils.UnZoomedNodeTitleStyle == null ) - return original; - - GUIContent content = new GUIContent( original ); - - string finalTitle = string.Empty; - bool addEllipsis = false; - for( int i = 1; i <= original.Length; i++ ) - { - content.text = original.Substring( 0, i ); - Vector2 titleSize = UIUtils.UnZoomedNodeTitleStyle.CalcSize( content ); - if( titleSize.x > maxSize ) - { - addEllipsis = true; - break; - } - else - { - finalTitle = content.text; - } - } - if( addEllipsis ) - finalTitle += endString; - - return finalTitle; - } - - public virtual void RefreshOnUndo() { } - public virtual void CalculateCustomGraphDepth() { } - public int GraphDepth { get { return m_graphDepth; } } - - public PrecisionType CurrentPrecisionType { get { return m_currentPrecisionType == PrecisionType.Inherit ? ContainerGraph.CurrentPrecision : m_currentPrecisionType; } } - - - public Material PreviewMaterial - { - get - { - if( m_previewMaterial == null ) - { - m_previewMaterial = new Material( PreviewShader ); - } - return m_previewMaterial; - } - } - - public Shader PreviewShader - { - get - { - if( m_previewShader == null ) - { - m_previewShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( m_previewShaderGUID ) ); - } - - if( m_previewShader == null ) - { - m_previewShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "d9ca47581ac157145bff6f72ac5dd73e" ) ); //ranged float guid - } - - if( m_previewShader == null ) - m_previewShader = Shader.Find( "Unlit/Colored Transparent" ); - - return m_previewShader; - } - } - - public bool HasPreviewShader - { - get { return !string.IsNullOrEmpty( m_previewShaderGUID ); } - } - - public void CheckSpherePreview() - { - bool oneIsSphere = false; - - if( m_drawPreviewAsSphere ) - oneIsSphere = true; - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - ParentNode node = null; - if( m_inputPorts[ i ].ExternalReferences.Count > 0) - { - node = ContainerGraph.GetNode( m_inputPorts[ i ].ExternalReferences[ 0 ].NodeId ); - } - if( node != null && node.SpherePreview ) - oneIsSphere = true; - } - - if( m_forceDrawPreviewAsPlane ) - oneIsSphere = false; - - SpherePreview = oneIsSphere; - } - - public bool SpherePreview - { - get { return m_spherePreview; } - set { m_spherePreview = value; } - } - - public bool ShowPreview - { - get { return m_showPreview; } - set { m_showPreview = value; } - } - - public int VisiblePorts - { - get { return m_visiblePorts; } - set { m_visiblePorts = value; } - } - - public bool Docking - { - get { return m_docking; } - set { m_docking = value; } - } - - public bool UseSquareNodeTitle - { - get { return m_useSquareNodeTitle; } - set { m_useSquareNodeTitle = value; } - } - - public bool InsideShaderFunction - { - get { return ContainerGraph != ContainerGraph.ParentWindow.CurrentGraph; } - } - - public virtual void SetContainerGraph( ParentGraph newgraph ) - { - m_containerGraph = newgraph; - } - public virtual void OnMasterNodeReplaced( MasterNode newMasterNode ) { } - public virtual void RefreshExternalReferences() { } - - public Rect DropdownRect { get { return m_dropdownRect; } } - - public virtual bool Contains( Vector2 pos ) { return m_globalPosition.Contains( pos ); } - public virtual bool Contains( Vector3 pos ) { return m_globalPosition.Contains( pos ); } - public bool IsNodeBeingCopied { get { return m_isNodeBeingCopied; } set { m_isNodeBeingCopied = value; } } - - public virtual WirePortDataType GetInputPortVisualDataTypeByArrayIdx( int portArrayIdx ) - { - return m_inputPorts[ portArrayIdx ].DataType; - } - - public virtual WirePortDataType GetOutputPortVisualDataTypeById( int portId ) - { - return GetOutputPortByUniqueId( portId ).DataType; - } - - - public virtual bool CheckFindText( string text ) - { - return TitleContent.text.IndexOf( text, StringComparison.CurrentCultureIgnoreCase ) >= 0; - } - - public virtual float HeightEstimate - { - get - { - float heightEstimate = 0; - heightEstimate = 32 + Constants.INPUT_PORT_DELTA_Y; - for( int i = 0; i < InputPorts.Count; i++ ) - { - if( InputPorts[ i ].Visible ) - heightEstimate += 18 + Constants.INPUT_PORT_DELTA_Y; - } - - return heightEstimate; - // Magic number 18 represents m_fontHeight that might not be set yet - //return Constants.NODE_HEADER_EXTRA_HEIGHT + Mathf.Max( 18 + m_inputPorts.Count, m_outputPorts.Count ) * Constants.INPUT_PORT_DELTA_Y; - } - } - public bool Alive { get { return m_alive;} set { m_alive = value; } } - public string TypeName { get { if( m_nodeAttribs != null ) return m_nodeAttribs.Name;return GetType().ToString(); } } - public bool PreviewIsDirty { set { m_previewIsDirty = value; } get { return m_previewIsDirty; } } - protected bool FinishPreviewRender { get { return m_finishPreviewRender; } set { m_finishPreviewRender = value; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs.meta deleted file mode 100644 index c3a66c87..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 33e0374f361d5c642a257b9957e4cfa0 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs deleted file mode 100644 index 8bd85dc4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs +++ /dev/null @@ -1,170 +0,0 @@ -using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class ReordenatorNode : PropertyNode - { - [SerializeField] - private List<PropertyNode> m_propertyList; - - [SerializeField] - private string m_headerTitle = string.Empty; - - [SerializeField] - private bool m_isInside; - - public ReordenatorNode() : base() - { - - } - - public void Init( string entryName, string entryInspectorName, List<PropertyNode> list, bool register = true ) - { - m_propertyName = entryName; - m_propertyInspectorName = entryInspectorName; - - m_propertyList = list; - - if( register ) - UIUtils.RegisterPropertyNode( this ); - } - - public override void Destroy() - { - base.Destroy(); - - m_propertyList.Clear(); - m_propertyList = null; - - UIUtils.UnregisterPropertyNode( this ); - } - - //public List<ParentNode> PropertyList - //{ - // get { return m_propertyList; } - //} - - public int PropertyListCount - { - get { if ( m_propertyList != null ) return m_propertyList.Count; else return -1; } - } - - public string HeaderTitle { get { return m_headerTitle; } set { m_headerTitle = value; } } - - public bool HasTitle { get { return !string.IsNullOrEmpty( m_headerTitle ); } } - - public bool IsInside { get { return m_isInside; } set { m_isInside = value; } } - - public int RecursiveSetOrderOffset( int offset, bool lockit, int order = -1 ) - { - //Debug.Log( Locked + " " + PropertyName ); - - if ( Locked ) - return offset; - - if( order > -1 ) - OrderIndex = order; - - int currentOffset = offset; - - if( m_propertyList != null ) - m_propertyList.Sort( ( x, y ) => { return ( x as PropertyNode ).OrderIndex.CompareTo( ( y as PropertyNode ).OrderIndex ); } ); - - OrderIndexOffset = currentOffset - RawOrderIndex; - currentOffset++; - - if ( m_propertyList != null ) - for ( int i = 0; i < m_propertyList.Count; i++ ) - { - ReordenatorNode rnode = m_propertyList[ i ] as ReordenatorNode; - if ( rnode != null ) - { - currentOffset = rnode.RecursiveSetOrderOffset( currentOffset, false ); - } - else - { - PropertyNode pnode = m_propertyList[ i ] as PropertyNode; - { - pnode.OrderIndexOffset = currentOffset - pnode.RawOrderIndex;// + ( HasTitle ? 1 : 0 ); - } - currentOffset++; - } - } - - if ( lockit ) - Locked = true; - - return currentOffset; - } - - public int RecursiveCount() - { - int amount = 0; - if ( HasTitle ) - amount += 1; - for ( int i = 0; i < m_propertyList.Count; i++ ) - { - if ( ( m_propertyList[ i ] is ReordenatorNode ) ) - amount += ( m_propertyList[ i ] as ReordenatorNode ).RecursiveCount(); - else - amount +=1; - } - return amount; - } - - public void RecursiveLog() - { - Debug.LogWarning( OrderIndex+" HEADER "+ PropertyName ); - for( int i = 0; i < m_propertyList.Count; i++ ) - { - if( ( m_propertyList[ i ] is ReordenatorNode ) ) - ( m_propertyList[ i ] as ReordenatorNode ).RecursiveLog(); - else - Debug.Log( ( m_propertyList[ i ] as PropertyNode ).OrderIndex+" "+( m_propertyList[ i ] as PropertyNode).PropertyName ); - } - } - - public bool Locked = false; - - public void RecursiveClear() - { - Locked = false; - if( m_propertyList != null) - for ( int i = 0; i < m_propertyList.Count; i++ ) - { - ReordenatorNode renode = ( m_propertyList[ i ] as ReordenatorNode ); - if ( renode != null ) - { - renode.RecursiveClear(); - } - } - } - - public bool RecursiveConnectedProperties() - { - bool connected = false; - if ( m_propertyList != null ) - { - for ( int i = 0; i < m_propertyList.Count; i++ ) - { - ReordenatorNode renode = ( m_propertyList[ i ] as ReordenatorNode ); - if ( renode != null ) - { - bool temp = renode.RecursiveConnectedProperties(); - if( temp ) - connected = true; - } else - { - if ( ( m_propertyList[ i ] as PropertyNode ).IsConnected ) - connected = true; - } - } - } - return connected; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs.meta deleted file mode 100644 index 8dc50376..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/ReordenatorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 91aad2b9cfaf3954c8c450c32d218981 -timeCreated: 1493053838 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP.meta deleted file mode 100644 index 11d8b84b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 7283c593c3b4be64e957cb2b91abe1af -folderAsset: yes -timeCreated: 1556618802 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs deleted file mode 100644 index 7a67f480..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -#if UNITY_2018_3_OR_NEWER -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "SRP Baked GI", "Miscellaneous", "Gets Baked GI info." )] - public sealed class BakedGINode : ParentNode - { - private const string HDBakedGIHeader = "ASEBakedGI( {0}, {1}, {2}, {3} )"; - private readonly string[] HDBakedGIBody = - { - "float3 ASEBakedGI( float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap )\n", - "{\n", - "\tfloat3 positionRWS = GetCameraRelativePositionWS( positionWS );\n", - "\treturn SampleBakedGI( positionRWS, normalWS, uvStaticLightmap, uvDynamicLightmap );\n", - "}\n" - }; - - private readonly string LWBakedGIHeader = "ASEBakedGI( {0}, {1}, {2})"; - private readonly string[] LWBakedGIBody = - { - "float3 ASEBakedGI( float3 normalWS, float2 uvStaticLightmap, bool applyScaling )\n", - "{\n", - "#ifdef LIGHTMAP_ON\n", - "\tif( applyScaling )\n", - "\t\tuvStaticLightmap = uvStaticLightmap * unity_LightmapST.xy + unity_LightmapST.zw;\n", - "\treturn SampleLightmap( uvStaticLightmap, normalWS );\n", - "#else\n", - "\treturn SampleSH(normalWS);\n", - "#endif\n", - "}\n" - }; - - private const string ApplyScalingStr = "Apply Scaling"; - - [SerializeField] - private bool m_applyScaling = true; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "World Position" ); - AddInputPort( WirePortDataType.FLOAT3, false, "World Normal" ); - AddInputPort( WirePortDataType.FLOAT2, false, "Static UV" ); - AddInputPort( WirePortDataType.FLOAT2, false, "Dynamic UV" ); - AddOutputPort( WirePortDataType.FLOAT3, Constants.EmptyPortValue ); - m_textLabelWidth = 95; - m_autoWrapProperties = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - m_applyScaling = EditorGUILayoutToggle( ApplyScalingStr, m_applyScaling ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !dataCollector.IsSRP ) - { - UIUtils.ShowMessage( "Node only intended to use on HD and Lightweight rendering pipelines" ); - return GenerateErrorValue(); - } - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - - string positionWS = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string normalWS = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string uvStaticLightmap = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string uvDynamicLightmap = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - string localVarName = "bakedGI" + OutputId; - - if( dataCollector.TemplateDataCollectorInstance.IsHDRP ) - { - dataCollector.AddFunction( HDBakedGIBody[ 0 ], HDBakedGIBody, false ); - RegisterLocalVariable( 0, string.Format( HDBakedGIHeader, positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap ), ref dataCollector, localVarName ); - } - else - { - dataCollector.AddFunction( LWBakedGIBody[ 0 ], LWBakedGIBody, false ); - RegisterLocalVariable( 0, string.Format( LWBakedGIHeader, normalWS, uvStaticLightmap, m_applyScaling?"true":"false" ), ref dataCollector, localVarName ); - } - return localVarName; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_applyScaling = 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_applyScaling ); - } - - - } -} -#endif diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs.meta deleted file mode 100644 index e988a134..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/BakedGINode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6aacdecbe4e41f44988580058f7e0000 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs deleted file mode 100644 index b1721938..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Amplify Shader Editor - Visual Shader vEditing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [NodeAttributes( "Material Quality", "Logical Operators", "Choose between separate branches according to currently selected Quality (SRP only) ", Available = true )] - public class MaterialQualityNode : ParentNode - { - private const string SRPError = "Node intended to be used only on SRP templates as it makes use of keywords defined over that environment."; - - private const string MaxKeyword = "MATERIAL_QUALITY_HIGH"; - private const string MedKeyword = "MATERIAL_QUALITY_MEDIUM"; - private const string MinKeyword = "MATERIAL_QUALITY_LOW"; - private const string MaterialPragmas = "#pragma shader_feature " + MaxKeyword + " " + MedKeyword + " " + MinKeyword; - private readonly string[] MaterialCode = - { - "#if defined("+MaxKeyword+")", - "#elif defined("+MedKeyword+")", - "#else", - "#endif" - }; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "High" ); - AddInputPort( WirePortDataType.FLOAT, false, "Medium" ); - AddInputPort( WirePortDataType.FLOAT, false, "Low" ); - AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_errorMessageTypeIsError = NodeMessageType.Error; - m_errorMessageTooltip = SRPError; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - if( !ContainerGraph.IsSRP ) - { - if( !m_showErrorMessage ) - { - m_showErrorMessage = true; - } - } - else - { - if( m_showErrorMessage ) - { - m_showErrorMessage = 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 ); - - dataCollector.AddToDirectives( MaterialPragmas ); - string maxQualityValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string medQualityValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string minQualityValue = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - string localVarName = "currQuality" + OutputId; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, localVarName, "0" ); - - //High - dataCollector.AddLocalVariable( UniqueId, MaterialCode[ 0 ], true ); - dataCollector.AddLocalVariable( UniqueId, localVarName, maxQualityValue, false, true ); - - //Medium - dataCollector.AddLocalVariable( UniqueId, MaterialCode[ 1 ], true ); - dataCollector.AddLocalVariable( UniqueId, localVarName, medQualityValue, false, true ); - - //Low - dataCollector.AddLocalVariable( UniqueId, MaterialCode[ 2 ], true ); - dataCollector.AddLocalVariable( UniqueId, localVarName, minQualityValue,false,true ); - m_outputPorts[ 0 ].SetLocalValue( localVarName, dataCollector.PortCategory ); - - dataCollector.AddLocalVariable( UniqueId, MaterialCode[ 3 ], true ); - return localVarName; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs.meta deleted file mode 100644 index a322f3bb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SRP/MaterialQualityNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8245233e0833c884b8a176943d80514b -timeCreated: 1570027418 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs deleted file mode 100644 index 1e8c6d49..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace AmplifyShaderEditor -{ - public class SignalGeneratorNode : ParentNode, ISignalGenerator - { - public SignalGeneratorNode() : base() { } - public SignalGeneratorNode( 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 ); - SelfPowered = true; - } - - public void GenerateSignalPropagation() - { - System.Type myType = GetType(); - for ( int i = 0; i < m_inputPorts.Count; i++ ) - { - if ( m_inputPorts[ i ].IsConnected ) - { - m_inputPorts[ i ].GetOutputNode().ActivateNode( UniqueId, i, myType ); - } - } - } - - public void GenerateSignalInibitor() - { - for ( int i = 0; i < m_inputPorts.Count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - ParentNode node = m_inputPorts[ i ].GetOutputNode(); - if( node != null ) - node.DeactivateNode( i, false ); - } - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs.meta deleted file mode 100644 index 92146032..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SignalGeneratorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2f92560b009046f4a86504e682834405 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes.meta deleted file mode 100644 index 4f6f807b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 899b55cb557ca594f926ad64dfa4ad8f -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs deleted file mode 100644 index 463528fd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs +++ /dev/null @@ -1,58 +0,0 @@ -// 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( "Add", "Math Operators", "Addition of two or more values ( A + B + .. )", null, KeyCode.A )] - public sealed class SimpleAddOpNode : DynamicTypeNode - { - private int m_cachedPropertyId = -1; - - protected override void CommonInit( int uniqueId ) - { - m_dynamicRestrictions = new WirePortDataType[] - { - WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.INT - }; - - base.CommonInit( uniqueId ); - m_extensibleInputPorts = true; - m_previewShaderGUID = "9eb150cbc752cbc458a0a37984b9934a"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedPropertyId == -1 ) - m_cachedPropertyId = Shader.PropertyToID( "_Count" ); - - PreviewMaterial.SetInt( m_cachedPropertyId, m_inputPorts.Count); - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - string result = "( " + m_extensibleInputResults[ 0 ]; - for ( int i = 1; i < m_extensibleInputResults.Count; i++ ) - { - result += " + " + m_extensibleInputResults[ i ]; - } - result += " )"; - return result; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs.meta deleted file mode 100644 index c3660959..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleAddOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6ca9162ab6c708f40bbc21f0c22909fa -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs deleted file mode 100644 index 0cafeb3c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Divide", "Math Operators", "Division of two values ( A / B )", null, KeyCode.D )] - public sealed class SimpleDivideOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - m_dynamicRestrictions = new WirePortDataType[] - { - WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.INT - }; - - base.CommonInit( uniqueId ); - m_allowMatrixCheck = true; - m_previewShaderGUID = "409f06d00d1094849b0834c52791fa72"; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - SetExtensibleInputData( outputId, ref dataCollector, ignoreLocalvar ); - string result = "( " + m_extensibleInputResults[ 0 ]; - for ( int i = 1; i < m_extensibleInputResults.Count; i++ ) - { - result += " / " + m_extensibleInputResults[ i ]; - } - result += " )"; - return result; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs.meta deleted file mode 100644 index 98e759a8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleDivideOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e80e305761a1e6c4898e401a64b17f84 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs deleted file mode 100644 index fdb3c8ce..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Max", "Math Operators", "Maximum of two scalars or each respective component of two vectors" )] - public sealed class SimpleMaxOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_previewShaderGUID = "79d7f2a11092ac84a95ef6823b34adf2"; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - return "max( " + m_inputA + " , " + m_inputB + " )"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs.meta deleted file mode 100644 index fe8023a1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMaxOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4ea5a2904ca58164086eeb8ef3084ed2 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs deleted file mode 100644 index 4b24eb3c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Min", "Math Operators", "Minimum of two scalars or each respective component of two vectors" )] - public sealed class SimpleMinOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_previewShaderGUID = "d6033298044f0f14aa9932ca46e58ce6"; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - return "min( " + m_inputA + " , " + m_inputB + " )"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs.meta deleted file mode 100644 index a92e3e5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMinOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1b19c8479d7a7a9458a6f556bf6545d5 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs deleted file mode 100644 index 4a41a775..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Multiply", "Math Operators", "Multiplication of two or more values ( A * B * .. )\nIt also handles Matrices multiplication", null, KeyCode.M )] - public sealed class SimpleMultiplyOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - m_dynamicRestrictions = new WirePortDataType[] - { - WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.INT - }; - - base.CommonInit( uniqueId ); - m_extensibleInputPorts = true; - m_vectorMatrixOps = true; - m_previewShaderGUID = "1ba1e43e86415ff4bbdf4d81dfcf035b"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - int count = 0; - int inputCount = m_inputPorts.Count; - for( int i = 2; i < inputCount; i++ ) - { - count++; - if( !m_inputPorts[ i ].IsConnected ) - PreviewMaterial.SetTexture( ( "_" + Convert.ToChar( i + 65 ) ), UnityEditor.EditorGUIUtility.whiteTexture ); - } - - m_previewMaterialPassId = count; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 || - m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4x4 || - m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT3x3 || - m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT4x4 ) - { - m_inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - m_inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - - WirePortDataType autoCast = WirePortDataType.OBJECT; - // Check matrix on first input - if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 ) - { - switch( m_inputPorts[ 1 ].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - m_inputB = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT3, m_inputB ); - autoCast = WirePortDataType.FLOAT3; - } - break; - case WirePortDataType.FLOAT4x4: - { - m_inputA = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT4x4, m_inputA ); - } - break; - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT3x3: break; - } - } - - if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4x4 ) - { - switch( m_inputPorts[ 1 ].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - { - m_inputB = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT4, m_inputB ); - autoCast = WirePortDataType.FLOAT4; - } - break; - case WirePortDataType.FLOAT3x3: - { - m_inputB = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT4x4, m_inputB ); - } - break; - case WirePortDataType.FLOAT4x4: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: break; - } - } - - // Check matrix on second input - if( m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT3x3 ) - { - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: - { - m_inputA = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT3, m_inputA ); - autoCast = WirePortDataType.FLOAT3; - } - break; - case WirePortDataType.FLOAT4x4: - case WirePortDataType.FLOAT3: - case WirePortDataType.FLOAT3x3: break; - } - } - - if( m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT4x4 ) - { - switch( m_inputPorts[ 0 ].DataType ) - { - case WirePortDataType.OBJECT: - case WirePortDataType.FLOAT: - case WirePortDataType.INT: - case WirePortDataType.FLOAT2: - case WirePortDataType.FLOAT3: - { - m_inputA = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT4, m_inputA ); - autoCast = WirePortDataType.FLOAT4; - } - break; - case WirePortDataType.FLOAT3x3: - case WirePortDataType.FLOAT4x4: - case WirePortDataType.FLOAT4: - case WirePortDataType.COLOR: break; - } - } - string result = "mul( " + m_inputA + ", " + m_inputB + " )"; - if( autoCast != WirePortDataType.OBJECT && autoCast != m_outputPorts[ 0 ].DataType ) - { - result = UIUtils.CastPortType( ref dataCollector, CurrentPrecisionType, new NodeCastInfo( UniqueId, outputId ), result, autoCast, m_outputPorts[ 0 ].DataType, result ); - } - return result; - } - else - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - string result = "( " + m_extensibleInputResults[ 0 ]; - for( int i = 1; i < m_extensibleInputResults.Count; i++ ) - { - result += " * " + m_extensibleInputResults[ i ]; - } - result += " )"; - return result; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs.meta deleted file mode 100644 index 0283ca77..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleMultiplyOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 647081578ac7f014d98090d36b5b1bc8 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs deleted file mode 100644 index 64da4fdf..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs +++ /dev/null @@ -1,62 +0,0 @@ -// 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 ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs.meta deleted file mode 100644 index 528ea33f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleRemainderNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5785c326a26d2ba4ab642fc2bdd41e9a -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs deleted file mode 100644 index eaabab20..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Subtract", "Math Operators", "Subtraction of two values ( A - B )", null, UnityEngine.KeyCode.S )] - public sealed class SimpleSubtractOpNode : DynamicTypeNode - { - protected override void CommonInit( int uniqueId ) - { - m_dynamicRestrictions = new WirePortDataType[] - { - WirePortDataType.OBJECT, - WirePortDataType.FLOAT, - WirePortDataType.FLOAT2, - WirePortDataType.FLOAT3, - WirePortDataType.FLOAT4, - WirePortDataType.COLOR, - WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.INT - }; - - base.CommonInit( uniqueId ); - m_allowMatrixCheck = true; - m_previewShaderGUID = "5725e8300be208449973f771ab6682f2"; - } - - public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ); - return "( " + m_inputA + " - " + m_inputB + " )"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs.meta deleted file mode 100644 index a550f19a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SimpleNodes/SimpleSubtractOpNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 204f935dafd0a984297e242583de1da5 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs.meta deleted file mode 100644 index 4487ca30..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: ddb697d654917eb4aada5b2caeef2db8 -folderAsset: yes -timeCreated: 1481126946 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs deleted file mode 100644 index e4223e1b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs +++ /dev/null @@ -1,17 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta deleted file mode 100644 index 8f36faf6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ColorInputsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ee44f086d7aa7804ea035860c5735cfb -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs deleted file mode 100644 index 3e2a5117..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs +++ /dev/null @@ -1,118 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta deleted file mode 100644 index 5a57543d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/GrabScreenPosition.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 47af62ad6a29d1b409d526d352b5e677 -timeCreated: 1485198163 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs deleted file mode 100644 index 785e39fa..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta deleted file mode 100644 index 91b6b542..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/LocalVertexPosNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2528fbf85b5823a4499871c2a6eecc0a -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs deleted file mode 100644 index 60a7f230..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs +++ /dev/null @@ -1,678 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta deleted file mode 100644 index 2012d503..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenColorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b266c7cca236bcb469d6d4f13df55df5 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs deleted file mode 100644 index d08d1c80..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs +++ /dev/null @@ -1,173 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta deleted file mode 100644 index 95f77777..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenDepthNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 52266d8a6f7f4fe428dcee2ddb0514ac -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs deleted file mode 100644 index 6acaa57f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs +++ /dev/null @@ -1,155 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta deleted file mode 100644 index 60d2abbd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ScreenPosInputsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 32cea8ff65efa3844a0047477ec789da -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs deleted file mode 100644 index e0f094b0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs +++ /dev/null @@ -1,122 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta deleted file mode 100644 index 92a1e5b1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/SurfaceShaderINParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 71628885b2fde0944bf7dd8e4eb2770f -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs deleted file mode 100644 index 2659320f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs +++ /dev/null @@ -1,304 +0,0 @@ -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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta deleted file mode 100644 index 1e6fa013..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/TexelSizeNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1a23decd88779d24f9af6ae30c3d5a5f -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs deleted file mode 100644 index b259d89f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs +++ /dev/null @@ -1,112 +0,0 @@ -//// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta deleted file mode 100644 index eae8ca56..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 73fb18e7d547d514695cb0b83a29f80e -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs deleted file mode 100644 index e60a359f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs +++ /dev/null @@ -1,167 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta deleted file mode 100644 index 32985728..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/ViewDirInputsCoordNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4755b85e957e31d4b96d341070b156b5 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs deleted file mode 100644 index d179cddb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs +++ /dev/null @@ -1,119 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta deleted file mode 100644 index da99f65c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalInputsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 891e3ffa10c12c54e83a1e40df03df2f -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs deleted file mode 100644 index 861ee6d2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs +++ /dev/null @@ -1,178 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta deleted file mode 100644 index 7646e491..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldNormalVector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d61a084db19701c4fb3030ee953ac509 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs deleted file mode 100644 index 15c0b29f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs +++ /dev/null @@ -1,37 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta deleted file mode 100644 index 91f10c87..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldPosInputsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 850bb0065928b7f499b869b8adc1ce5c -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs deleted file mode 100644 index 99b49780..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta deleted file mode 100644 index 8e4e079d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflInputsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e4f39f3a52f10644392decce9d1e6790 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs deleted file mode 100644 index 30953218..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs +++ /dev/null @@ -1,213 +0,0 @@ -// 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/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta deleted file mode 100644 index eb2bf472..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/WorldReflectionVector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bd82e1d90bd90fc4d924e97e5fdcc7de -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures.meta deleted file mode 100644 index 263b4f74..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 3ab7ef71451065148bf8221d353c5020 -folderAsset: yes -timeCreated: 1481126945 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs deleted file mode 100644 index 6c063c65..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Blend Normals", "Textures", "Blend Normals" )] - public class BlendNormalsNode : ParentNode - { - public readonly static string[] ModeListStr = { "Tangent Normals", "Reoriented Tangent Normals", "Reoriented World Normals" }; - public readonly static int[] ModeListInt = { 0, 1, 2 }; - - [SerializeField] - public int m_selectedMode = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal A" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Normal B" ); - AddInputPort( WirePortDataType.FLOAT3, false, "Vertex Normal" ); - m_inputPorts[ 2 ].Visible = false; - AddOutputPort( WirePortDataType.FLOAT3, "XYZ" ); - m_useInternalPortData = true; - m_previewShaderGUID = "bcdf750ff5f70444f98b8a3efa50dc6f"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ); - - string _inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string _inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string result = "BlendNormals( " + _inputA + " , " + _inputB + " )"; - - if( dataCollector.IsTemplate && dataCollector.IsSRP ) - { - switch( m_selectedMode ) - { - default: - case 0: - result = "BlendNormal( " + _inputA + " , " + _inputB + " )"; - break; - case 1: - result = "BlendNormalRNM( " + _inputA + " , " + _inputB + " )"; - break; - case 2: - string inputC = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - result = "BlendNormalWorldspaceRNM( " + _inputA + " , " + _inputB + ", " + inputC + " )"; - break; - } - } - return CreateOutputLocalVariable( 0, result, ref dataCollector ); - } - - public override void DrawProperties() - { - base.DrawProperties(); - if( ContainerGraph.IsSRP ) - { - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, () => - { - EditorGUI.BeginChangeCheck(); - m_selectedMode = EditorGUILayoutIntPopup( "Mode", m_selectedMode, ModeListStr, ModeListInt ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_selectedMode == 2 ) - { - m_inputPorts[ 2 ].Visible = true; - } - else - { - m_inputPorts[ 2 ].Visible = false; - } - m_sizeIsDirty = true; - } - } ); - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 14503 ) - m_selectedMode = 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_selectedMode ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs.meta deleted file mode 100644 index b92fa344..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/BlendNormalsNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: eceb6029efe39524d83b45c10a979943 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs deleted file mode 100644 index fc1744f5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node HeightMap Texture Masking -// Donated by Rea - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "HeightMap Texture Blend", "Textures", "Advanced Texture Blending by using heightMap and splatMask, usefull for texture layering ", null, KeyCode.None, true, false, null, null, "Rea" )] - public sealed class HeightMapBlendNode : ParentNode - { - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "HeightMap" ); - AddInputPort( WirePortDataType.FLOAT, false, "SplatMask" ); - AddInputPort( WirePortDataType.FLOAT, false, "BlendStrength" ); - AddOutputVectorPorts( WirePortDataType.FLOAT, Constants.EmptyPortValue ); - m_textLabelWidth = 120; - m_useInternalPortData = true; - m_inputPorts[ 2 ].FloatInternalData = 1; - m_previewShaderGUID = "b2ac23d6d5dcb334982b6f31c2e7a734"; - } - - 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 HeightMap = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string SplatMask = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector); - string Blend = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - string HeightMask = "saturate(pow(((" + HeightMap + "*" + SplatMask + ")*4)+(" + SplatMask + "*2)," + Blend + "))"; - string varName = "HeightMask" + OutputId; - - RegisterLocalVariable( 0, HeightMask, ref dataCollector , varName ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - /* - A = (heightMap * SplatMask)*4 - B = SplatMask*2 - C = pow(A+B,Blend) - saturate(C) - saturate(pow(((heightMap * SplatMask)*4)+(SplatMask*2),Blend)); - */ - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs.meta deleted file mode 100644 index 62736ab3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b80a218ca12b89948b83d0dee41fc056 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs deleted file mode 100644 index e20c8c05..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Panner", "UV Coordinates", "Pans UV texture coordinates according to its inputs" )] - public sealed class PannerNode : ParentNode - { - private const string _speedXStr = "Speed X"; - private const string _speedYStr = "Speed Y"; - - private int m_cachedUsingEditorId = -1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ,-1,MasterNodePortCategory.Fragment,0); - AddInputPort( WirePortDataType.FLOAT2, false, "Speed", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, "Time", -1, MasterNodePortCategory.Fragment, 1 ); - AddOutputPort( WirePortDataType.FLOAT2, "Out" ); - m_textLabelWidth = 70; - m_useInternalPortData = true; - m_previewShaderGUID = "6f89a5d96bdad114b9bbd0c236cac622"; - m_inputPorts[ 2 ].FloatInternalData = 1; - m_continuousPreviewRefresh = true; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedUsingEditorId == -1 ) - m_cachedUsingEditorId = Shader.PropertyToID( "_UsingEditor" ); - - PreviewMaterial.SetFloat( m_cachedUsingEditorId, ( m_inputPorts[ 2 ].IsConnected ? 0 : 1 ) ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( portId == 1 ) - { - m_continuousPreviewRefresh = false; - } - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( portId == 1 ) - { - m_continuousPreviewRefresh = true; - } - } - - 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 timePort = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - if( !m_inputPorts[ 2 ].IsConnected ) - { - if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - timePort += " * _Time.y"; - } - - string speed = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string result = "( " + timePort + " * " + speed + " + " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ")"; - - RegisterLocalVariable( 0, result, ref dataCollector, "panner" + OutputId ); - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 13107 ) - { - // The internal data for the new port can be set in here since it didn't existed - // on older shader versions - float speedX = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - float speedY = Convert.ToSingle( GetCurrentParam( ref nodeParams ) ); - m_inputPorts[ 1 ].Vector2InternalData = new Vector2( speedX, speedY ); - } - } - - public override void ReadInputDataFromString( ref string[] nodeParams ) - { - base.ReadInputDataFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 13107 ) - { - //Time Port must be rewritten after internal data is read - // already existed in previous shaders - m_inputPorts[ 2 ].FloatInternalData = 1; - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs.meta deleted file mode 100644 index e05e46eb..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/PannerNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 08ddf1dd61719944b9e50d4bc87c0413 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs deleted file mode 100644 index 18aa7781..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Rotator", "UV Coordinates", "Rotates UVs or any Vector2 value from an Anchor point for a specified Time value")] - public sealed class RotatorNode : ParentNode - { - private int m_cachedUsingEditorId = -1; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT2, false, "Anchor" ); - AddInputPort( WirePortDataType.FLOAT, false, "Time" ); - AddOutputPort( WirePortDataType.FLOAT2, "Out" ); - m_useInternalPortData = true; - m_inputPorts[ 2 ].FloatInternalData = 1; - m_textLabelWidth = 50; - m_previewShaderGUID = "e21408a1c7f12f14bbc2652f69bce1fc"; - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if ( m_cachedUsingEditorId == -1 ) - m_cachedUsingEditorId = Shader.PropertyToID( "_UsingEditor" ); - - PreviewMaterial.SetFloat( m_cachedUsingEditorId, (m_inputPorts[ 2 ].IsConnected ? 0 : 1 ) ); - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( portId == 2 ) - { - m_continuousPreviewRefresh = false; - } - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( portId == 2 ) - { - m_continuousPreviewRefresh = true; - } - } - - - 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 result = string.Empty; - string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string anchor = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - string time = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - if ( !m_inputPorts[ 2 ].IsConnected ) - { - if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ); - time += " * _Time.y"; - } - - result += uv; - - string cosVar = "cos" + OutputId; - string sinVar = "sin" + OutputId; - dataCollector.AddLocalVariable( UniqueId, "float " + cosVar + " = cos( "+time+" );"); - dataCollector.AddLocalVariable( UniqueId, "float " + sinVar + " = sin( "+time+" );"); - - string value = "mul( " + result + " - " + anchor + " , float2x2( "+cosVar+" , -"+sinVar+" , "+sinVar+" , "+cosVar+" )) + "+anchor; - RegisterLocalVariable( 0, value, ref dataCollector, "rotator" + OutputId ); - - return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( UIUtils.CurrentShaderVersion() < 13107 ) - { - m_inputPorts[ 2 ].FloatInternalData = 1; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs.meta deleted file mode 100644 index b031237a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/RotatorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e228d03a789934a4f90f9587396692e3 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs deleted file mode 100644 index 5cf0833c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs +++ /dev/null @@ -1,2091 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - // Disabling Substance Deprecated warning - - public enum TexReferenceType - { - Object = 0, - Instance - } - - public enum MipType - { - Auto, - MipLevel, - MipBias, - Derivative - } - - public enum ReferenceState - { - Self, - Connected, - Instance - } - - [Serializable] -#if UNITY_2018_1_OR_NEWER - [NodeAttributes( "Texture Sample", "Textures", "Samples a chosen texture and returns its color values, <b>Texture</b> and <b>UVs</b> can be overriden and you can select different mip modes and levels. It can also unpack and scale textures marked as normalmaps.", KeyCode.T, true, 0, int.MaxValue, typeof( Texture ), typeof( Texture2D ), typeof( Texture3D ), typeof( Cubemap ), typeof( CustomRenderTexture ) )] -#else - - // Disabling Substance Deprecated warning -#pragma warning disable 0618 - [NodeAttributes( "Texture Sample", "Textures", "Samples a chosen texture and returns its color values, <b>Texture</b> and <b>UVs</b> can be overriden and you can select different mip modes and levels. It can also unpack and scale textures marked as normalmaps.", KeyCode.T, true, 0, int.MaxValue, typeof( Texture ), typeof( Texture2D ), typeof( Texture3D ), typeof( Cubemap ), typeof( ProceduralTexture ), typeof( RenderTexture ) -#if UNITY_2017_1_OR_NEWER - ,typeof( CustomRenderTexture ) -#endif - )] -#pragma warning restore 0618 -#endif - public sealed class SamplerNode : TexturePropertyNode - { - private const string MipModeStr = "Mip Mode"; - - private const string DefaultTextureUseSematicsStr = "Use Semantics"; - private const string DefaultTextureIsNormalMapsStr = "Is Normal Map"; - - private const string NormalScaleStr = "Scale"; - - private float InstanceIconWidth = 19; - private float InstanceIconHeight = 19; - - private readonly Color ReferenceHeaderColor = new Color( 2.66f, 1.02f, 0.6f, 1.0f ); - - public readonly static int[] AvailableAutoCast = { 0, 1, 2, 3, 4 }; - public readonly static string[] AvailableAutoCastStr = { "Auto", "Locked To Texture 1D", "Locked To Texture 2D", "Locked To Texture 3D", "Locked To Cube" }; - - [SerializeField] - private int m_textureCoordSet = 0; - - [SerializeField] - private string m_normalMapUnpackMode; - - [SerializeField] - private bool m_autoUnpackNormals = false; - - [SerializeField] - private bool m_useSemantics; - - [SerializeField] - private string m_samplerType; - - [SerializeField] - private MipType m_mipMode = MipType.Auto; - - [SerializeField] - private TexReferenceType m_referenceType = TexReferenceType.Object; - - [SerializeField] - private int m_referenceArrayId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - private SamplerNode m_referenceSampler = null; - - [SerializeField] - private GUIStyle m_referenceStyle = null; - - [SerializeField] - private GUIStyle m_referenceIconStyle = null; - - [SerializeField] - private GUIContent m_referenceContent = null; - - [SerializeField] - private float m_referenceWidth = -1; - - [SerializeField] - private SamplerStateAutoGenerator m_samplerStateAutoGenerator = new SamplerStateAutoGenerator(); - - private Vector4Node m_texCoordsHelper; - - private string m_previousAdditionalText = string.Empty; - - private int m_cachedUvsId = -1; - private int m_cachedUnpackId = -1; - private int m_cachedLodId = -1; - - private InputPort m_texPort; - private InputPort m_uvPort; - private InputPort m_lodPort; - private InputPort m_ddxPort; - private InputPort m_ddyPort; - private InputPort m_normalPort; - - private OutputPort m_colorPort; - - private TexturePropertyNode m_previewTextProp = null; - private ReferenceState m_state = ReferenceState.Self; - - private Rect m_iconPos; - - public SamplerNode() : base() { } - public SamplerNode( 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 ); - if( m_useSamplerArrayIdx < 0 ) - { - m_useSamplerArrayIdx = 0; - } - - m_defaultTextureValue = TexturePropertyValues.white; - AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex" ); - m_inputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Level" ); - AddInputPort( WirePortDataType.FLOAT2, false, "DDX" ); - AddInputPort( WirePortDataType.FLOAT2, false, "DDY" ); - AddInputPort( WirePortDataType.FLOAT, false, NormalScaleStr ); - - m_texPort = m_inputPorts[ 0 ]; - m_uvPort = m_inputPorts[ 1 ]; - m_lodPort = m_inputPorts[ 2 ]; - m_ddxPort = m_inputPorts[ 3 ]; - m_ddyPort = m_inputPorts[ 4 ]; - m_normalPort = m_inputPorts[ 5 ]; - m_normalPort.AutoDrawInternalData = true; - m_lodPort.Visible = false; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - m_normalPort.Visible = m_autoUnpackNormals; - m_normalPort.FloatInternalData = 1.0f; - - //Remove output port (sampler) - m_outputPortsDict.Remove( m_outputPorts[ 0 ].PortId ); - m_outputPorts.RemoveAt( 0 ); - - AddOutputColorPorts( "RGBA" ); - m_colorPort = m_outputPorts[ 0 ]; - m_currentParameterType = PropertyType.Property; - // m_useCustomPrefix = true; - m_customPrefix = "Texture Sample "; - m_referenceContent = new GUIContent( string.Empty ); - m_freeType = false; - m_useSemantics = true; - m_drawPicker = false; - ConfigTextureData( TextureType.Texture2D ); - m_selectedLocation = PreviewLocation.TopCenter; - m_previewShaderGUID = "7b4e86a89b70ae64993bf422eb406422"; - - m_errorMessageTooltip = "A texture object marked as normal map is connected to this sampler. Please consider turning on the Unpack Normal Map option"; - m_errorMessageTypeIsError = NodeMessageType.Warning; - m_textLabelWidth = 135; - m_customPrecision = false; - } - - public override void SetPreviewInputs() - { - //TODO: rewrite this to be faster - base.SetPreviewInputs(); - - if( m_cachedUvsId == -1 ) - m_cachedUvsId = Shader.PropertyToID( "_CustomUVs" ); - - PreviewMaterial.SetInt( m_cachedUvsId, ( m_uvPort.IsConnected ? 1 : 0 ) ); - - if( m_cachedUnpackId == -1 ) - m_cachedUnpackId = Shader.PropertyToID( "_Unpack" ); - - PreviewMaterial.SetInt( m_cachedUnpackId, m_autoUnpackNormals ? 1 : 0 ); - - if( m_cachedLodId == -1 ) - m_cachedLodId = Shader.PropertyToID( "_LodType" ); - - PreviewMaterial.SetInt( m_cachedLodId, ( m_mipMode == MipType.MipLevel ? 1 : ( m_mipMode == MipType.MipBias ? 2 : 0 ) ) ); - - if( m_typeId == -1 ) - m_typeId = Shader.PropertyToID( "_Type" ); - - bool usingTexture = false; - if( m_texPort.IsConnected ) - { - usingTexture = true; - SetPreviewTexture( m_texPort.InputPreviewTexture( ContainerGraph ) ); - } - else if( SoftValidReference && m_referenceSampler.TextureProperty != null ) - { - if( m_referenceSampler.TextureProperty.Value != null ) - { - usingTexture = true; - SetPreviewTexture( m_referenceSampler.TextureProperty.Value ); - } - else - { - usingTexture = true; - SetPreviewTexture( m_referenceSampler.PreviewTexture ); - } - } - else if( TextureProperty != null ) - { - if( TextureProperty.Value != null ) - { - usingTexture = true; - SetPreviewTexture( TextureProperty.Value ); - } - } - - if( m_defaultId == -1 ) - m_defaultId = Shader.PropertyToID( "_Default" ); - - if( usingTexture ) - { - PreviewMaterial.SetInt( m_defaultId, 0 ); - m_previewMaterialPassId = 1; - } - else - { - PreviewMaterial.SetInt( m_defaultId, ( (int)m_defaultTextureValue ) + 1 ); - m_previewMaterialPassId = 0; - } - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterSamplerNode( this ); - UIUtils.RegisterPropertyNode( this ); - } - m_textureProperty = this; - - if( UniqueId > -1 ) - ContainerGraph.SamplerNodes.OnReorderEventComplete += OnReorderEventComplete; - } - - private void OnReorderEventComplete() - { - if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null ) - { - m_referenceArrayId = ContainerGraph.SamplerNodes.GetNodeRegisterIdx( m_referenceSampler.UniqueId ); - } - } - - public void ConfigSampler() - { - switch( m_currentType ) - { - case TextureType.Texture1D: - m_samplerType = "tex1D"; - break; - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - m_samplerType = "tex2D"; - break; - case TextureType.Texture3D: - m_samplerType = "tex3D"; - break; - case TextureType.Cube: - m_samplerType = "texCUBE"; - break; - } - } - - public override void DrawSubProperties() - { - ShowDefaults(); - - DrawSamplerOptions(); - - EditorGUI.BeginChangeCheck(); - Type currType = ( m_autocastMode == AutoCastType.Auto ) ? typeof( Texture ) : m_textureType; - m_defaultValue = EditorGUILayoutObjectField( Constants.DefaultValueLabel, m_defaultValue, currType, false ) as Texture; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - } - - public override void DrawMaterialProperties() - { - ShowDefaults(); - - DrawSamplerOptions(); - - EditorGUI.BeginChangeCheck(); - Type currType = ( m_autocastMode == AutoCastType.Auto ) ? typeof( Texture ) : m_textureType; - m_materialValue = EditorGUILayoutObjectField( Constants.MaterialValueLabel, m_materialValue, currType, false ) as Texture; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - } - - new void ShowDefaults() - { - m_defaultTextureValue = (TexturePropertyValues)EditorGUILayoutEnumPopup( DefaultTextureStr, m_defaultTextureValue ); - AutoCastType newAutoCast = (AutoCastType)EditorGUILayoutIntPopup( AutoCastModeStr, (int)m_autocastMode, AvailableAutoCastStr, AvailableAutoCast ); - //AutoCastType newAutoCast = (AutoCastType)EditorGUILayoutEnumPopup( AutoCastModeStr, m_autocastMode ); - if( newAutoCast != m_autocastMode ) - { - m_autocastMode = newAutoCast; - if( m_autocastMode != AutoCastType.Auto ) - { - ConfigTextureData( m_currentType ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - } - } - - public override void AdditionalCheck() - { - m_autoUnpackNormals = m_isNormalMap; - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - - - public override void OnConnectedOutputNodeChanges( int portId, int otherNodeId, int otherPortId, string name, WirePortDataType type ) - { - base.OnConnectedOutputNodeChanges( portId, otherNodeId, otherPortId, name, type ); - if( portId == m_texPort.PortId ) - { - m_textureProperty = m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode; - if( m_textureProperty != null ) - { - m_currentType = m_textureProperty.CurrentType; - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - } - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - - if( portId == m_texPort.PortId ) - { - m_textureProperty = m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode; - - if( m_textureProperty == null ) - { - m_textureProperty = this; - // This cast fails only from within shader functions if connected to a Sampler Input - // and in this case property is set by what is connected to that input - UIUtils.UnregisterPropertyNode( this ); - UIUtils.UnregisterTexturePropertyNode( this ); - } - else - { - //if( m_autocastMode == AutoCastType.Auto ) - //{ - m_currentType = m_textureProperty.CurrentType; - //} - - - //if ( m_textureProperty is VirtualTexturePropertyNode ) - //{ - // AutoUnpackNormals = ( m_textureProperty as VirtualTexturePropertyNode ).Channel == VirtualChannel.Normal; - //} - //else if( m_textureProperty.IsValid ) - //{ - - // AutoUnpackNormals = m_textureProperty.IsNormalMap; - //} - - UIUtils.UnregisterPropertyNode( this ); - UIUtils.UnregisterTexturePropertyNode( this ); - } - - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - - UpdateTitle(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - - if( portId == m_texPort.PortId ) - { - m_textureProperty = this; - - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterPropertyNode( this ); - UIUtils.RegisterTexturePropertyNode( this ); - } - - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - - UpdateTitle(); - } - - private void ForceInputPortsChange() - { - m_texPort.ChangeType( WirePortDataType.SAMPLER2D, false ); - m_normalPort.ChangeType( WirePortDataType.FLOAT, false ); - switch( m_currentType ) - { - case TextureType.Texture1D: - m_uvPort.ChangeType( WirePortDataType.FLOAT, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT, false ); - break; - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - m_uvPort.ChangeType( WirePortDataType.FLOAT2, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT2, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT2, false ); - break; - case TextureType.Texture3D: - case TextureType.Cube: - m_uvPort.ChangeType( WirePortDataType.FLOAT3, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT3, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT3, false ); - break; - } - } - - public override void ConfigureInputPorts() - { - m_normalPort.Visible = AutoUnpackNormals; - - switch( m_mipMode ) - { - case MipType.Auto: - m_lodPort.Visible = false; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - break; - case MipType.MipLevel: - m_lodPort.Name = "Level"; - m_lodPort.Visible = true; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - break; - case MipType.MipBias: - m_lodPort.Name = "Bias"; - m_lodPort.Visible = true; - m_ddxPort.Visible = false; - m_ddyPort.Visible = false; - break; - case MipType.Derivative: - m_lodPort.Visible = false; - m_ddxPort.Visible = true; - m_ddyPort.Visible = true; - break; - } - - switch( m_currentType ) - { - case TextureType.Texture1D: - m_uvPort.ChangeType( WirePortDataType.FLOAT, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT, false ); - break; - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - m_uvPort.ChangeType( WirePortDataType.FLOAT2, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT2, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT2, false ); - break; - case TextureType.Texture3D: - case TextureType.Cube: - m_uvPort.ChangeType( WirePortDataType.FLOAT3, false ); - m_ddxPort.ChangeType( WirePortDataType.FLOAT3, false ); - m_ddyPort.ChangeType( WirePortDataType.FLOAT3, false ); - break; - } - - m_sizeIsDirty = true; - } - - public override void ConfigureOutputPorts() - { - m_outputPorts[ m_colorPort.PortId + 4 ].Visible = !AutoUnpackNormals; - - if( !AutoUnpackNormals ) - { - m_colorPort.ChangeProperties( "RGBA", WirePortDataType.COLOR, false ); - m_outputPorts[ m_colorPort.PortId + 1 ].ChangeProperties( "R", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 2 ].ChangeProperties( "G", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 3 ].ChangeProperties( "B", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 4 ].ChangeProperties( "A", WirePortDataType.FLOAT, false ); - - } - else - { - m_colorPort.ChangeProperties( "XYZ", WirePortDataType.FLOAT3, false ); - m_outputPorts[ m_colorPort.PortId + 1 ].ChangeProperties( "X", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 2 ].ChangeProperties( "Y", WirePortDataType.FLOAT, false ); - m_outputPorts[ m_colorPort.PortId + 3 ].ChangeProperties( "Z", WirePortDataType.FLOAT, false ); - } - - m_sizeIsDirty = true; - } - - void UpdateTitle() - { - if( m_referenceType == TexReferenceType.Object ) - { - SetTitleText( m_propertyInspectorName ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - } - - m_sizeIsDirty = true; - } - - public override void OnObjectDropped( UnityEngine.Object obj ) - { - base.OnObjectDropped( obj ); - ConfigFromObject( obj ); - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - base.SetupFromCastObject( obj ); - ConfigFromObject( obj ); - } - - void UpdateHeaderColor() - { - m_headerColorModifier = ( m_referenceType == TexReferenceType.Object ) ? Color.white : ReferenceHeaderColor; - } - - - - void ShowSamplerUI() - { - if( UIUtils.CurrentWindow.OutsideGraph.IsSRP ) - { - string[] contents = UIUtils.TexturePropertyNodeArr(); - string[] arr = new string[ contents.Length + 1 ]; - arr[ 0 ] = "<None>"; - for( int i = 1; i < contents.Length + 1; i++ ) - { - arr[ i ] = contents[ i - 1 ]; - } - m_useSamplerArrayIdx = EditorGUILayoutPopup( "Reference Sampler", m_useSamplerArrayIdx, arr ); - m_samplerStateAutoGenerator.Draw( this ); - } - } - - public void DrawSamplerOptions() - { - m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ); - - MipType newMipMode = (MipType)EditorGUILayoutEnumPopup( MipModeStr, m_mipMode ); - if( newMipMode != m_mipMode ) - { - m_mipMode = newMipMode; - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - - EditorGUI.BeginChangeCheck(); - m_autoUnpackNormals = EditorGUILayoutToggle( "Unpack Normal Map", m_autoUnpackNormals ); - if( m_autoUnpackNormals && !m_normalPort.IsConnected ) - { - m_normalPort.FloatInternalData = EditorGUILayoutFloatField( NormalScaleStr, m_normalPort.FloatInternalData ); - } - - if( EditorGUI.EndChangeCheck() ) - { - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - ShowSamplerUI(); - if( m_showErrorMessage ) - { - EditorGUILayout.HelpBox( m_errorMessageTooltip, MessageType.Warning ); - } - } - - public override void DrawMainPropertyBlock() - { - EditorGUI.BeginChangeCheck(); - m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ); - if( EditorGUI.EndChangeCheck() ) - { - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.RegisterSamplerNode( this ); - UIUtils.RegisterPropertyNode( this ); - if( !m_texPort.IsConnected ) - UIUtils.RegisterTexturePropertyNode( this ); - - SetTitleText( m_propertyInspectorName ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - m_referenceArrayId = -1; - m_referenceNodeId = -1; - m_referenceSampler = null; - m_textureProperty = m_texPort.IsConnected ? m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode : this; - - } - else - { - UIUtils.UnregisterSamplerNode( this ); - UIUtils.UnregisterPropertyNode( this ); - if( !m_texPort.IsConnected ) - UIUtils.UnregisterTexturePropertyNode( this ); - } - UpdateHeaderColor(); - } - - if( m_referenceType == TexReferenceType.Object ) - { - EditorGUI.BeginChangeCheck(); - if( m_texPort.IsConnected ) - { - m_drawAttributes = false; - DrawSamplerOptions(); - } - else - { - m_drawAttributes = true; - base.DrawMainPropertyBlock(); - } - if( EditorGUI.EndChangeCheck() ) - { - OnPropertyNameChanged(); - } - } - else - { - m_drawAttributes = true; - string[] arr = UIUtils.SamplerNodeArr(); - bool guiEnabledBuffer = GUI.enabled; - if( arr != null && arr.Length > 0 ) - { - GUI.enabled = true; - } - else - { - m_referenceArrayId = -1; - GUI.enabled = false; - } - - EditorGUI.BeginChangeCheck(); - m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId, arr ); - if( EditorGUI.EndChangeCheck() ) - { - m_referenceSampler = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - if( m_referenceSampler != null ) - { - m_referenceNodeId = m_referenceSampler.UniqueId; - } - else - { - m_referenceArrayId = -1; - m_referenceNodeId = -1; - } - } - GUI.enabled = guiEnabledBuffer; - - DrawSamplerOptions(); - } - } - - public override void OnPropertyNameChanged() - { - base.OnPropertyNameChanged(); - UIUtils.UpdateSamplerDataNode( UniqueId, PropertyName ); - UIUtils.UpdateTexturePropertyDataNode( UniqueId, PropertyName ); - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( m_state != ReferenceState.Self && drawInfo.CurrentEventType == EventType.MouseDown && m_previewRect.Contains( drawInfo.MousePosition ) && drawInfo.LeftMouseButtonPressed ) - { - UIUtils.FocusOnNode( m_previewTextProp, 1, true ); - Event.current.Use(); - } - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - CheckReference(); - - if( SoftValidReference ) - { - m_state = ReferenceState.Instance; - m_previewTextProp = m_referenceSampler.TextureProperty; - } - else if( m_texPort.IsConnected ) - { - m_state = ReferenceState.Connected; - m_previewTextProp = TextureProperty; - } - else - { - m_state = ReferenceState.Self; - } - - if( m_previewTextProp == null ) - m_previewTextProp = this; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - if( m_drawPreview ) - { - m_iconPos = m_globalPosition; - m_iconPos.width = InstanceIconWidth * drawInfo.InvertedZoom; - m_iconPos.height = InstanceIconHeight * drawInfo.InvertedZoom; - - m_iconPos.y += 10 * drawInfo.InvertedZoom; - m_iconPos.x += m_globalPosition.width - m_iconPos.width - 5 * drawInfo.InvertedZoom; - } - } - - public override void OnNodeRepaint( DrawInfo drawInfo ) - { - base.OnNodeRepaint( drawInfo ); - - if( !m_isVisible ) - return; - - if( drawInfo.CurrentEventType != EventType.Repaint ) - return; - - switch( m_state ) - { - default: - case ReferenceState.Self: - { - m_drawPreview = false; - //SetTitleText( PropertyInspectorName /*m_propertyInspectorName*/ ); - //small optimization, string format or concat on every frame generates garbage - //string tempVal = GetPropertyValStr(); - //if ( !m_previousAdditionalText.Equals( tempVal ) ) - //{ - // m_previousAdditionalText = tempVal; - // m_additionalContent.text = string.Concat( "Value( ", tempVal, " )" ); - //} - - m_drawPicker = true; - } - break; - case ReferenceState.Connected: - { - m_drawPreview = true; - m_drawPicker = false; - - SetTitleText( m_previewTextProp.PropertyInspectorName + " (Input)" ); - m_previousAdditionalText = m_previewTextProp.AdditonalTitleContent.text; - SetAdditonalTitleText( m_previousAdditionalText ); - // Draw chain lock - GUI.Label( m_iconPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ) ); - - // Draw frame around preview - GUI.Label( m_previewRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - break; - case ReferenceState.Instance: - { - m_drawPreview = true; - m_drawPicker = false; - - //SetTitleText( m_previewTextProp.PropertyInspectorName + Constants.InstancePostfixStr ); - //m_previousAdditionalText = m_previewTextProp.AdditonalTitleContent.text; - //SetAdditonalTitleText( m_previousAdditionalText ); - - SetTitleTextOnCallback( m_previewTextProp.PropertyInspectorName, ( instance, newTitle ) => instance.TitleContent.text = newTitle + Constants.InstancePostfixStr ); - SetAdditonalTitleText( m_previewTextProp.AdditonalTitleContent.text ); - - // Draw chain lock - GUI.Label( m_iconPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ) ); - - // Draw frame around preview - GUI.Label( m_previewRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - break; - } - } - - void CheckReference() - { - if( m_referenceType != TexReferenceType.Instance ) - { - return; - } - - if( m_referenceArrayId > -1 ) - { - ParentNode newNode = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - if( newNode == null || newNode.UniqueId != m_referenceNodeId ) - { - m_referenceSampler = null; - int count = ContainerGraph.SamplerNodes.NodesList.Count; - for( int i = 0; i < count; i++ ) - { - ParentNode node = ContainerGraph.SamplerNodes.GetNode( i ); - if( node.UniqueId == m_referenceNodeId ) - { - m_referenceSampler = node as SamplerNode; - m_referenceArrayId = i; - break; - } - } - } - else - { - // Set References Options - AutoCastType newAutoCast = m_referenceSampler.AutocastMode; - if( newAutoCast != m_autocastMode ) - { - m_autocastMode = newAutoCast; - if( m_autocastMode != AutoCastType.Auto ) - { - ConfigTextureData( m_currentType ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - } - } - } - - if( m_referenceSampler == null && m_referenceNodeId > -1 ) - { - m_referenceNodeId = -1; - m_referenceArrayId = -1; - } - } - - public void SetTitleTextDelay( string newText ) - { - if( !newText.Equals( m_content.text ) ) - { - m_content.text = newText; - BeginDelayedDirtyProperty(); - } - } - - public void SetAdditonalTitleTextDelay( string newText ) - { - if( !newText.Equals( m_additionalContent.text ) ) - { - m_additionalContent.text = newText; - BeginDelayedDirtyProperty(); - } - } - - private void DrawTexturePropertyPreview( DrawInfo drawInfo, bool instance ) - { - if( drawInfo.CurrentEventType != EventType.Repaint ) - return; - - Rect newPos = m_previewRect; - - TexturePropertyNode texProp = null; - if( instance ) - texProp = m_referenceSampler.TextureProperty; - else - texProp = TextureProperty; - - if( texProp == null ) - texProp = this; - - float previewSizeX = PreviewSizeX; - float previewSizeY = PreviewSizeY; - newPos.width = previewSizeX * drawInfo.InvertedZoom; - newPos.height = previewSizeY * drawInfo.InvertedZoom; - - SetTitleText( texProp.PropertyInspectorName + ( instance ? Constants.InstancePostfixStr : " (Input)" ) ); - SetAdditonalTitleText( texProp.AdditonalTitleContent.text ); - - if( m_referenceStyle == null ) - { - m_referenceStyle = UIUtils.GetCustomStyle( CustomStyle.SamplerTextureRef ); - } - - if( m_referenceIconStyle == null || m_referenceIconStyle.normal == null ) - { - m_referenceIconStyle = UIUtils.GetCustomStyle( CustomStyle.SamplerTextureIcon ); - if( m_referenceIconStyle != null && m_referenceIconStyle.normal != null && m_referenceIconStyle.normal.background != null ) - { - InstanceIconWidth = m_referenceIconStyle.normal.background.width; - InstanceIconHeight = m_referenceIconStyle.normal.background.height; - } - } - - Rect iconPos = m_globalPosition; - iconPos.width = InstanceIconWidth * drawInfo.InvertedZoom; - iconPos.height = InstanceIconHeight * drawInfo.InvertedZoom; - - iconPos.y += 10 * drawInfo.InvertedZoom; - iconPos.x += m_globalPosition.width - iconPos.width - 5 * drawInfo.InvertedZoom; - - //if ( GUI.Button( newPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerTextureRef )/* m_referenceStyle */) || - // GUI.Button( iconPos, string.Empty, m_referenceIconStyle ) - // ) - //{ - // UIUtils.FocusOnNode( texProp, 1, true ); - //} - - if( texProp.Value != null ) - { - DrawPreview( drawInfo, m_previewRect ); - GUI.Label( newPos, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - //UIUtils.GetCustomStyle( CustomStyle.SamplerButton ).fontSize = ( int )Mathf.Round( 9 * drawInfo.InvertedZoom ); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port" ); - return "(-1)"; - } - - OnPropertyNameChanged(); - - ConfigSampler(); - - string portProperty = string.Empty; - if( m_texPort.IsConnected ) - portProperty = m_texPort.GenerateShaderForOutput( ref dataCollector, true ); - - if( SoftValidReference ) - { - OrderIndex = m_referenceSampler.RawOrderIndex; - if( m_referenceSampler.TexPort.IsConnected ) - { - portProperty = m_referenceSampler.TexPort.GeneratePortInstructions( ref dataCollector ); - } - else - { - m_referenceSampler.RegisterProperty( ref dataCollector ); - } - } - - if( m_autoUnpackNormals ) - { - bool isScaledNormal = false; - if( m_normalPort.IsConnected ) - { - isScaledNormal = true; - } - else - { - if( m_normalPort.FloatInternalData != 1 ) - { - isScaledNormal = true; - } - } - - string scaleValue = isScaledNormal ? m_normalPort.GeneratePortInstructions( ref dataCollector ) : "1.0f"; - m_normalMapUnpackMode = TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, isScaledNormal, scaleValue ); - - if( isScaledNormal ) - { - if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ); - } - } - - } - if( IsObject && ( !m_texPort.IsConnected || portProperty == "0.0" ) ) - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - - string valueName = SetFetchedData( ref dataCollector, ignoreLocalVar, outputId, portProperty ); - if( TextureProperty is VirtualTextureObject ) - { - return valueName; - } - else - { - - return GetOutputColorItem( 0, outputId, valueName ); - } - } - - public string SampleVirtualTexture( VirtualTextureObject node, string coord ) - { - string sampler = string.Empty; - switch( node.Channel ) - { - default: - case VirtualChannel.Albedo: - case VirtualChannel.Base: - sampler = "VTSampleAlbedo( " + coord + " )"; - break; - case VirtualChannel.Normal: - case VirtualChannel.Height: - case VirtualChannel.Occlusion: - case VirtualChannel.Displacement: - sampler = "VTSampleNormal( " + coord + " )"; - break; - case VirtualChannel.Specular: - case VirtualChannel.SpecMet: - case VirtualChannel.Material: - sampler = "VTSampleSpecular( " + coord + " )"; - break; - } - return sampler; - } - - public string SampleTexture( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, string portProperty, MipType currMipMode, string propertyName ) - { - string samplerValue = string.Empty; - string uvCoords = GetUVCoords( ref dataCollector, ignoreLocalVar, portProperty ); - bool useMacros = false; - - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - useMacros = Constants.TexSampleSRPMacros.ContainsKey( m_currentType ); - } - else - { - useMacros = Constants.TexSampleStandardMacros.ContainsKey( m_currentType ); - } - } - - if( useMacros ) - { - string suffix = string.Empty; - if( m_lodPort.IsConnected ) - { - switch( currMipMode ) - { - default: - case MipType.Auto: break; - case MipType.MipLevel: suffix = "_LOD"; break; - case MipType.MipBias: suffix = "_BIAS"; break; - case MipType.Derivative: suffix = "_GRAD"; break; - } - } - else - { - switch( currMipMode ) - { - default: - case MipType.MipLevel: - case MipType.MipBias: - case MipType.Auto: break; - case MipType.Derivative: suffix = "_GRAD"; break; - } - } - string samplerToUse = string.Empty; - if( m_useSamplerArrayIdx > 0 ) - { - TexturePropertyNode samplerNode = UIUtils.GetTexturePropertyNode( m_useSamplerArrayIdx - 1 ); - if( samplerNode != null ) - { - if( samplerNode.IsConnected ) - { - samplerToUse = samplerNode.CurrentPropertyReference; - } - else - { - UIUtils.ShowMessage( UniqueId, string.Format( "{0} attempting to use sampler from unconnected {1} node. Reference Sampler nodes must be in use for their samplers to be created.", m_propertyName, samplerNode.PropertyName ), MessageSeverity.Warning ); - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ m_currentType ], propertyName ) ); - samplerToUse = propertyName; - } - } - else - { - UIUtils.ShowMessage( UniqueId, m_propertyName + " attempting to use sampler from invalid node.", MessageSeverity.Warning ); - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ m_currentType ], propertyName ) ); - samplerToUse = propertyName; - } - } - else - { - if( HasPropertyReference ) - dataCollector.AddToUniforms( UniqueId, string.Format( Constants.SamplerDeclarationSRPMacros[ m_currentType ], propertyName ) ); - - samplerToUse = propertyName; - } - - if( outsideGraph.IsSRP ) - { - samplerValue = string.Format( Constants.TexSampleSRPMacros[ m_currentType ], suffix, propertyName, samplerToUse, uvCoords ); - } - else - { - GeneratorUtils.AddCustomStandardSamplingMacros( ref dataCollector ); - - samplerValue = string.Format( Constants.TexSampleStandardMacros[ m_currentType ], suffix, propertyName, uvCoords ); - } - } - else - { - string mipType = ""; - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - mipType = "lod"; - } - - if( m_lodPort.IsConnected ) - { - switch( currMipMode ) - { - case MipType.Auto: - break; - case MipType.MipLevel: - mipType = "lod"; - break; - case MipType.MipBias: - mipType = "bias"; - break; - case MipType.Derivative: - break; - } - } - samplerValue = m_samplerType + mipType + "( " + propertyName + ", " + uvCoords + " )"; - } - - return samplerValue; - } - - public string SetFetchedData( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, int outputId, string portProperty = null ) - { - m_precisionString = UIUtils.PrecisionWirePortToCgType( CurrentPrecisionType, m_colorPort.DataType ); - string propertyName = CurrentPropertyReference; - if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) - { - propertyName = portProperty; - } - MipType currMipMode = m_mipMode; - //string mipType = ""; - //if( m_lodPort.IsConnected ) - //{ - // switch( m_mipMode ) - // { - // case MipType.Auto: - // break; - // case MipType.MipLevel: - // mipType = "lod"; - // break; - // case MipType.MipBias: - // mipType = "bias"; - // break; - // case MipType.Derivative: - // break; - // } - //} - //string uvCoords = string.Empty; - //bool useMacros = false; - if( ignoreLocalVar ) - { - if( TextureProperty is VirtualTextureObject ) - Debug.Log( "TODO" ); - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - //mipType = "lod"; - currMipMode = MipType.MipLevel; - } - - string samplerValue = SampleTexture( ref dataCollector, ignoreLocalVar, portProperty, currMipMode, propertyName ); - //string samplerValue = string.Empty; - //uvCoords = GetUVCoords( ref dataCollector, ignoreLocalVar, portProperty ); - //useMacros = m_containerGraph.SamplingThroughMacros && !mipType.Equals( "bias" ) && Constants.TexSampleStandardMacros.ContainsKey( m_currentType ); - //if( useMacros ) - //{ - // bool addLodPrefix = mipType.Equals( "lod" ); - // samplerValue = string.Format( Constants.TexSampleStandardMacros[ m_currentType ], addLodPrefix ? Constants.TexSampleLODPrefix : string.Empty, propertyName, uvCoords ); - //} - //else - //{ - // samplerValue = m_samplerType + mipType + "( " + propertyName + ", " + uvCoords + " )"; - //} - AddNormalMapTag( ref samplerValue ); - return samplerValue; - } - - VirtualTextureObject vtex = ( TextureProperty as VirtualTextureObject ); - - if( vtex != null ) - { - string atPathname = AssetDatabase.GUIDToAssetPath( Constants.ATSharedLibGUID ); - if( string.IsNullOrEmpty( atPathname ) ) - { - UIUtils.ShowMessage( UniqueId, "Could not find Amplify Texture on your project folder. Please install it and re-compile the shader.", MessageSeverity.Error ); - } - else - { - //Need to see if the asset really exists because AssetDatabase.GUIDToAssetPath() can return a valid path if - // the asset was previously imported and deleted after that - UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>( atPathname ); - if( obj == null ) - { - UIUtils.ShowMessage( UniqueId, "Could not find Amplify Texture on your project folder. Please install it and re-compile the shader.", MessageSeverity.Error ); - } - else - { - if( m_colorPort.IsLocalValue( dataCollector.PortCategory ) ) - return m_colorPort.LocalValue( dataCollector.PortCategory ); - - //string remapPortR = ".r"; - //string remapPortG = ".g"; - //string remapPortB = ".b"; - //string remapPortA = ".a"; - - //if ( vtex.Channel == VirtualChannel.Occlusion ) - //{ - // remapPortR = ".r"; remapPortG = ".r"; remapPortB = ".r"; remapPortA = ".r"; - //} - //else if ( vtex.Channel == VirtualChannel.SpecMet && ( ContainerGraph.CurrentStandardSurface != null && ContainerGraph.CurrentStandardSurface.CurrentLightingModel == StandardShaderLightModel.Standard ) ) - //{ - // remapPortR = ".r"; remapPortG = ".r"; remapPortB = ".r"; - //} - //else if ( vtex.Channel == VirtualChannel.Height || vtex.Channel == VirtualChannel.Displacement ) - //{ - // remapPortR = ".b"; remapPortG = ".b"; remapPortB = ".b"; remapPortA = ".b"; - //} - - dataCollector.AddToPragmas( UniqueId, IOUtils.VirtualTexturePragmaHeader ); - dataCollector.AddToIncludes( UniqueId, atPathname ); - - string lodBias = string.Empty; - if( dataCollector.IsFragmentCategory ) - { - lodBias = m_mipMode == MipType.MipLevel ? "Lod" : m_mipMode == MipType.MipBias ? "Bias" : ""; - } - else - { - lodBias = "Lod"; - } - - int virtualCoordId = dataCollector.GetVirtualCoordinatesId( UniqueId, GetVirtualUVCoords( ref dataCollector, ignoreLocalVar, portProperty ), lodBias ); - string virtualSampler = SampleVirtualTexture( vtex, Constants.VirtualCoordNameStr + virtualCoordId ); - string virtualVariable = dataCollector.AddVirtualLocalVariable( UniqueId, "virtualNode" + OutputId, virtualSampler ); - - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, virtualVariable, virtualSampler ); - - AddNormalMapTag( ref virtualVariable ); - - switch( vtex.Channel ) - { - default: - case VirtualChannel.Albedo: - case VirtualChannel.Base: - case VirtualChannel.Normal: - case VirtualChannel.Specular: - case VirtualChannel.SpecMet: - case VirtualChannel.Material: - virtualVariable = GetOutputColorItem( 0, outputId, virtualVariable ); - break; - case VirtualChannel.Displacement: - case VirtualChannel.Height: - { - if( outputId > 0 ) - virtualVariable += ".b"; - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "virtual_cast_" + OutputId, virtualVariable + ".b" ); - virtualVariable = "virtual_cast_" + OutputId; - } - //virtualVariable = UIUtils.CastPortType( dataCollector.PortCategory, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), virtualVariable, WirePortDataType.FLOAT, WirePortDataType.FLOAT4, virtualVariable ); - } - break; - case VirtualChannel.Occlusion: - { - if( outputId > 0 ) - virtualVariable += ".r"; - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "virtual_cast_" + OutputId, virtualVariable + ".r" ); - virtualVariable = "virtual_cast_" + OutputId; - } - } - break; - } - - //for ( int i = 0; i < m_outputPorts.Count; i++ ) - //{ - // if ( m_outputPorts[ i ].IsConnected ) - // { - - // //TODO: make the sampler not generate local variables at all times - // m_textureFetchedValue = "virtualNode" + OutputId; - // m_isTextureFetched = true; - - // //dataCollector.AddToLocalVariables( m_uniqueId, m_precisionString + " " + m_textureFetchedValue + " = " + virtualSampler + ";" ); - // if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - // dataCollector.AddToVertexLocalVariables( UniqueId, m_precisionString + " " + m_textureFetchedValue + " = " + virtualSampler + ";" ); - // else - // dataCollector.AddToLocalVariables( UniqueId, m_precisionString + " " + m_textureFetchedValue + " = " + virtualSampler + ";" ); - - // m_colorPort.SetLocalValue( m_textureFetchedValue ); - // m_outputPorts[ m_colorPort.PortId + 1 ].SetLocalValue( m_textureFetchedValue + remapPortR ); - // m_outputPorts[ m_colorPort.PortId + 2 ].SetLocalValue( m_textureFetchedValue + remapPortG ); - // m_outputPorts[ m_colorPort.PortId + 3 ].SetLocalValue( m_textureFetchedValue + remapPortB ); - // m_outputPorts[ m_colorPort.PortId + 4 ].SetLocalValue( m_textureFetchedValue + remapPortA ); - // return m_textureFetchedValue; - // } - //} - - return virtualVariable; - } - } - } - - if( m_colorPort.IsLocalValue( dataCollector.PortCategory ) ) - return m_colorPort.LocalValue( dataCollector.PortCategory ); - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - currMipMode = MipType.MipLevel; - //mipType = "lod"; - } - - string samplerOp = SampleTexture( ref dataCollector, ignoreLocalVar, portProperty, currMipMode, propertyName ); - //string samplerOp = string.Empty; - //uvCoords = GetUVCoords( ref dataCollector, ignoreLocalVar, portProperty ); - //useMacros = m_containerGraph.SamplingThroughMacros && !mipType.Equals( "bias" ) && Constants.TexSampleStandardMacros.ContainsKey( m_currentType ); - //if( useMacros ) - //{ - // bool addLodPrefix = mipType.Equals( "lod" ); - // samplerOp = string.Format( Constants.TexSampleStandardMacros[ m_currentType ], addLodPrefix ? Constants.TexSampleLODPrefix : string.Empty, propertyName, uvCoords ); - //} - //else - //{ - // samplerOp = m_samplerType + mipType + "( " + propertyName + ", " + uvCoords + " )"; - //} - - AddNormalMapTag( ref samplerOp ); - - int connectedPorts = 0; - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - connectedPorts += 1; - if( connectedPorts > 1 || m_outputPorts[ i ].ConnectionCount > 1 ) - { - // Create common local var and mark as fetched - string textureFetchedValue = m_samplerType + "Node" + OutputId; - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - dataCollector.AddToVertexLocalVariables( UniqueId, m_precisionString + " " + textureFetchedValue + " = " + samplerOp + ";" ); - else - dataCollector.AddToLocalVariables( UniqueId, m_precisionString + " " + textureFetchedValue + " = " + samplerOp + ";" ); - - - m_colorPort.SetLocalValue( textureFetchedValue, dataCollector.PortCategory ); - m_outputPorts[ m_colorPort.PortId + 1 ].SetLocalValue( textureFetchedValue + ".r", dataCollector.PortCategory ); - m_outputPorts[ m_colorPort.PortId + 2 ].SetLocalValue( textureFetchedValue + ".g", dataCollector.PortCategory ); - m_outputPorts[ m_colorPort.PortId + 3 ].SetLocalValue( textureFetchedValue + ".b", dataCollector.PortCategory ); - m_outputPorts[ m_colorPort.PortId + 4 ].SetLocalValue( textureFetchedValue + ".a", dataCollector.PortCategory ); - return textureFetchedValue; - } - } - } - return samplerOp; - } - - private void AddNormalMapTag( ref string value ) - { - if( m_autoUnpackNormals ) - { - value = string.Format( m_normalMapUnpackMode, value ); - } - } - - public override void ReadOutputDataFromString( ref string[] nodeParams ) - { - base.ReadOutputDataFromString( ref nodeParams ); - ConfigureOutputPorts(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string defaultTextureGUID = GetCurrentParam( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( defaultTextureGUID ) ); - string materialTextureGUID = GetCurrentParam( ref nodeParams ); - m_materialValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( materialTextureGUID ) ); - } - else - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( defaultTextureGUID ); - } - m_useSemantics = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_textureCoordSet = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_isNormalMap = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_defaultTextureValue = (TexturePropertyValues)Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_autocastMode = (AutoCastType)Enum.Parse( typeof( AutoCastType ), GetCurrentParam( ref nodeParams ) ); - m_autoUnpackNormals = Convert.ToBoolean( GetCurrentParam( 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.UnregisterSamplerNode( this ); - UIUtils.UnregisterPropertyNode( this ); - } - UpdateHeaderColor(); - } - if( UIUtils.CurrentShaderVersion() > 2406 ) - m_mipMode = (MipType)Enum.Parse( typeof( MipType ), GetCurrentParam( ref nodeParams ) ); - - - if( UIUtils.CurrentShaderVersion() > 3201 ) - m_currentType = (TextureType)Enum.Parse( typeof( TextureType ), GetCurrentParam( ref nodeParams ) ); - - if( m_defaultValue == null ) - { - ConfigureInputPorts(); - ConfigureOutputPorts(); - //ResizeNodeToPreview(); - } - else - { - if( m_materialValue == null ) - { - ConfigFromObject( m_defaultValue, false, false ); - } - else - { - CheckTextureImporter( false, false ); - } - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - - if( !m_isNodeBeingCopied && m_referenceType == TexReferenceType.Object ) - { - ContainerGraph.SamplerNodes.UpdateDataOnNode( UniqueId, DataToArray ); - } - } - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - ForceInputPortsChange(); - - if( m_useSamplerArrayIdx > -1 ) - { - m_useSamplerArrayIdx = UIUtils.GetTexturePropertyNodeRegisterId( m_useSamplerArrayIdx ) + 1; - } - else - { - m_useSamplerArrayIdx = 0; - } - - EditorGUI.BeginChangeCheck(); - if( m_referenceType == TexReferenceType.Instance ) - { - if( UIUtils.CurrentShaderVersion() > 22 ) - { - - - m_referenceSampler = ContainerGraph.GetNode( m_referenceNodeId ) as SamplerNode; - m_referenceArrayId = ContainerGraph.SamplerNodes.GetNodeRegisterIdx( m_referenceNodeId ); - } - else - { - m_referenceSampler = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - if( m_referenceSampler != null ) - { - m_referenceNodeId = m_referenceSampler.UniqueId; - } - } - } - - if( EditorGUI.EndChangeCheck() ) - { - OnPropertyNameChanged(); - } - } - - public override void ReadAdditionalData( ref string[] nodeParams ) { } - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_defaultValue ) ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_materialValue ) ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_useSemantics.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordSet.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_isNormalMap.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autocastMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoUnpackNormals ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_referenceType ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( ( m_referenceSampler != null ) ? m_referenceSampler.UniqueId : -1 ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_mipMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentType ); - } - - public override void WriteAdditionalToString( ref string nodeInfo, ref string connectionsInfo ) { } - - public string GetVirtualUVCoords( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, string portProperty ) - { - string bias = ""; - if( !dataCollector.IsFragmentCategory || m_mipMode == MipType.MipBias || m_mipMode == MipType.MipLevel ) - { - string lodLevel = m_lodPort.GeneratePortInstructions( ref dataCollector ); - bias += ", " + lodLevel; - } - - if( m_uvPort.IsConnected ) - { - string uvs = m_uvPort.GeneratePortInstructions( ref dataCollector ); - return uvs + bias; - } - else - { - string propertyName = CurrentPropertyReference; - if( !string.IsNullOrEmpty( portProperty ) ) - { - propertyName = portProperty; - } - string uvChannelName = IOUtils.GetUVChannelName( propertyName, m_textureCoordSet ); - - - string uvCoord = string.Empty; - if( dataCollector.IsTemplate ) - { - string uvName = string.Empty; - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordSet ) ) - { - uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordSet, m_uvPort.DataType ); - } - else - { - uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordSet, m_uvPort.DataType ); - } - - string attr = GetPropertyValue(); - - if( attr.IndexOf( "[NoScaleOffset]" ) > -1 ) - { - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, uvName ); - } - else - { - dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, uvName + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); - } - uvCoord = uvChannelName; - } - else - { - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - uvCoord = Constants.VertexShaderInputStr + ".texcoord"; - if( m_textureCoordSet > 0 ) - { - uvCoord += m_textureCoordSet.ToString(); - } - } - else - { - propertyName = CurrentPropertyReference; - if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) - { - propertyName = portProperty; - } - uvChannelName = IOUtils.GetUVChannelName( propertyName, m_textureCoordSet ); - - string dummyPropUV = "_texcoord" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ); - string dummyUV = "uv" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ) + dummyPropUV; - - dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 ); - dataCollector.AddToInput( UniqueId, dummyUV, WirePortDataType.FLOAT2 ); - - string attr = GetPropertyValue(); - - if( attr.IndexOf( "[NoScaleOffset]" ) > -1 ) - { - dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, Constants.InputVarStr + "." + dummyUV ); - } - else - { - dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); - } - uvCoord = uvChannelName; - } - } - return uvCoord + bias; - } - } - - public string GetUVCoords( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, string portProperty ) - { - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - - // make sure the final result is always a float4 with empty 0's in the middle - string uvAppendix = ", "; - int coordSize = 3; - if( m_uvPort.DataType == WirePortDataType.FLOAT2 ) - { - uvAppendix = ", 0, "; - coordSize = 2; - } - else if( m_uvPort.DataType == WirePortDataType.FLOAT ) - { - uvAppendix = ", 0, 0, "; - coordSize = 1; - } - - string uvs = m_uvPort.GeneratePortInstructions( ref dataCollector ); - - // generate automatic UVs if not connected - if( !m_uvPort.IsConnected ) - { - string propertyName = CurrentPropertyReference; - - // check for references - if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) - propertyName = portProperty; - - int coordSet = ( ( m_textureCoordSet < 0 ) ? 0 : m_textureCoordSet ); - string uvName = IOUtils.GetUVChannelName( propertyName, coordSet ); - string dummyPropUV = "_tex" + ( coordSize != 2 ? "" + coordSize : "" ) + "coord" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" ); - string dummyUV = "uv" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" ) + dummyPropUV; - - string attr = GetPropertyValue(); - bool scaleOffset = true; - if( attr.IndexOf( "[NoScaleOffset]" ) > -1 ) - scaleOffset = false; - - string texCoordsST = string.Empty; - if( scaleOffset ) - { - if( m_texCoordsHelper == null ) - { - m_texCoordsHelper = CreateInstance<Vector4Node>(); - m_texCoordsHelper.ContainerGraph = ContainerGraph; - m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ); - m_texCoordsHelper.RegisterPropertyOnInstancing = false; - m_texCoordsHelper.AddGlobalToSRPBatcher = true; - } - - if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader ) - { - m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty; - } - else - { - m_texCoordsHelper.CurrentParameterType = PropertyType.Global; - } - m_texCoordsHelper.ResetOutputLocals(); - m_texCoordsHelper.SetRawPropertyName( propertyName + "_ST" ); - texCoordsST = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ); - } - - string coordInput = string.Empty; - if( !dataCollector.IsTemplate && coordSet > 3 ) - { - coordInput = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, coordSet, null, WirePortDataType.FLOAT2 ); - } - else - { - dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 9999 ); - if( isVertex ) - { - coordInput = Constants.VertexShaderInputStr + ".texcoord"; - if( coordSet > 0 ) - coordInput += coordSet.ToString(); - } - else - { - coordInput = Constants.InputVarStr + "." + dummyUV; - dataCollector.AddToInput( UniqueId, dummyUV, m_uvPort.DataType ); - } - } - - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordSet ) ) - coordInput = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordSet, m_uvPort.DataType ); - else - coordInput = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordSet, m_uvPort.DataType ); - } - - if( !scaleOffset ) - uvName += OutputId; - - if( coordSize > 2 ) - { - uvName += coordSize; - dataCollector.UsingHigherSizeTexcoords = true; - dataCollector.AddLocalVariable( UniqueId, "float" + coordSize + " " + uvName + " = " + coordInput + ";" ); - if( scaleOffset ) - dataCollector.AddLocalVariable( UniqueId, uvName + ".xy = " + coordInput + ".xy * " + texCoordsST + ".xy + " + texCoordsST + ".zw;" ); - } - else - { - if( coordSize == 1 ) - uvName += coordSize; - - if( scaleOffset ) - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, m_uvPort.DataType, uvName, coordInput + " * " + texCoordsST + ".xy + " + texCoordsST + ".zw" ); - else - dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, m_uvPort.DataType, uvName, coordInput ); - } - - uvs = uvName; - } - - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( isVertex ) - { - string lodLevel = m_lodPort.GeneratePortInstructions( ref dataCollector ); - if( outsideGraph.SamplingThroughMacros ) - return uvs + "," + lodLevel; - else - return UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT4 ) + "( " + uvs + uvAppendix + lodLevel + ")"; - } - else - { - if( ( m_mipMode == MipType.MipLevel || m_mipMode == MipType.MipBias ) && m_lodPort.IsConnected ) - { - string lodLevel = m_lodPort.GeneratePortInstructions( ref dataCollector ); - if( outsideGraph.SamplingThroughMacros ) - return uvs + "," + lodLevel; - else - return UIUtils.PrecisionWirePortToCgType( PrecisionType.Float, WirePortDataType.FLOAT4 ) + "( " + uvs + uvAppendix + lodLevel + ")"; - } - else if( m_mipMode == MipType.Derivative ) - { - string ddx = m_ddxPort.GeneratePortInstructions( ref dataCollector ); - string ddy = m_ddyPort.GeneratePortInstructions( ref dataCollector ); - - return uvs + ", " + ddx + ", " + ddy; - } - else - { - return uvs; - } - } - } - - - - public override int VersionConvertInputPortId( int portId ) - { - int newPort = portId; - //change normal scale port to last - if( UIUtils.CurrentShaderVersion() < 2407 ) - { - if( portId == 1 ) - newPort = 4; - } - - if( UIUtils.CurrentShaderVersion() < 2408 ) - { - newPort = newPort + 1; - } - - return newPort; - } - - public override void Destroy() - { - base.Destroy(); - - //Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff - if( m_texCoordsHelper != null ) - { - DestroyImmediate( m_texCoordsHelper ); - m_texCoordsHelper = null; - } - - m_samplerStateAutoGenerator.Destroy(); - m_samplerStateAutoGenerator = null; - m_defaultValue = null; - m_materialValue = null; - m_referenceSampler = null; - m_referenceStyle = null; - m_referenceContent = null; - m_texPort = null; - m_uvPort = null; - m_lodPort = null; - m_ddxPort = null; - m_ddyPort = null; - m_normalPort = null; - m_colorPort = null; - - if( m_referenceType == TexReferenceType.Object ) - { - UIUtils.UnregisterSamplerNode( this ); - UIUtils.UnregisterPropertyNode( this ); - } - if( UniqueId > -1 ) - ContainerGraph.SamplerNodes.OnReorderEventComplete -= OnReorderEventComplete; - } - - public override string GetPropertyValStr() - { - return m_materialMode ? ( m_materialValue != null ? m_materialValue.name : IOUtils.NO_TEXTURES ) : ( m_defaultValue != null ? m_defaultValue.name : IOUtils.NO_TEXTURES ); - } - - public TexturePropertyNode TextureProperty - { - get - { - if( m_referenceSampler != null ) - { - m_textureProperty = m_referenceSampler as TexturePropertyNode; - } - else if( m_texPort.IsConnected ) - { - m_textureProperty = m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode; - } - - if( m_textureProperty == null ) - return this; - - return m_textureProperty; - } - } - - public override string GetPropertyValue() - { - if( SoftValidReference ) - { - if( m_referenceSampler.TexPort.IsConnected ) - { - return string.Empty; - } - else - { - return m_referenceSampler.TextureProperty.GetPropertyValue(); - } - } - else - if( m_texPort.IsConnected && ( m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode ) != null ) - { - return TextureProperty.GetPropertyValue(); - } - - switch( m_currentType ) - { - case TextureType.Texture1D: - { - return PropertyAttributes + GetTexture1DPropertyValue(); - } - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - { - return PropertyAttributes + GetTexture2DPropertyValue(); - } - case TextureType.Texture3D: - { - return PropertyAttributes + GetTexture3DPropertyValue(); - } - case TextureType.Cube: - { - return PropertyAttributes + GetCubePropertyValue(); - } - } - return string.Empty; - } - - public override string GetUniformValue() - { - - if( SoftValidReference ) - { - if( m_referenceSampler.TexPort.IsConnected ) - return string.Empty; - else - return m_referenceSampler.TextureProperty.GetUniformValue(); - } - else if( m_texPort.IsConnected && ( m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode ) != null ) - { - return TextureProperty.GetUniformValue(); - } - - return base.GetUniformValue(); - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - if( SoftValidReference ) - { - if( m_referenceSampler.TexPort.IsConnected ) - { - base.GetUniformData( out dataType, out dataName, ref fullValue ); - return false; - } - else - return m_referenceSampler.TextureProperty.GetUniformData( out dataType, out dataName, ref fullValue ); - } - else if( m_texPort.IsConnected && ( m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode ) != null ) - { - return TextureProperty.GetUniformData( out dataType, out dataName, ref fullValue ); - - } - - return base.GetUniformData( out dataType, out dataName, ref fullValue ); - } - - public string UVCoordsName { get { return Constants.InputVarStr + "." + IOUtils.GetUVChannelName( CurrentPropertyReference, m_textureCoordSet ); } } - public bool HasPropertyReference - { - get - { - if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 ) - { - SamplerNode node = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - if( node != null ) - return true; - } - - if( m_texPort.IsConnected ) - { - return true; - } - - return false; - } - } - - public override string CurrentPropertyReference - { - get - { - string propertyName = string.Empty; - if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 ) - { - SamplerNode node = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - propertyName = ( node != null ) ? node.TextureProperty.PropertyName : PropertyName; - } - else if( m_texPort.IsConnected && ( m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode ) != null ) - { - propertyName = TextureProperty.PropertyName; - } - else - { - propertyName = PropertyName; - } - return propertyName; - } - } - - public bool SoftValidReference - { - get - { - if( m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1 ) - { - m_referenceSampler = ContainerGraph.SamplerNodes.GetNode( m_referenceArrayId ); - - m_texPort.Locked = true; - - if( m_referenceContent == null ) - m_referenceContent = new GUIContent(); - - - if( m_referenceSampler != null ) - { - m_referenceContent.image = m_referenceSampler.Value; - if( m_referenceWidth != m_referenceSampler.Position.width ) - { - m_referenceWidth = m_referenceSampler.Position.width; - m_sizeIsDirty = true; - } - } - else - { - m_referenceArrayId = -1; - m_referenceWidth = -1; - } - - return m_referenceSampler != null; - } - m_texPort.Locked = false; - return false; - } - } - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( PropertyName ) ) - { - m_materialValue = material.GetTexture( PropertyName ); - CheckTextureImporter( true ); - PreviewIsDirty = true; - } - - } - public override void SetContainerGraph( ParentGraph newgraph ) - { - base.SetContainerGraph( newgraph ); - m_textureProperty = m_texPort.GetOutputNodeWhichIsNotRelay( 0 ) as TexturePropertyNode; - if( m_textureProperty == null ) - { - m_textureProperty = this; - } - } - - public bool AutoUnpackNormals - { - get { return m_autoUnpackNormals; } - set - { - if( value != m_autoUnpackNormals ) - { - m_autoUnpackNormals = value; - if( !UIUtils.IsLoading ) - { - m_defaultTextureValue = value ? TexturePropertyValues.bump : TexturePropertyValues.white; - } - } - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( dataCollector.IsTemplate ) - { - if( !m_texPort.IsConnected ) - dataCollector.TemplateDataCollectorInstance.SetUVUsage( m_textureCoordSet, m_uvPort.DataType ); - } - else if( m_textureCoordSet > 3 ) - { - dataCollector.AddCustomAppData( string.Format( TemplateHelperFunctions.TexUVFullSemantic, m_textureCoordSet ) ); - } - } - - private InputPort TexPort { get { return m_texPort; } } - public bool IsObject { get { return ( m_referenceType == TexReferenceType.Object ) || ( m_referenceSampler == null ); } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs.meta deleted file mode 100644 index 87957e47..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SamplerNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 057d23b232d9c044cbf3f1d0b1a06909 -timeCreated: 1481126953 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs deleted file mode 100644 index cc93bf0e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs +++ /dev/null @@ -1,1330 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; -#if !UNITY_2018_1_OR_NEWER -namespace AmplifyShaderEditor -{ - // Disabling Substance Deprecated warning -#pragma warning disable 0618 - [Serializable] - [NodeAttributes( "Substance Sample", "Textures", "Samples a procedural material", KeyCode.None, true, 0, int.MaxValue, typeof( SubstanceArchive ), typeof( ProceduralMaterial ) )] - public sealed class SubstanceSamplerNode : PropertyNode - { - private const string GlobalVarDecStr = "uniform sampler2D {0};"; - private const string PropertyDecStr = "{0}(\"{0}\", 2D) = \"white\""; - - private const string AutoNormalStr = "Auto-Normal"; - private const string SubstanceStr = "Substance"; - - private float TexturePreviewSizeX = 128; - private float TexturePreviewSizeY = 128; - - private float PickerPreviewWidthAdjust = 18; - - private bool m_editing; - - private CacheNodeConnections m_cacheNodeConnections; - - [SerializeField] - private int m_firstOutputConnected = 0; - - [SerializeField] - private ProceduralMaterial m_proceduralMaterial; - - [SerializeField] - private int m_textureCoordSet = 0; - - [SerializeField] - private ProceduralOutputType[] m_textureTypes; - - [SerializeField] - private bool m_autoNormal = true; - - private System.Type m_type; - - private Texture[] m_textures = new Texture[] { }; - - private List<int> m_outputConns = new List<int>(); - - private Rect m_previewArea; - - private Rect m_pickerArea; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddOutputPort( WirePortDataType.COLOR, Constants.EmptyPortValue ); - m_insideSize.Set( TexturePreviewSizeX + PickerPreviewWidthAdjust, TexturePreviewSizeY + 10 ); - m_type = typeof( ProceduralMaterial ); - m_currentParameterType = PropertyType.Property; - m_freeType = false; - m_freeName = false; - m_autoWrapProperties = true; - m_customPrefix = "Substance Sample "; - m_drawPrecisionUI = false; - m_showPreview = true; - m_drawPreviewExpander = false; - m_selectedLocation = PreviewLocation.TopCenter; - m_cacheNodeConnections = new CacheNodeConnections(); - m_previewShaderGUID = "6f322c1da33f1e744941aafcb0ad1a2d"; - m_showAutoRegisterUI = false; - } - - public override void RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - SetPreviewInputs(); - - PreviewMaterial.SetInt( "_CustomUVs", m_inputPorts[ 0 ].IsConnected ? 1 : 0 ); - - if( m_proceduralMaterial == null ) - return; - - Texture[] texs = m_proceduralMaterial.GetGeneratedTextures(); - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - RenderTexture temp = RenderTexture.active; - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - - PreviewMaterial.SetTexture( "_GenTex", texs[ i ] ); - - if( m_autoNormal && m_textureTypes[ i ] == ProceduralOutputType.Normal ) - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, 1 ); - else - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, 0 ); - RenderTexture.active = temp; - } - - PreviewIsDirty = m_continuousPreviewRefresh; - } - - public override void OnOutputPortConnected( int portId, int otherNodeId, int otherPortId ) - { - base.OnOutputPortConnected( portId, otherNodeId, otherPortId ); - m_firstOutputConnected = -1; - } - - public override void OnOutputPortDisconnected( int portId ) - { - base.OnOutputPortDisconnected( portId ); - m_firstOutputConnected = -1; - } - - void CalculateFirstOutputConnected() - { - m_outputConns.Clear(); - int count = m_outputPorts.Count; - bool connectionsAvailable = false; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - connectionsAvailable = true; - } - } - - for( int i = 0; i < count; i++ ) - { - if( connectionsAvailable ) - { - if( m_outputPorts[ i ].IsConnected ) - { - if( m_firstOutputConnected < 0 ) - m_firstOutputConnected = i; - - m_outputConns.Add( i ); - } - } - else - { - m_outputConns.Add( i ); - } - } - - if( m_firstOutputConnected < 0 ) - m_firstOutputConnected = 0; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_previewArea = m_remainingBox; - m_previewArea.width = TexturePreviewSizeX * drawInfo.InvertedZoom; - m_previewArea.height = TexturePreviewSizeY * drawInfo.InvertedZoom; - m_previewArea.x += 0.5f * m_remainingBox.width - 0.5f * m_previewArea.width; - m_pickerArea = m_previewArea; - m_pickerArea.width = 40 * drawInfo.InvertedZoom; - m_pickerArea.x = m_previewArea.xMax - m_pickerArea.width - 2; - m_pickerArea.height = 14 * drawInfo.InvertedZoom; - m_pickerArea.y = m_previewArea.yMax - m_pickerArea.height - 2; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( !( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp || drawInfo.CurrentEventType == EventType.ExecuteCommand || drawInfo.CurrentEventType == EventType.DragPerform ) ) - return; - - bool insideBox = m_previewArea.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - m_editing = true; - } - else if( m_editing && !insideBox && drawInfo.CurrentEventType != EventType.ExecuteCommand ) - { - GUI.FocusControl( null ); - m_editing = false; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_editing ) - { - m_textures = m_proceduralMaterial != null ? m_proceduralMaterial.GetGeneratedTextures() : null; - if( GUI.Button( m_pickerArea, string.Empty, GUIStyle.none ) ) - { - int controlID = EditorGUIUtility.GetControlID( FocusType.Passive ); - EditorGUIUtility.ShowObjectPicker<ProceduralMaterial>( m_proceduralMaterial, false, "", controlID ); - } - - string commandName = Event.current.commandName; - UnityEngine.Object newValue = null; - if( commandName == "ObjectSelectorUpdated" ) - { - newValue = EditorGUIUtility.GetObjectPickerObject(); - if( newValue != (UnityEngine.Object)m_proceduralMaterial ) - { - PreviewIsDirty = true; - UndoRecordObject( "Changing value EditorGUIObjectField on node Substance Sample" ); - - m_proceduralMaterial = newValue != null ? (ProceduralMaterial)newValue : null; - m_textures = m_proceduralMaterial != null ? m_proceduralMaterial.GetGeneratedTextures() : null; - OnNewSubstanceSelected( m_textures ); - } - } - else if( commandName == "ObjectSelectorClosed" ) - { - newValue = EditorGUIUtility.GetObjectPickerObject(); - if( newValue != (UnityEngine.Object)m_proceduralMaterial ) - { - PreviewIsDirty = true; - UndoRecordObject( "Changing value EditorGUIObjectField on node Substance Sample" ); - - m_proceduralMaterial = newValue != null ? (ProceduralMaterial)newValue : null; - m_textures = m_proceduralMaterial != null ? m_proceduralMaterial.GetGeneratedTextures() : null; - OnNewSubstanceSelected( m_textures ); - } - m_editing = false; - } - - if( GUI.Button( m_previewArea, string.Empty, GUIStyle.none ) ) - { - if( m_proceduralMaterial != null ) - { - Selection.activeObject = m_proceduralMaterial; - EditorGUIUtility.PingObject( Selection.activeObject ); - } - m_editing = false; - } - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( !m_editing ) - m_textures = m_proceduralMaterial != null ? m_proceduralMaterial.GetGeneratedTextures() : null; - - if( m_textures != null ) - { - if( m_firstOutputConnected < 0 ) - { - CalculateFirstOutputConnected(); - } - else if( m_textures.Length != m_textureTypes.Length ) - { - OnNewSubstanceSelected( m_textures ); - } - - int texCount = m_outputConns.Count; - Rect individuals = m_previewArea; - individuals.height /= texCount; - - for( int i = 0; i < texCount; i++ ) - { - EditorGUI.DrawPreviewTexture( individuals, m_textures[ m_outputConns[ i ] ], null, ScaleMode.ScaleAndCrop ); - individuals.y += individuals.height; - } - } - else - { - GUI.Label( m_previewArea, string.Empty, UIUtils.ObjectFieldThumb ); - } - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - Rect smallButton = m_previewArea; - smallButton.height = 14 * drawInfo.InvertedZoom; - smallButton.y = m_previewArea.yMax - smallButton.height - 2; - smallButton.width = 40 * drawInfo.InvertedZoom; - smallButton.x = m_previewArea.xMax - smallButton.width - 2; - if( m_textures == null ) - { - GUI.Label( m_previewArea, "None (Procedural Material)", UIUtils.ObjectFieldThumbOverlay ); - } - GUI.Label( m_pickerArea, "Select", UIUtils.GetCustomStyle( CustomStyle.SamplerButton ) ); - } - - GUI.Label( m_previewArea, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - } - - void OnNewSubstanceSelected( Texture[] textures ) - { - CacheCurrentSettings(); - ConfigPortsFromMaterial( true, textures ); - ConnectFromCache(); - m_requireMaterialUpdate = true; - CalculateFirstOutputConnected(); - ContainerGraph.ParentWindow.RequestRepaint(); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_proceduralMaterial = EditorGUILayoutObjectField( SubstanceStr, m_proceduralMaterial, m_type, false ) as ProceduralMaterial; - if( EditorGUI.EndChangeCheck() ) - { - Texture[] textures = m_proceduralMaterial != null ? m_proceduralMaterial.GetGeneratedTextures() : null; - if( textures != null ) - { - OnNewSubstanceSelected( textures ); - } - } - - m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ); - EditorGUI.BeginChangeCheck(); - m_autoNormal = EditorGUILayoutToggle( AutoNormalStr, m_autoNormal ); - if( EditorGUI.EndChangeCheck() ) - { - for( int i = 0; i < m_textureTypes.Length; i++ ) - { - WirePortDataType portType = ( m_autoNormal && m_textureTypes[ i ] == ProceduralOutputType.Normal ) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR; - if( m_outputPorts[ i ].DataType != portType ) - { - m_outputPorts[ i ].ChangeType( portType, false ); - } - } - } - } - - private void CacheCurrentSettings() - { - m_cacheNodeConnections.Clear(); - for( int portId = 0; portId < m_outputPorts.Count; portId++ ) - { - if( m_outputPorts[ portId ].IsConnected ) - { - int connCount = m_outputPorts[ portId ].ConnectionCount; - for( int connIdx = 0; connIdx < connCount; connIdx++ ) - { - WireReference connection = m_outputPorts[ portId ].GetConnection( connIdx ); - m_cacheNodeConnections.Add( m_outputPorts[ portId ].Name, new NodeCache( connection.NodeId, connection.PortId ) ); - } - } - } - } - - private void ConnectFromCache() - { - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - List<NodeCache> connections = m_cacheNodeConnections.GetList( m_outputPorts[ i ].Name ); - if( connections != null ) - { - int count = connections.Count; - for( int connIdx = 0; connIdx < count; connIdx++ ) - { - UIUtils.SetConnection( connections[ connIdx ].TargetNodeId, connections[ connIdx ].TargetPortId, UniqueId, i ); - } - } - } - } - - - private void ConfigPortsFromMaterial( bool invalidateConnections = false, Texture[] newTextures = null ) - { - SetAdditonalTitleText( ( m_proceduralMaterial != null ) ? string.Format( Constants.PropertyValueLabel, m_proceduralMaterial.name ) : "Value( <None> )" ); - - Texture[] textures = newTextures != null ? newTextures : ( ( m_proceduralMaterial != null ) ? m_proceduralMaterial.GetGeneratedTextures() : null ); - if( textures != null ) - { - m_firstOutputConnected = -1; - string nameToRemove = m_proceduralMaterial.name + "_"; - m_textureTypes = new ProceduralOutputType[ textures.Length ]; - for( int i = 0; i < textures.Length; i++ ) - { - ProceduralTexture procTex = textures[ i ] as ProceduralTexture; - m_textureTypes[ i ] = procTex.GetProceduralOutputType(); - - WirePortDataType portType = ( m_autoNormal && m_textureTypes[ i ] == ProceduralOutputType.Normal ) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR; - string newName = textures[ i ].name.Replace( nameToRemove, string.Empty ); - char firstLetter = Char.ToUpper( newName[ 0 ] ); - newName = firstLetter.ToString() + newName.Substring( 1 ); - if( i < m_outputPorts.Count ) - { - m_outputPorts[ i ].ChangeProperties( newName, portType, false ); - if( invalidateConnections ) - { - m_outputPorts[ i ].FullDeleteConnections(); - } - } - else - { - AddOutputPort( portType, newName ); - } - } - - if( textures.Length < m_outputPorts.Count ) - { - int itemsToRemove = m_outputPorts.Count - textures.Length; - for( int i = 0; i < itemsToRemove; i++ ) - { - int idx = m_outputPorts.Count - 1; - if( m_outputPorts[ idx ].IsConnected ) - { - m_outputPorts[ idx ].ForceClearConnection(); - } - RemoveOutputPort( idx ); - } - } - } - else - { - int itemsToRemove = m_outputPorts.Count - 1; - m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.COLOR, false ); - m_outputPorts[ 0 ].ForceClearConnection(); - - for( int i = 0; i < itemsToRemove; i++ ) - { - int idx = m_outputPorts.Count - 1; - if( m_outputPorts[ idx ].IsConnected ) - { - m_outputPorts[ idx ].ForceClearConnection(); - } - RemoveOutputPort( idx ); - } - } - - m_sizeIsDirty = true; - m_isDirty = true; - } - - private void ConfigFromObject( UnityEngine.Object obj ) - { - ProceduralMaterial newMat = AssetDatabase.LoadAssetAtPath<ProceduralMaterial>( AssetDatabase.GetAssetPath( obj ) ); - if( newMat != null ) - { - m_proceduralMaterial = newMat; - ConfigPortsFromMaterial(); - } - } - - public override void OnObjectDropped( UnityEngine.Object obj ) - { - ConfigFromObject( obj ); - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - ConfigFromObject( obj ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_proceduralMaterial == null ) - { - return "(0).xxxx"; - } - - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - Texture[] textures = m_proceduralMaterial.GetGeneratedTextures(); - - string uvPropertyName = string.Empty; - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].HasConnectedNode ) - { - uvPropertyName = textures[ i ].name; - break; - } - } - - string name = textures[ outputId ].name + OutputId; - dataCollector.AddToUniforms( UniqueId, string.Format( GlobalVarDecStr, textures[ outputId ].name ) ); - dataCollector.AddToProperties( UniqueId, string.Format( PropertyDecStr, textures[ outputId ].name ) + "{}", -1 ); - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - string value = string.Format( "tex2D{0}({1}, {2})", ( isVertex ? "lod" : string.Empty ), textures[ outputId ].name, GetUVCoords( ref dataCollector, ignoreLocalvar, uvPropertyName ) ); - if( m_autoNormal && m_textureTypes[ outputId ] == ProceduralOutputType.Normal ) - { - value = string.Format( TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector,false,"1.0"), value ); - } - - dataCollector.AddPropertyNode( this ); - RegisterLocalVariable( outputId, value, ref dataCollector, name ); - - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - public string GetUVCoords( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, string propertyName ) - { - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - if( m_inputPorts[ 0 ].IsConnected ) - { - return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, isVertex ? WirePortDataType.FLOAT4 : WirePortDataType.FLOAT2, ignoreLocalVar, true ); - } - else - { - string uvChannelName = IOUtils.GetUVChannelName( propertyName, m_textureCoordSet ); - - if( dataCollector.IsTemplate ) - { - string propertyHelperVar = propertyName + "_ST"; - dataCollector.AddToUniforms( UniqueId, "float4", propertyHelperVar, dataCollector.IsSRP ); - string uvName = string.Empty; - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordSet ) ) - { - uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordSet ); - } - else - { - uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordSet ); - } - - uvChannelName = "uv" + propertyName; - if( isVertex ) - { - string value = string.Format( Constants.TilingOffsetFormat, uvName, propertyHelperVar + ".xy", propertyHelperVar + ".zw" ); - string lodLevel = "0"; - - value = "float4( " + value + ", 0 , " + lodLevel + " )"; - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, uvChannelName, value ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT2, uvChannelName, string.Format( Constants.TilingOffsetFormat, uvName, propertyHelperVar + ".xy", propertyHelperVar + ".zw" ) ); - } - } - else - { - string vertexCoords = Constants.VertexShaderInputStr + ".texcoord"; - if( m_textureCoordSet > 0 ) - { - vertexCoords += m_textureCoordSet.ToString(); - } - - - string dummyPropUV = "_texcoord" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ); - string dummyUV = "uv" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ) + dummyPropUV; - - dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 ); - dataCollector.AddToInput( UniqueId, dummyUV, WirePortDataType.FLOAT2 ); - - if( isVertex ) - { - dataCollector.AddToVertexLocalVariables( UniqueId, "float4 " + uvChannelName + " = float4(" + vertexCoords + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw, 0 ,0);" ); - return uvChannelName; - } - else - dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); - - } - - return uvChannelName; - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( m_proceduralMaterial != null ) - { - Texture[] textures = m_proceduralMaterial.GetGeneratedTextures(); - for( int i = 0; i < textures.Length; i++ ) - { - if( mat.HasProperty( textures[ i ].name ) && !InsideShaderFunction ) - { - mat.SetTexture( textures[ i ].name, textures[ i ] ); - } - } - } - } - - public override bool UpdateShaderDefaults( ref Shader shader, ref TextureDefaultsDataColector defaultCol ) - { - if( m_proceduralMaterial != null ) - { - Texture[] textures = m_proceduralMaterial.GetGeneratedTextures(); - for( int i = 0; i < textures.Length; i++ ) - { - defaultCol.AddValue( textures[ i ].name, textures[ i ] ); - } - } - return true; - } - - public override void Destroy() - { - base.Destroy(); - m_textures = null; - m_proceduralMaterial = null; - m_cacheNodeConnections.Clear(); - m_cacheNodeConnections = null; - m_outputConns.Clear(); - m_outputConns = null; - } - - public override string GetPropertyValStr() - { - return m_proceduralMaterial ? m_proceduralMaterial.name : string.Empty; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string guid = GetCurrentParam( ref nodeParams ); - m_textureCoordSet = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_autoNormal = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( guid.Length > 1 ) - { - m_proceduralMaterial = AssetDatabase.LoadAssetAtPath<ProceduralMaterial>( AssetDatabase.GUIDToAssetPath( guid ) ); - if( m_proceduralMaterial != null ) - { - ConfigPortsFromMaterial(); - } - else - { - UIUtils.ShowMessage( UniqueId, "Substance not found ", MessageSeverity.Error ); - } - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - string guid = ( m_proceduralMaterial != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_proceduralMaterial ) ) : "0"; - IOUtils.AddFieldValueToString( ref nodeInfo, guid ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordSet ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoNormal ); - } - - } -#pragma warning restore 0618 -} -#elif SUBSTANCE_PLUGIN_ENABLED - -using Substance.Game; - -namespace AmplifyShaderEditor -{ - public enum ASEProceduralOutputType - { - Color, - Normal, - } - // Disabling Substance Deprecated warning -#pragma warning disable 0618 - [Serializable] - [NodeAttributes( "Substance Sample", "Textures", "Samples a procedural material", KeyCode.None, true, 0, int.MaxValue, typeof( SubstanceGraph ), typeof( Substance.Game.Substance ) )] - public sealed class SubstanceSamplerNode : PropertyNode - { - private const string NormalMapCheck = "_normal"; - private const string GlobalVarDecStr = "uniform sampler2D {0};"; - private const string PropertyDecStr = "{0}(\"{1}\", 2D) = \"white\""; - - private const string AutoNormalStr = "Auto-Normal"; - private const string SubstanceStr = "Substance"; - - private float TexturePreviewSizeX = 128; - private float TexturePreviewSizeY = 128; - - private float PickerPreviewWidthAdjust = 18; - - private bool m_editing; - - private CacheNodeConnections m_cacheNodeConnections; - - [SerializeField] - private int m_firstOutputConnected = 0; - - [SerializeField] - private Substance.Game.SubstanceGraph m_substanceGraph; - [SerializeField] - private string m_substanceGUID = string.Empty; - - [SerializeField] - private int m_textureCoordSet = 0; - - [SerializeField] - private ASEProceduralOutputType[] m_textureTypes; - - [SerializeField] - private bool m_autoNormal = true; - - private System.Type m_type; - - private List<Texture2D> m_textures = new List<Texture2D>(); - - private List<int> m_outputConns = new List<int>(); - - private Rect m_previewArea; - - private Rect m_pickerArea; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddOutputPort( WirePortDataType.COLOR, Constants.EmptyPortValue ); - m_insideSize.Set( TexturePreviewSizeX + PickerPreviewWidthAdjust, TexturePreviewSizeY + 10 ); - m_type = typeof( Substance.Game.Substance ); - m_currentParameterType = PropertyType.Property; - m_freeType = false; - m_freeName = false; - m_autoWrapProperties = true; - m_customPrefix = "Substance Sample "; - m_drawPrecisionUI = false; - m_showPreview = true; - m_drawPreviewExpander = false; - m_selectedLocation = PreviewLocation.TopCenter; - m_cacheNodeConnections = new CacheNodeConnections(); - m_previewShaderGUID = "6f322c1da33f1e744941aafcb0ad1a2d"; - m_showAutoRegisterUI = false; - } - - public override void RenderNodePreview() - { - if( !m_initialized ) - return; - - SetPreviewInputs(); - PreviewMaterial.SetInt( "_CustomUVs", m_inputPorts[ 0 ].IsConnected ? 1 : 0 ); - - if( m_substanceGraph == null ) - return; - - List<Texture2D> texs = m_substanceGraph.generatedTextures; - int count = m_outputPorts.Count; - for( int i = 0; i < count; i++ ) - { - RenderTexture temp = RenderTexture.active; - RenderTexture.active = m_outputPorts[ i ].OutputPreviewTexture; - - PreviewMaterial.SetTexture( "_GenTex", texs[ i ] ); - - if( m_autoNormal && m_textureTypes[ i ] == ASEProceduralOutputType.Normal ) - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, 1 ); - else - Graphics.Blit( null, m_outputPorts[ i ].OutputPreviewTexture, PreviewMaterial, 0 ); - RenderTexture.active = temp; - } - } - - public override void OnOutputPortConnected( int portId, int otherNodeId, int otherPortId ) - { - base.OnOutputPortConnected( portId, otherNodeId, otherPortId ); - m_firstOutputConnected = -1; - } - - public override void OnOutputPortDisconnected( int portId ) - { - base.OnOutputPortDisconnected( portId ); - m_firstOutputConnected = -1; - } - - void CalculateFirstOutputConnected() - { - m_outputConns.Clear(); - int count = m_outputPorts.Count; - bool connectionsAvailable = false; - for( int i = 0; i < count; i++ ) - { - if( m_outputPorts[ i ].IsConnected ) - { - connectionsAvailable = true; - } - } - - for( int i = 0; i < count; i++ ) - { - if( connectionsAvailable ) - { - if( m_outputPorts[ i ].IsConnected ) - { - if( m_firstOutputConnected < 0 ) - m_firstOutputConnected = i; - - m_outputConns.Add( i ); - } - } - else - { - m_outputConns.Add( i ); - } - } - - if( m_firstOutputConnected < 0 ) - m_firstOutputConnected = 0; - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - - m_previewArea = m_remainingBox; - m_previewArea.width = TexturePreviewSizeX * drawInfo.InvertedZoom; - m_previewArea.height = TexturePreviewSizeY * drawInfo.InvertedZoom; - m_previewArea.x += 0.5f * m_remainingBox.width - 0.5f * m_previewArea.width; - m_pickerArea = m_previewArea; - m_pickerArea.width = 40 * drawInfo.InvertedZoom; - m_pickerArea.x = m_previewArea.xMax - m_pickerArea.width - 2; - m_pickerArea.height = 14 * drawInfo.InvertedZoom; - m_pickerArea.y = m_previewArea.yMax - m_pickerArea.height - 2; - } - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( !( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp || drawInfo.CurrentEventType == EventType.ExecuteCommand || drawInfo.CurrentEventType == EventType.DragPerform ) ) - return; - - bool insideBox = m_previewArea.Contains( drawInfo.MousePosition ); - - if( insideBox ) - { - m_editing = true; - } - else if( m_editing && !insideBox && drawInfo.CurrentEventType != EventType.ExecuteCommand ) - { - GUI.FocusControl( null ); - m_editing = false; - } - } - - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_editing ) - { - m_textures = m_substanceGraph != null ? m_substanceGraph.generatedTextures : null; - if( GUI.Button( m_pickerArea, string.Empty, GUIStyle.none ) ) - { - int controlID = EditorGUIUtility.GetControlID( FocusType.Passive ); - EditorGUIUtility.ShowObjectPicker<SubstanceGraph>( m_substanceGraph, false, "", controlID ); - } - - string commandName = Event.current.commandName; - UnityEngine.Object newValue = null; - if( commandName == "ObjectSelectorUpdated" ) - { - newValue = EditorGUIUtility.GetObjectPickerObject(); - if( newValue != (UnityEngine.Object)m_substanceGraph ) - { - UndoRecordObject( "Changing value EditorGUIObjectField on node Substance Sample" ); - - SubstanceGraph = newValue != null ? (SubstanceGraph)newValue : null; - m_textures = m_substanceGraph != null ? m_substanceGraph.generatedTextures : null; - OnNewSubstanceSelected( m_textures ); - } - } - else if( commandName == "ObjectSelectorClosed" ) - { - newValue = EditorGUIUtility.GetObjectPickerObject(); - if( newValue != (UnityEngine.Object)m_substanceGraph ) - { - UndoRecordObject( "Changing value EditorGUIObjectField on node Substance Sample" ); - - SubstanceGraph = newValue != null ? (SubstanceGraph)newValue : null; - m_textures = m_substanceGraph != null ? m_substanceGraph.generatedTextures : null; - OnNewSubstanceSelected( m_textures ); - } - m_editing = false; - } - - if( GUI.Button( m_previewArea, string.Empty, GUIStyle.none ) ) - { - if( m_substanceGraph != null ) - { - Selection.activeObject = m_substanceGraph; - EditorGUIUtility.PingObject( Selection.activeObject ); - } - m_editing = false; - } - } - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - if( !m_editing ) - m_textures = m_substanceGraph != null ? m_substanceGraph.generatedTextures : null; - - if( m_textures != null ) - { - if( m_firstOutputConnected < 0 ) - { - CalculateFirstOutputConnected(); - } - else if( m_textures.Count != m_textureTypes.Length ) - { - OnNewSubstanceSelected( m_textures ); - } - - int texCount = m_outputConns.Count; - Rect individuals = m_previewArea; - individuals.height /= texCount; - - for( int i = 0; i < texCount; i++ ) - { - EditorGUI.DrawPreviewTexture( individuals, m_textures[ m_outputConns[ i ] ], null, ScaleMode.ScaleAndCrop ); - individuals.y += individuals.height; - } - } - else - { - GUI.Label( m_previewArea, string.Empty, UIUtils.ObjectFieldThumb ); - } - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - Rect smallButton = m_previewArea; - smallButton.height = 14 * drawInfo.InvertedZoom; - smallButton.y = m_previewArea.yMax - smallButton.height - 2; - smallButton.width = 40 * drawInfo.InvertedZoom; - smallButton.x = m_previewArea.xMax - smallButton.width - 2; - if( m_textures == null ) - { - GUI.Label( m_previewArea, "None (Procedural Material)", UIUtils.ObjectFieldThumbOverlay ); - } - GUI.Label( m_pickerArea, "Select", UIUtils.GetCustomStyle( CustomStyle.SamplerButton ) ); - } - - GUI.Label( m_previewArea, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - } - - void OnNewSubstanceSelected( List<Texture2D> textures ) - { - CacheCurrentSettings(); - ConfigPortsFromMaterial( true, textures ); - ConnectFromCache(); - m_requireMaterialUpdate = true; - CalculateFirstOutputConnected(); - ContainerGraph.ParentWindow.RequestRepaint(); - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - SubstanceGraph = EditorGUILayoutObjectField( SubstanceStr, m_substanceGraph, m_type, false ) as SubstanceGraph; - if( EditorGUI.EndChangeCheck() ) - { - List<Texture2D> textures = m_substanceGraph != null ? m_substanceGraph.generatedTextures : null; - if( textures != null ) - { - OnNewSubstanceSelected( textures ); - } - } - - m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ); - EditorGUI.BeginChangeCheck(); - m_autoNormal = EditorGUILayoutToggle( AutoNormalStr, m_autoNormal ); - if( EditorGUI.EndChangeCheck() ) - { - for( int i = 0; i < m_textureTypes.Length; i++ ) - { - WirePortDataType portType = ( m_autoNormal && m_textureTypes[ i ] == ASEProceduralOutputType.Normal ) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR; - if( m_outputPorts[ i ].DataType != portType ) - { - m_outputPorts[ i ].ChangeType( portType, false ); - } - } - } - } - - private void CacheCurrentSettings() - { - m_cacheNodeConnections.Clear(); - for( int portId = 0; portId < m_outputPorts.Count; portId++ ) - { - if( m_outputPorts[ portId ].IsConnected ) - { - int connCount = m_outputPorts[ portId ].ConnectionCount; - for( int connIdx = 0; connIdx < connCount; connIdx++ ) - { - WireReference connection = m_outputPorts[ portId ].GetConnection( connIdx ); - m_cacheNodeConnections.Add( m_outputPorts[ portId ].Name, new NodeCache( connection.NodeId, connection.PortId ) ); - } - } - } - } - - private void ConnectFromCache() - { - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - List<NodeCache> connections = m_cacheNodeConnections.GetList( m_outputPorts[ i ].Name ); - if( connections != null ) - { - int count = connections.Count; - for( int connIdx = 0; connIdx < count; connIdx++ ) - { - UIUtils.SetConnection( connections[ connIdx ].TargetNodeId, connections[ connIdx ].TargetPortId, UniqueId, i ); - } - } - } - } - - - private void ConfigPortsFromMaterial( bool invalidateConnections = false, List<Texture2D> newTextures = null ) - { - SetAdditonalTitleText( ( m_substanceGraph != null ) ? string.Format( Constants.PropertyValueLabel, m_substanceGraph.name ) : "Value( <None> )" ); - - List<Texture2D> textures = newTextures != null ? newTextures : ( ( m_substanceGraph != null ) ? m_substanceGraph.generatedTextures : null ); - if( textures != null ) - { - m_firstOutputConnected = -1; - string nameToRemove = m_substanceGraph.graphLabel + "_"; - m_textureTypes = new ASEProceduralOutputType[ textures.Count ]; - for( int i = 0; i < textures.Count; i++ ) - { - //TODO: Replace for a more efficient test as soon as Laurent gives more infos - m_textureTypes[ i ] = textures[ i ].name.EndsWith( NormalMapCheck )?ASEProceduralOutputType.Normal:ASEProceduralOutputType.Color; - - WirePortDataType portType = ( m_autoNormal && m_textureTypes[ i ] == ASEProceduralOutputType.Normal ) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR; - string newName = textures[ i ].name.Replace( nameToRemove, string.Empty ); - char firstLetter = Char.ToUpper( newName[ 0 ] ); - newName = firstLetter.ToString() + newName.Substring( 1 ); - if( i < m_outputPorts.Count ) - { - m_outputPorts[ i ].ChangeProperties( newName, portType, false ); - if( invalidateConnections ) - { - m_outputPorts[ i ].FullDeleteConnections(); - } - } - else - { - AddOutputPort( portType, newName ); - } - } - - if( textures.Count < m_outputPorts.Count ) - { - int itemsToRemove = m_outputPorts.Count - textures.Count; - for( int i = 0; i < itemsToRemove; i++ ) - { - int idx = m_outputPorts.Count - 1; - if( m_outputPorts[ idx ].IsConnected ) - { - m_outputPorts[ idx ].ForceClearConnection(); - } - RemoveOutputPort( idx ); - } - } - } - else - { - int itemsToRemove = m_outputPorts.Count - 1; - m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.COLOR, false ); - m_outputPorts[ 0 ].ForceClearConnection(); - - for( int i = 0; i < itemsToRemove; i++ ) - { - int idx = m_outputPorts.Count - 1; - if( m_outputPorts[ idx ].IsConnected ) - { - m_outputPorts[ idx ].ForceClearConnection(); - } - RemoveOutputPort( idx ); - } - } - - m_sizeIsDirty = true; - m_isDirty = true; - } - - private void ConfigFromObject( UnityEngine.Object obj ) - { - SubstanceGraph newGraph = obj as SubstanceGraph;// AssetDatabase.LoadAssetAtPath<SubstanceGraph>( AssetDatabase.GetAssetPath( obj ) ); - if( newGraph != null ) - { - SubstanceGraph = newGraph; - ConfigPortsFromMaterial(); - } - - Substance.Game.Substance newSubstance = obj as Substance.Game.Substance;// AssetDatabase.LoadAssetAtPath<SubstanceGraph>( AssetDatabase.GetAssetPath( obj ) ); - if( newSubstance != null && newSubstance.graphs.Count > 0 ) - { - SubstanceGraph = newSubstance.graphs[0]; - ConfigPortsFromMaterial(); - } - - } - - public override void OnObjectDropped( UnityEngine.Object obj ) - { - ConfigFromObject( obj ); - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - ConfigFromObject( obj ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( m_substanceGraph == null ) - { - return "(0).xxxx"; - } - - if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) ) - { - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - List<Texture2D> textures = m_substanceGraph.generatedTextures; - - string uvPropertyName = string.Empty; - for( int i = 0; i < m_outputPorts.Count; i++ ) - { - if( m_outputPorts[ i ].HasConnectedNode ) - { - uvPropertyName = UIUtils.GeneratePropertyName( textures[ i ].name , PropertyType.Property ); - break; - } - } - - string propertyName = UIUtils.GeneratePropertyName( textures[ outputId ].name, PropertyType.Property ); - string name = propertyName + OutputId; - dataCollector.AddToUniforms( UniqueId, string.Format( GlobalVarDecStr, propertyName ) ); - dataCollector.AddToProperties( UniqueId, string.Format( PropertyDecStr, propertyName, textures[ outputId ].name ) + "{}", -1 ); - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - string value = string.Format( "tex2D{0}({1}, {2})", ( isVertex ? "lod" : string.Empty ), propertyName, GetUVCoords( ref dataCollector, ignoreLocalvar, uvPropertyName ) ); - if( m_autoNormal && m_textureTypes[ outputId ] == ASEProceduralOutputType.Normal ) - { - value = string.Format( TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, false, "1.0" ), value ); - } - - dataCollector.AddPropertyNode( this ); - RegisterLocalVariable( outputId, value, ref dataCollector, name ); - - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - public string GetUVCoords( ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar, string propertyName ) - { - bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - if( m_inputPorts[ 0 ].IsConnected ) - { - return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, isVertex ? WirePortDataType.FLOAT4 : WirePortDataType.FLOAT2, ignoreLocalVar, true ); - } - else - { - string uvChannelName = IOUtils.GetUVChannelName( propertyName, m_textureCoordSet ); - - if( dataCollector.IsTemplate ) - { - string propertyHelperVar = propertyName + "_ST"; - dataCollector.AddToUniforms( UniqueId, "float4", propertyHelperVar, dataCollector.IsSRP ); - string uvName = string.Empty; - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordSet ) ) - { - uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordSet ); - } - else - { - uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordSet ); - } - - uvChannelName = "uv" + propertyName; - if( isVertex ) - { - string value = string.Format( Constants.TilingOffsetFormat, uvName, propertyHelperVar + ".xy", propertyHelperVar + ".zw" ); - string lodLevel = "0"; - - value = "float4( " + value + ", 0 , " + lodLevel + " )"; - dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, uvChannelName, value ); - } - else - { - dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT2, uvChannelName, string.Format( Constants.TilingOffsetFormat, uvName, propertyHelperVar + ".xy", propertyHelperVar + ".zw" ) ); - } - } - else - { - string vertexCoords = Constants.VertexShaderInputStr + ".texcoord"; - if( m_textureCoordSet > 0 ) - { - vertexCoords += m_textureCoordSet.ToString(); - } - - - string dummyPropUV = "_texcoord" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ); - string dummyUV = "uv" + ( m_textureCoordSet > 0 ? ( m_textureCoordSet + 1 ).ToString() : "" ) + dummyPropUV; - - dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 ); - dataCollector.AddToInput( UniqueId, dummyUV, WirePortDataType.FLOAT2 ); - - if( isVertex ) - { - dataCollector.AddToVertexLocalVariables( UniqueId, "float4 " + uvChannelName + " = float4(" + vertexCoords + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw, 0 ,0);" ); - return uvChannelName; - } - else - dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvChannelName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); - - } - - return uvChannelName; - } - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( m_substanceGraph != null ) - { - List<Texture2D> textures = m_substanceGraph.generatedTextures; - for( int i = 0; i < textures.Count; i++ ) - { - string textureName = UIUtils.GeneratePropertyName( textures[ i ].name, PropertyType.Property ); - if( mat.HasProperty( textureName ) && !InsideShaderFunction ) - { - mat.SetTexture( textureName, textures[ i ] ); - } - } - } - } - - public override bool UpdateShaderDefaults( ref Shader shader, ref TextureDefaultsDataColector defaultCol ) - { - if( m_substanceGraph != null ) - { - List<Texture2D> textures = m_substanceGraph.generatedTextures; - for( int i = 0; i < textures.Count; i++ ) - { - defaultCol.AddValue( UIUtils.GeneratePropertyName( textures[ i ].name, PropertyType.Property ), textures[ i ] ); - } - } - return true; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - if( m_substanceGraph == null && !string.IsNullOrEmpty( m_substanceGUID ) ) - { - SubstanceGraph = AssetDatabase.LoadAssetAtPath<SubstanceGraph>( AssetDatabase.GUIDToAssetPath( m_substanceGUID ) ); - if( m_substanceGraph == null ) - { - m_substanceGUID = string.Empty; - } - } - } - - public override void Destroy() - { - base.Destroy(); - m_textures = null; - m_substanceGraph = null; - m_substanceGUID = string.Empty; - m_cacheNodeConnections.Clear(); - m_cacheNodeConnections = null; - m_outputConns.Clear(); - m_outputConns = null; - } - - public override string GetPropertyValStr() - { - return m_substanceGraph ? m_substanceGraph.name : string.Empty; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string guid = GetCurrentParam( ref nodeParams ); - m_textureCoordSet = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_autoNormal = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( guid.Length > 1 ) - { - SubstanceGraph = AssetDatabase.LoadAssetAtPath<SubstanceGraph>( AssetDatabase.GUIDToAssetPath( guid ) ); - if( m_substanceGraph != null ) - { - ConfigPortsFromMaterial(); - } - else - { - UIUtils.ShowMessage( "Substance not found ", MessageSeverity.Error ); - } - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - string guid = ( m_substanceGraph != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_substanceGraph ) ) : "0"; - IOUtils.AddFieldValueToString( ref nodeInfo, guid ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordSet ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autoNormal ); - } - - public SubstanceGraph SubstanceGraph - { - set - { - m_substanceGraph = value; - if( value != null ) - { - m_substanceGUID = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( value ) ); - } - else - { - m_substanceGUID = string.Empty; - } - } - get { return m_substanceGraph; } - } - } -#pragma warning restore 0618 -} -#endif diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs.meta deleted file mode 100644 index 02886b0f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/SubstanceSamplerNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7323b6020278e034b9e4c670cbc61361 -timeCreated: 1486640033 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs deleted file mode 100644 index 3735c3ad..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs +++ /dev/null @@ -1,238 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Flipbook UV Animation -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - - [Serializable] - [NodeAttributes( "Flipbook UV Animation", "UV Coordinates", "Animate a Flipbook Texture Modifying UV Coordinates.", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCFlipBookUVAnimation : ParentNode - - { - - private const string TextureVerticalDirectionStr = "Texture Direction"; - private const string NegativeSpeedBehaviorStr = "If Negative Speed"; - - [SerializeField] - private int m_selectedTextureVerticalDirection = 0; - - [SerializeField] - private int m_negativeSpeedBehavior = 0; - - [SerializeField] - private readonly string[] m_textureVerticalDirectionValues = { "Top To Bottom", "Bottom To Top" }; - - [SerializeField] - private readonly string[] m_negativeSpeedBehaviorValues = { "Switch to Positive", "Reverse Animation" }; - - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, false, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Columns" ); - AddInputPort( WirePortDataType.FLOAT, false, "Rows" ); - AddInputPort( WirePortDataType.FLOAT, false, "Speed" ); - AddInputPort( WirePortDataType.FLOAT, false, "Start Frame" ); - AddInputPort( WirePortDataType.FLOAT, false, "Time" ); - - AddOutputVectorPorts( WirePortDataType.FLOAT2, "UV" ); - m_outputPorts[ 1 ].Name = "U"; - m_outputPorts[ 2 ].Name = "V"; - m_textLabelWidth = 125; - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "04fe24be792bfd5428b92132d7cf0f7d"; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( portId == 5 ) - { - m_previewMaterialPassId = 1; - } - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( portId == 5 ) - { - m_previewMaterialPassId = 0; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.BeginVertical(); - m_selectedTextureVerticalDirection = EditorGUILayoutPopup( TextureVerticalDirectionStr, m_selectedTextureVerticalDirection, m_textureVerticalDirectionValues ); - m_negativeSpeedBehavior = EditorGUILayoutPopup( NegativeSpeedBehaviorStr, m_negativeSpeedBehavior, m_negativeSpeedBehaviorValues ); - EditorGUILayout.EndVertical(); - EditorGUILayout.HelpBox( "Flipbook UV Animation:\n\n - UV: Texture Coordinates to Flipbook.\n - Columns: number of Columns (X) of the Flipbook Texture.\n - Rows: number of Rows (Y) of the Flipbook Textures.\n - Speed: speed of the animation.\n - Texture Direction: set the vertical order of the texture tiles.\n - If Negative Speed: set the behavior when speed is negative.\n\n - Out: UV Coordinates.", MessageType.None ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_selectedTextureVerticalDirection = ( int ) int.Parse( GetCurrentParam( ref nodeParams ) ); - m_negativeSpeedBehavior = ( int ) int.Parse( GetCurrentParam( ref nodeParams ) ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedTextureVerticalDirection ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_negativeSpeedBehavior ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - // OPTIMIZATION NOTES - // - // round( fmod( x, y ) ) can be replaced with a faster - // floor( frac( x / y ) * y + 0.5 ) => div can be muls with 1/y, almost always static/constant - // - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - - string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string columns = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - - if ( !m_inputPorts[ 1 ].IsConnected ) - columns = ( float.Parse( columns ) == 0f ? "1" : columns ); - - string rows = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - if ( !m_inputPorts[ 2 ].IsConnected ) - rows = ( float.Parse( rows ) == 0f ? "1" : rows ); - - string speed = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ); - string startframe = m_inputPorts[ 4 ].GeneratePortInstructions( ref dataCollector ); - string timer = m_inputPorts[ 5 ].IsConnected ? m_inputPorts[ 5 ].GeneratePortInstructions( ref dataCollector ) : "_Time[ 1 ]"; - - string vcomment1 = "// *** BEGIN Flipbook UV Animation vars ***"; - string vcomment2 = "// Total tiles of Flipbook Texture"; - string vtotaltiles = "float fbtotaltiles" + OutputId + " = " + columns + " * " + rows + ";"; - string vcomment3 = "// Offsets for cols and rows of Flipbook Texture"; - string vcolsoffset = "float fbcolsoffset" + OutputId + " = 1.0f / " + columns + ";"; - string vrowssoffset = "float fbrowsoffset" + OutputId + " = 1.0f / " + rows + ";"; - string vcomment4 = "// Speed of animation"; - - string vspeed = string.Format( "float fbspeed{0} = {1} * {2};", OutputId,timer,speed); - string vcomment5 = "// UV Tiling (col and row offset)"; - string vtiling = "float2 fbtiling" + OutputId + " = float2(fbcolsoffset" + OutputId + ", fbrowsoffset" + OutputId + ");"; - string vcomment6 = "// UV Offset - calculate current tile linear index, and convert it to (X * coloffset, Y * rowoffset)"; - string vcomment7 = "// Calculate current tile linear index"; - //float fbcurrenttileindex1 = round( fmod( fbspeed1 + _Float0, fbtotaltiles1 ) ); - string vcurrenttileindex = "float fbcurrenttileindex" + OutputId + " = round( fmod( fbspeed" + OutputId + " + " + startframe + ", fbtotaltiles" + OutputId + ") );"; - string vcurrenttileindex1 = "fbcurrenttileindex" + OutputId + " += ( fbcurrenttileindex" + OutputId + " < 0) ? fbtotaltiles" + OutputId + " : 0;"; - //fbcurrenttileindex1 += ( fbcurrenttileindex1 < 0 ) ? fbtotaltiles1 : 0; - //string vcurrenttileindex = "int fbcurrenttileindex" + m_uniqueId + " = (int)fmod( fbspeed" + m_uniqueId + ", fbtotaltiles" + m_uniqueId + ") + " + startframe + ";"; - string vcomment8 = "// Obtain Offset X coordinate from current tile linear index"; - - //float fblinearindextox1 = round( fmod( fbcurrenttileindex1, 5.0 ) ); - //string voffsetx1 = "int fblinearindextox" + m_uniqueId + " = fbcurrenttileindex" + m_uniqueId + " % (int)" + columns + ";"; - string voffsetx1 = "float fblinearindextox" + OutputId + " = round ( fmod ( fbcurrenttileindex" + OutputId + ", " + columns + " ) );"; - string vcomment9 = String.Empty; - string voffsetx2 = String.Empty; - if ( m_negativeSpeedBehavior != 0 ) - { - vcomment9 = "// Reverse X animation if speed is negative"; - voffsetx2 = "fblinearindextox" + OutputId + " = (" + speed + " > 0 ? fblinearindextox" + OutputId + " : (int)" + columns + " - fblinearindextox" + OutputId + ");"; - } - string vcomment10 = "// Multiply Offset X by coloffset"; - string voffsetx3 = "float fboffsetx" + OutputId + " = fblinearindextox" + OutputId + " * fbcolsoffset" + OutputId + ";"; - string vcomment11 = "// Obtain Offset Y coordinate from current tile linear index"; - //float fblinearindextoy1 = round( fmod( ( fbcurrenttileindex1 - fblinearindextox1 ) / 5.0, 5.0 ) ); - string voffsety1 = "float fblinearindextoy" + OutputId + " = round( fmod( ( fbcurrenttileindex" + OutputId + " - fblinearindextox" + OutputId + " ) / " + columns + ", " + rows + " ) );"; - //string voffsety1 = "int fblinearindextoy" + m_uniqueId + " = (int)( ( fbcurrenttileindex" + m_uniqueId + " - fblinearindextox" + m_uniqueId + " ) / " + columns + " ) % (int)" + rows + ";"; - //string vcomment10 = "// Reverse Y to get from Top to Bottom"; - //string voffsety2 = "fblinearindextoy" + m_uniqueId + " = (int)" + rows + " - fblinearindextoy" + m_uniqueId + ";"; - string vcomment12 = String.Empty; - string voffsety2 = String.Empty; - if ( m_negativeSpeedBehavior == 0 ) - { - if ( m_selectedTextureVerticalDirection == 0 ) - { - vcomment12 = "// Reverse Y to get tiles from Top to Bottom"; - voffsety2 = "fblinearindextoy" + OutputId + " = (int)(" + rows + "-1) - fblinearindextoy" + OutputId + ";"; - } - } - else - { - string reverseanimationoperator = String.Empty; - if ( m_selectedTextureVerticalDirection == 0 ) - { - vcomment12 = "// Reverse Y to get tiles from Top to Bottom and Reverse Y animation if speed is negative"; - reverseanimationoperator = " < "; - } - else - { - vcomment12 = "// Reverse Y animation if speed is negative"; - reverseanimationoperator = " > "; - } - voffsety2 = "fblinearindextoy" + OutputId + " = (" + speed + reverseanimationoperator + " 0 ? fblinearindextoy" + OutputId + " : (int)" + rows + " - fblinearindextoy" + OutputId + ");"; - } - string vcomment13 = "// Multiply Offset Y by rowoffset"; - string voffsety3 = "float fboffsety" + OutputId + " = fblinearindextoy" + OutputId + " * fbrowsoffset" + OutputId + ";"; - string vcomment14 = "// UV Offset"; - string voffset = "float2 fboffset" + OutputId + " = float2(fboffsetx" + OutputId + ", fboffsety" + OutputId + ");"; - //string voffset = "float2 fboffset" + m_uniqueId + " = float2( ( ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + ") % (int)" + columns + " ) * fbcolsoffset" + m_OutputId + " ) , ( ( (int)" + rows + " - ( (int)( ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + " ) - ( (int)fmod( fbspeed" + m_uniqueId + " , fbtotaltiles" + m_uniqueId + " ) % (int)" + columns + " ) ) / " + columns + " ) % (int)" + rows + " ) ) * fbrowsoffset" + m_uniqueId + " ) );"; - string vcomment15 = "// Flipbook UV"; - string vfbuv = "half2 fbuv" + OutputId + " = " + uv + " * fbtiling" + OutputId + " + fboffset" + OutputId + ";"; - string vcomment16 = "// *** END Flipbook UV Animation vars ***"; - string result = "fbuv" + OutputId; - - dataCollector.AddLocalVariable( UniqueId, vcomment1 ); - dataCollector.AddLocalVariable( UniqueId, vcomment2 ); - dataCollector.AddLocalVariable( UniqueId, vtotaltiles ); - dataCollector.AddLocalVariable( UniqueId, vcomment3 ); - dataCollector.AddLocalVariable( UniqueId, vcolsoffset ); - dataCollector.AddLocalVariable( UniqueId, vrowssoffset ); - dataCollector.AddLocalVariable( UniqueId, vcomment4 ); - dataCollector.AddLocalVariable( UniqueId, vspeed ); - dataCollector.AddLocalVariable( UniqueId, vcomment5 ); - dataCollector.AddLocalVariable( UniqueId, vtiling ); - dataCollector.AddLocalVariable( UniqueId, vcomment6 ); - dataCollector.AddLocalVariable( UniqueId, vcomment7 ); - dataCollector.AddLocalVariable( UniqueId, vcurrenttileindex ); - dataCollector.AddLocalVariable( UniqueId, vcurrenttileindex1 ); - dataCollector.AddLocalVariable( UniqueId, vcomment8 ); - dataCollector.AddLocalVariable( UniqueId, voffsetx1 ); - if ( m_negativeSpeedBehavior != 0 ) - { - dataCollector.AddLocalVariable( UniqueId, vcomment9 ); - dataCollector.AddLocalVariable( UniqueId, voffsetx2 ); - } - dataCollector.AddLocalVariable( UniqueId, vcomment10 ); - dataCollector.AddLocalVariable( UniqueId, voffsetx3 ); - dataCollector.AddLocalVariable( UniqueId, vcomment11 ); - dataCollector.AddLocalVariable( UniqueId, voffsety1 ); - if ( m_selectedTextureVerticalDirection == 0 || m_negativeSpeedBehavior != 0 ) - { - dataCollector.AddLocalVariable( UniqueId, vcomment12 ); - dataCollector.AddLocalVariable( UniqueId, voffsety2 ); - } - dataCollector.AddLocalVariable( UniqueId, vcomment13 ); - dataCollector.AddLocalVariable( UniqueId, voffsety3 ); - dataCollector.AddLocalVariable( UniqueId, vcomment14 ); - dataCollector.AddLocalVariable( UniqueId, voffset ); - dataCollector.AddLocalVariable( UniqueId, vcomment15 ); - dataCollector.AddLocalVariable( UniqueId, vfbuv ); - dataCollector.AddLocalVariable( UniqueId, vcomment16 ); - - m_outputPorts[ 0 ].SetLocalValue( result, dataCollector.PortCategory ); - - return GetOutputVectorItem( 0, outputId, result ); - - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs.meta deleted file mode 100644 index cf165fe3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCFlipBookUVAnimation.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 38b8c76e7f2dc294581195a669942706 -timeCreated: 1481126954 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs deleted file mode 100644 index 3d778d9c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Pixelate UV -// Donated by The Four Headed Cat - @fourheadedcat - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Pixelate UV", "UV Coordinates", "Pixelate Texture Modifying UV.", null, KeyCode.None, true, false, null, null, "The Four Headed Cat - @fourheadedcat" )] - public sealed class TFHCPixelate : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT2, true, "UV" ); - AddInputPort( WirePortDataType.FLOAT, false, "Pixels X" ); - AddInputPort( WirePortDataType.FLOAT, false, "Pixels Y" ); - AddOutputPort( WirePortDataType.FLOAT2, "Out" ); - m_useInternalPortData = true; - m_previewShaderGUID = "e2f7e3c513ed18340868b8cbd0d85cfb"; - } - - public override void DrawProperties() - { - base.DrawProperties (); - EditorGUILayout.HelpBox ("Pixelate UV.\n\n - UV is the Texture Coordinates to pixelate.\n - Pixels X is the number of horizontal pixels\n - Pixels Y is the number of vertical pixels.", MessageType.None); - - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - string PixelCount_X = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ); - string PixelCount_Y = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); - - string pixelWidth = "float pixelWidth" + OutputId + " = 1.0f / " + PixelCount_X + ";"; - string pixelHeight = "float pixelHeight" + OutputId + " = 1.0f / " + PixelCount_Y + ";"; - string pixelatedUV = "half2 pixelateduv" + OutputId + " = half2((int)(" + uv + ".x / pixelWidth" + OutputId + ") * pixelWidth" + OutputId + ", (int)(" + uv + ".y / pixelHeight" + OutputId + ") * pixelHeight" + OutputId + ");"; - string result = "pixelateduv" + OutputId; - - dataCollector.AddLocalVariable( UniqueId, pixelWidth ); - dataCollector.AddLocalVariable( UniqueId, pixelHeight ); - dataCollector.AddLocalVariable( UniqueId, pixelatedUV ); - - return GetOutputVectorItem( 0, outputId, result); - - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs.meta deleted file mode 100644 index fc01dd0a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 72a1a810ace8ea440ba20d4a4f9086ce -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs deleted file mode 100644 index fc7b1801..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs +++ /dev/null @@ -1,588 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Texture Coordinates", "UV Coordinates", "Texture UV coordinates set, if <b>Tex</b> is connected to a texture object it will use that texture scale factors, otherwise uses <b>Tilling</b> and <b>Offset</b> port values", null, KeyCode.U, tags: "uv" )] - public sealed class TextureCoordinatesNode : ParentNode - { - - private const string DummyPropertyDec = "[HideInInspector] _DummyTex{0}( \"\", 2D ) = \"white\""; - private const string DummyUniformDec = "uniform sampler2D _DummyTex{0};"; - private const string DummyTexCoordDef = "uv{0}_DummyTex{0}"; - private const string DummyTexCoordSurfDef = "float2 texCoordDummy{0} = {1}.uv{2}_DummyTex{2}*{3} + {4};"; - private const string DummyTexCoordSurfVar = "texCoordDummy{0}"; - - private readonly string[] Dummy = { string.Empty }; - - private const string TilingStr = "Tiling"; - private const string OffsetStr = "Offset"; - private const string TexCoordStr = "texcoord_"; - - [SerializeField] - private int m_referenceArrayId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - [SerializeField] - private int m_textureCoordChannel = 0; - - //[SerializeField] - //private int m_texcoordId = -1; - - [SerializeField] - private int m_texcoordSize = 2; - - [SerializeField] - private string m_surfaceTexcoordName = string.Empty; - - [SerializeField] - private TexturePropertyNode m_inputReferenceNode = null; - - private Vector4Node m_texCoordsHelper; - - private TexturePropertyNode m_referenceNode = null; - - private InputPort m_texPort = null; - private InputPort m_tilingPort = null; - private InputPort m_offsetPort = null; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.SAMPLER2D, false, "Tex", -1, MasterNodePortCategory.Fragment, 2 ); - m_texPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_texPort.CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT ); - - AddInputPort( WirePortDataType.FLOAT2, false, "Tiling", -1, MasterNodePortCategory.Fragment, 0 ); - m_tilingPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - m_tilingPort.Vector2InternalData = new Vector2( 1, 1 ); - AddInputPort( WirePortDataType.FLOAT2, false, "Offset", -1, MasterNodePortCategory.Fragment, 1 ); - m_offsetPort = m_inputPorts[ m_inputPorts.Count - 1 ]; - - - AddOutputVectorPorts( WirePortDataType.FLOAT2, "UV" ); - m_outputPorts[ 1 ].Name = "U"; - m_outputPorts[ 2 ].Name = "V"; - AddOutputPort( WirePortDataType.FLOAT, "W" ); - AddOutputPort( WirePortDataType.FLOAT, "T" ); - m_textLabelWidth = 90; - m_useInternalPortData = true; - m_autoWrapProperties = true; - m_tilingPort.Category = MasterNodePortCategory.Vertex; - m_offsetPort.Category = MasterNodePortCategory.Vertex; - UpdateOutput(); - m_previewShaderGUID = "085e462b2de441a42949be0e666cf5d2"; - } - - public override void Reset() - { - m_surfaceTexcoordName = string.Empty; - } - - public override void OnInputPortConnected( int portId, int otherNodeId, int otherPortId, bool activateNode = true ) - { - base.OnInputPortConnected( portId, otherNodeId, otherPortId, activateNode ); - if( portId == 2 ) - { - m_inputReferenceNode = m_texPort.GetOutputNodeWhichIsNotRelay() as TexturePropertyNode; - UpdatePorts(); - } - UpdateTitle(); - } - - public override void OnInputPortDisconnected( int portId ) - { - base.OnInputPortDisconnected( portId ); - if( portId == 2 ) - { - m_inputReferenceNode = null; - UpdatePorts(); - } - UpdateTitle(); - } - - void UpdateTitle() - { - if( m_inputReferenceNode != null ) - { - m_additionalContent.text = string.Format( "Value( {0} )", m_inputReferenceNode.PropertyInspectorName ); - } - else if( m_referenceArrayId > -1 && m_referenceNode != null ) - { - m_additionalContent.text = string.Format( "Value( {0} )", m_referenceNode.PropertyInspectorName ); - } - else - { - m_additionalContent.text = string.Empty; - } - m_sizeIsDirty = true; - } - - void UpdatePorts() - { - if( m_inputReferenceNode != null || m_texPort.IsConnected ) - { - m_tilingPort.Locked = true; - m_offsetPort.Locked = true; - } - else if( m_referenceArrayId > -1 ) - { - m_tilingPort.Locked = true; - m_offsetPort.Locked = true; - } - else - { - m_tilingPort.Locked = false; - m_offsetPort.Locked = false; - } - } - - public override void 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_texPort.IsConnected ); - m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId + 1, arr.ToArray() ) - 1; - } - else - { - m_referenceArrayId = -1; - GUI.enabled = false; - EditorGUILayoutPopup( Constants.AvailableReferenceStr, 0, Dummy ); - } - - GUI.enabled = guiEnabledBuffer; - if( EditorGUI.EndChangeCheck() ) - { - m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); - if( m_referenceNode != null ) - { - m_referenceNodeId = m_referenceNode.UniqueId; - } - else - { - m_referenceNodeId = -1; - m_referenceArrayId = -1; - } - - UpdateTitle(); - UpdatePorts(); - } - - EditorGUI.BeginChangeCheck(); - m_texcoordSize = EditorGUILayoutIntPopup( Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateOutput(); - } - - m_textureCoordChannel = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordChannel, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ); - - - if( m_referenceArrayId > -1 ) - GUI.enabled = false; - - base.DrawProperties(); - - GUI.enabled = guiEnabledBuffer; - } - - private void UpdateOutput() - { - if( m_texcoordSize == 3 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "UVW"; - m_outputPorts[ 3 ].Visible = true; - m_outputPorts[ 4 ].Visible = false; - } - else if( m_texcoordSize == 4 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "UVWT"; - m_outputPorts[ 3 ].Visible = true; - m_outputPorts[ 4 ].Visible = true; - } - else - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_outputPorts[ 0 ].Name = "UV"; - m_outputPorts[ 3 ].Visible = false; - m_outputPorts[ 4 ].Visible = false; - } - m_sizeIsDirty = true; - } - - public override void OnNodeLogicUpdate( DrawInfo drawInfo ) - { - base.OnNodeLogicUpdate( drawInfo ); - CheckReference(); - } - - //public override void Draw( DrawInfo drawInfo ) - //{ - // base.Draw( drawInfo ); - // //CheckReference(); - //} - - void CheckReference() - { - if( m_referenceArrayId > -1 ) - { - ParentNode newNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); - if( newNode == null || newNode.UniqueId != m_referenceNodeId ) - { - m_referenceNode = null; - int count = UIUtils.GetTexturePropertyNodeAmount(); - for( int i = 0; i < count; i++ ) - { - ParentNode node = UIUtils.GetTexturePropertyNode( i ); - if( node.UniqueId == m_referenceNodeId ) - { - m_referenceNode = node as TexturePropertyNode; - m_referenceArrayId = i; - break; - } - } - } - } - - if( m_referenceNode == null && m_referenceNodeId > -1 ) - { - m_referenceNodeId = -1; - m_referenceArrayId = -1; - UpdateTitle(); - UpdatePorts(); - } - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_textureCoordChannel = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 2402 ) - { - if( UIUtils.CurrentShaderVersion() > 2404 ) - { - m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - else - { - m_referenceArrayId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - - if( UIUtils.CurrentShaderVersion() > 5001 ) - { - m_texcoordSize = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdateOutput(); - } - } - - - public override void RefreshExternalReferences() - { - base.RefreshExternalReferences(); - if( UIUtils.CurrentShaderVersion() > 2402 ) - { - if( UIUtils.CurrentShaderVersion() > 2404 ) - { - m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode; - if( m_referenceNodeId > -1 ) - m_referenceArrayId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId ); - } - else - { - m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); - if( m_referenceNode != null ) - { - m_referenceNodeId = m_referenceNode.UniqueId; - } - } - UpdateTitle(); - UpdatePorts(); - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - if( dataCollector != null && dataCollector.TesselationActive ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - return; - } - - if( dataCollector.IsTemplate ) - { - dataCollector.TemplateDataCollectorInstance.SetUVUsage( m_textureCoordChannel, m_texcoordSize ); - } - else if( m_textureCoordChannel > 3 ) - { - dataCollector.AddCustomAppData( string.Format( TemplateHelperFunctions.TexUVFullSemantic, m_textureCoordChannel ) ); - } - UIUtils.SetCategoryInBitArray( ref m_category, nodeData.Category ); - - MasterNodePortCategory propagateCategory = ( nodeData.Category != MasterNodePortCategory.Vertex && nodeData.Category != MasterNodePortCategory.Tessellation ) ? MasterNodePortCategory.Vertex : nodeData.Category; - nodeData.Category = propagateCategory; - nodeData.GraphDepth += 1; - if( nodeData.GraphDepth > m_graphDepth ) - { - m_graphDepth = nodeData.GraphDepth; - } - - int count = m_inputPorts.Count; - for( int i = 0; i < count; i++ ) - { - if( m_inputPorts[ i ].IsConnected ) - { - //m_inputPorts[ i ].GetOutputNode().PropagateNodeCategory( category ); - m_inputPorts[ i ].GetOutputNode().PropagateNodeData( nodeData, ref dataCollector ); - } - } - } - - 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_referenceNode != null ) ? m_referenceNode.UniqueId : -1 ) ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_texcoordSize ); - } - - string GetValidPropertyName() - { - string propertyName = string.Empty; - if( m_inputReferenceNode != null ) - { - propertyName = m_inputReferenceNode.PropertyName; - } - else if( m_referenceArrayId > -1 ) - { - m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); - if( m_referenceNode != null ) - { - propertyName = m_referenceNode.PropertyName; - } - } - - return propertyName; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port" ); - return "-1"; - } - - //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); - - string tiling = string.Empty; - string offset = string.Empty; - - string portProperty = string.Empty; - if( m_texPort.IsConnected ) - { - portProperty = m_texPort.GeneratePortInstructions( ref dataCollector ); - } - else if( m_referenceArrayId > -1 ) - { - TexturePropertyNode temp = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); - if( temp != null ) - { - portProperty = temp.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - } - } - - //TEMPLATES - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - - string uvName = string.Empty; - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordChannel ) ) - { - uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ); - } - else - { - uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ); - } - string currPropertyName = GetValidPropertyName(); - if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) - { - currPropertyName = portProperty; - } - if( !string.IsNullOrEmpty( currPropertyName ) ) - { - string finalTexCoordName = "uv" + m_textureCoordChannel + currPropertyName; - string dummyPropertyTexcoords = currPropertyName + "_ST"; - - if( m_texCoordsHelper == null ) - { - m_texCoordsHelper = CreateInstance<Vector4Node>(); - m_texCoordsHelper.ContainerGraph = ContainerGraph; - m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ); - m_texCoordsHelper.RegisterPropertyOnInstancing = false; - m_texCoordsHelper.AddGlobalToSRPBatcher = true; - } - - if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader ) - { - m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty; - } - else - { - m_texCoordsHelper.CurrentParameterType = PropertyType.Global; - } - m_texCoordsHelper.ResetOutputLocals(); - m_texCoordsHelper.SetRawPropertyName( dummyPropertyTexcoords ); - dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ); - - if( m_texcoordSize > 2 ) - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ); - dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ) + ";" ); - m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ); - } - else - { - RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ), ref dataCollector, finalTexCoordName ); - } - //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName ); - } - else - { - string finalTexCoordName = "uv" + m_textureCoordChannel + OutputId; - tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ); - offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ); - - if( m_texcoordSize > 2 ) - { - dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ); - dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset ) + ";" ); - m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ); - } - else - { - RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ); - } - //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ); - } - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - //SURFACE - string propertyName = GetValidPropertyName(); - if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) - { - propertyName = portProperty; - } - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - - if( !m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one ) - tiling = null; - else - tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ); - - if( !m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero ) - offset = null; - else - offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ); - - if( !string.IsNullOrEmpty( propertyName ) /*m_referenceArrayId > -1*/ ) - { - m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ); - } - else - { - m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ); - } - - m_outputPorts[ 0 ].SetLocalValue( m_surfaceTexcoordName, dataCollector.PortCategory ); - return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ); - } - - public override void ReadInputDataFromString( ref string[] nodeParams ) - { - if( UIUtils.CurrentShaderVersion() > 7003 ) - { - base.ReadInputDataFromString( ref nodeParams ); - } - else - { - for( int i = 0; i < 2 && i < nodeParams.Length && m_currentReadParamIdx < nodeParams.Length; i++ ) - { - if( UIUtils.CurrentShaderVersion() < 5003 ) - { - int newId = VersionConvertInputPortId( i ) + 1; - if( UIUtils.CurrentShaderVersion() > 23 ) - { - m_inputPorts[ newId ].DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] ); - } - - m_inputPorts[ newId ].InternalData = nodeParams[ m_currentReadParamIdx++ ]; - if( m_inputPorts[ newId ].IsEditable && UIUtils.CurrentShaderVersion() >= 3100 && m_currentReadParamIdx < nodeParams.Length ) - { - m_inputPorts[ newId ].Name = nodeParams[ m_currentReadParamIdx++ ]; - } - } - else - { - int portId = Convert.ToInt32( nodeParams[ m_currentReadParamIdx++ ] ); - WirePortDataType DataType = (WirePortDataType)Enum.Parse( typeof( WirePortDataType ), nodeParams[ m_currentReadParamIdx++ ] ); - string InternalData = nodeParams[ m_currentReadParamIdx++ ]; - bool isEditable = Convert.ToBoolean( nodeParams[ m_currentReadParamIdx++ ] ); - string Name = string.Empty; - if( isEditable && m_currentReadParamIdx < nodeParams.Length ) - { - Name = nodeParams[ m_currentReadParamIdx++ ]; - } - - InputPort inputPort = GetInputPortByUniqueId( portId ); - if( inputPort != null ) - { - inputPort.DataType = DataType; - inputPort.InternalData = InternalData; - if( !string.IsNullOrEmpty( Name ) ) - { - inputPort.Name = Name; - } - } - } - } - } - } - - public override void Destroy() - { - base.Destroy(); - m_referenceNode = null; - - if( m_texCoordsHelper != null ) - { - //Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff - DestroyImmediate( m_texCoordsHelper ); - m_texCoordsHelper = null; - } - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs.meta deleted file mode 100644 index be9e1184..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureCoordinatesNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 872b1da17041cd64482c826cbfd9c8c6 -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs deleted file mode 100644 index 6f3e1016..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs +++ /dev/null @@ -1,1175 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum TexturePropertyValues - { - white, - black, - gray, - bump - } - - public enum TextureType - { - Texture1D, - Texture2D, - Texture3D, - Cube, - Texture2DArray, - ProceduralTexture - } - - public enum AutoCastType - { - Auto = 0, - LockedToTexture1D, - LockedToTexture2D, - LockedToTexture3D, - LockedToCube, - LockedToTexture2DArray - } - - - [Serializable] - [NodeAttributes( "Texture Object", "Textures", "Represents a Texture Asset. Can be used in samplers <b>Tex</b> inputs or shader function inputs to reuse the same texture multiple times.", SortOrderPriority = 1 )] - public class TexturePropertyNode : PropertyNode - { - private const string ObjectSelectorCmdStr = "ObjectSelectorClosed"; - - protected readonly string[] AvailablePropertyTypeLabels = { PropertyType.Property.ToString(), PropertyType.Global.ToString() }; - protected readonly int[] AvailablePropertyTypeValues = { (int)PropertyType.Property, (int)PropertyType.Global }; - - protected const int OriginalFontSizeUpper = 9; - protected const int OriginalFontSizeLower = 9; - - protected const string DefaultTextureStr = "Default Texture"; - protected const string AutoCastModeStr = "Auto-Cast Mode"; - - protected const string AutoUnpackNormalsStr = "Normal"; - - [SerializeField] - protected Texture m_defaultValue; - - [SerializeField] - protected Texture m_materialValue; - - [SerializeField] - protected TexturePropertyValues m_defaultTextureValue; - - [SerializeField] - protected bool m_isNormalMap; - - [SerializeField] - protected System.Type m_textureType = typeof( Texture2D ); - - [SerializeField] - protected int m_useSamplerArrayIdx = -1; - - //[SerializeField] - //protected bool m_isTextureFetched; - - //[SerializeField] - //protected string m_textureFetchedValue; - - [SerializeField] - protected TextureType m_currentType = TextureType.Texture2D; - - [SerializeField] - protected AutoCastType m_autocastMode = AutoCastType.Auto; - - protected int PreviewSizeX = 128; - protected int PreviewSizeY = 128; - - protected bool m_linearTexture; - - protected TexturePropertyNode m_textureProperty = null; - - protected bool m_drawPicker; - - protected bool m_drawAutocast = true; - - protected int m_cachedSamplerId = -1; - protected int m_cachedSamplerIdArray = -1; - protected int m_cachedSamplerIdCube = -1; - protected int m_cachedSamplerId3D = -1; - protected int m_defaultId = -1; - protected int m_typeId = -1; - - private TextureType m_previousType = TextureType.Texture2D; - private string m_labelText = "None (Texture2D)"; - - protected bool m_isEditingPicker; - - public TexturePropertyNode() : base() { } - public TexturePropertyNode( 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 ); - GlobalTypeWarningText = string.Format( GlobalTypeWarningText, "Texture" ); - m_defaultTextureValue = TexturePropertyValues.white; - m_insideSize.Set( PreviewSizeX, PreviewSizeY + 5 ); - AddOutputPort( WirePortDataType.SAMPLER2D, "Tex" ); - m_outputPorts[ 0 ].CreatePortRestrictions( WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT ); - m_currentParameterType = PropertyType.Property; - m_customPrefix = "Texture "; - m_drawPrecisionUI = false; - m_showVariableMode = true; - m_freeType = false; - m_drawPicker = true; - m_hasLeftDropdown = true; - m_textLabelWidth = 115; - m_longNameSize = 225; - m_availableAttribs.Add( new PropertyAttributes( "No Scale Offset", "[NoScaleOffset]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Normal", "[Normal]" ) ); - m_availableAttribs.Add( new PropertyAttributes( "Single Line Texture", "[SingleLineTexture]" ) ); - m_showPreview = true; - m_drawPreviewExpander = false; - m_drawPreview = false; - m_drawPreviewMaskButtons = false; - m_previewShaderGUID = "e53988745ec6e034694ee2640cd3d372"; - } - - public override void AfterCommonInit() - { - base.AfterCommonInit(); - m_hasLeftDropdown = true; - } - - protected void SetPreviewTexture( Texture newValue ) - { - if( newValue is Cubemap ) - { - PreviewMaterial.SetInt( m_typeId, 3 ); - - if( m_cachedSamplerIdCube == -1 ) - m_cachedSamplerIdCube = Shader.PropertyToID( "_Cube" ); - - PreviewMaterial.SetTexture( m_cachedSamplerIdCube, newValue as Cubemap ); - } - else if( newValue is Texture2DArray ) - { - PreviewMaterial.SetInt( m_typeId, 4 ); - - if( m_cachedSamplerIdArray == -1 ) - m_cachedSamplerIdArray = Shader.PropertyToID( "_Array" ); - - PreviewMaterial.SetTexture( m_cachedSamplerIdArray, newValue as Texture2DArray ); - } - else if( newValue is Texture3D ) - { - PreviewMaterial.SetInt( m_typeId, 2 ); - - if( m_cachedSamplerId3D == -1 ) - m_cachedSamplerId3D = Shader.PropertyToID( "_Sampler3D" ); - - PreviewMaterial.SetTexture( m_cachedSamplerId3D, newValue as Texture3D ); - } - else - { - PreviewMaterial.SetInt( m_typeId, 1 ); - - if( m_cachedSamplerId == -1 ) - m_cachedSamplerId = Shader.PropertyToID( "_Sampler" ); - - PreviewMaterial.SetTexture( m_cachedSamplerId, newValue ); - } - } - - public override void SetPreviewInputs() - { - base.SetPreviewInputs(); - - if( Value == null ) - { - if( m_defaultId == -1 ) - m_defaultId = Shader.PropertyToID( "_Default" ); - - PreviewMaterial.SetInt( m_defaultId, ( (int)m_defaultTextureValue ) + 1 ); - m_previewMaterialPassId = 0; - } - else - { - if( m_defaultId == -1 ) - m_defaultId = Shader.PropertyToID( "_Default" ); - - PreviewMaterial.SetInt( m_defaultId, 0 ); - - if( m_typeId == -1 ) - m_typeId = Shader.PropertyToID( "_Type" ); - - m_previewMaterialPassId = 1; - SetPreviewTexture( Value ); - //if( Value is Cubemap ) - //{ - // PreviewMaterial.SetInt( m_typeId, 3 ); - - // if( m_cachedSamplerIdCube == -1 ) - // m_cachedSamplerIdCube = Shader.PropertyToID( "_Cube" ); - - // PreviewMaterial.SetTexture( m_cachedSamplerIdCube, Value as Cubemap ); - //} - //else if( Value is Texture2DArray ) - //{ - // PreviewMaterial.SetInt( m_typeId, 4 ); - - // if( m_cachedSamplerIdArray == -1 ) - // m_cachedSamplerIdArray = Shader.PropertyToID( "_Array" ); - - // PreviewMaterial.SetTexture( m_cachedSamplerIdArray, Value as Texture2DArray ); - //} - //else if( Value is Texture3D ) - //{ - // PreviewMaterial.SetInt( m_typeId, 2 ); - - // if( m_cachedSamplerId3D == -1 ) - // m_cachedSamplerId3D = Shader.PropertyToID( "_Sampler3D" ); - - // PreviewMaterial.SetTexture( m_cachedSamplerId3D, Value as Texture3D ); - //} - //else - //{ - // PreviewMaterial.SetInt( m_typeId, 1 ); - - // if( m_cachedSamplerId == -1 ) - // m_cachedSamplerId = Shader.PropertyToID( "_Sampler" ); - - // PreviewMaterial.SetTexture( m_cachedSamplerId, Value ); - //} - } - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - m_textureProperty = this; - UIUtils.RegisterPropertyNode( this ); - UIUtils.RegisterTexturePropertyNode( this ); - } - - protected void ConfigTextureData( TextureType type ) - { - switch( m_autocastMode ) - { - case AutoCastType.Auto: - { - m_currentType = type; - } - break; - case AutoCastType.LockedToTexture1D: - { - m_currentType = TextureType.Texture1D; - } - break; - case AutoCastType.LockedToTexture2DArray: - { - m_currentType = TextureType.Texture2DArray; - } - break; - case AutoCastType.LockedToTexture2D: - { - m_currentType = TextureType.Texture2D; - } - break; - case AutoCastType.LockedToTexture3D: - { - m_currentType = TextureType.Texture3D; - } - break; - case AutoCastType.LockedToCube: - { - m_currentType = TextureType.Cube; - } - break; - } - - ConfigTextureType(); - } - - protected void ConfigTextureType() - { - switch( m_currentType ) - { - case TextureType.Texture1D: - { - m_textureType = typeof( Texture ); - } - break; - case TextureType.Texture2DArray: - { - m_textureType = typeof( Texture2DArray ); - } - break; - case TextureType.Texture2D: - { - m_textureType = typeof( Texture2D ); - } - break; - case TextureType.Texture3D: - { - m_textureType = typeof( Texture3D ); - } - break; - case TextureType.Cube: - { - m_textureType = typeof( Cubemap ); - } - break; -#if !UNITY_2018_1_OR_NEWER - // Disabling Substance Deprecated warning -#pragma warning disable 0618 - case TextureType.ProceduralTexture: - { - m_textureType = typeof( ProceduralTexture ); - } - break; -#pragma warning restore 0618 -#endif - - } - } - - protected void DrawTexturePropertyType() - { - PropertyType parameterType = (PropertyType)EditorGUILayoutIntPopup( ParameterTypeStr, (int)m_currentParameterType, AvailablePropertyTypeLabels, AvailablePropertyTypeValues ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - } - } - - // Texture1D - public string GetTexture1DPropertyValue() - { - return PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}"; - } - - public string GetTexture1DUniformValue() - { - return "uniform sampler1D " + PropertyName + ";"; - } - - // Texture2D - public string GetTexture2DPropertyValue() - { - return PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}"; - } - - public string GetTexture2DUniformValue() - { - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationSRPMacros[ TextureType.Texture2D ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerSRPMacros[ TextureType.Texture2D ], PropertyName ); - } - else - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationStandardMacros[ TextureType.Texture2D ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerStandardMacros[ TextureType.Texture2D ], PropertyName ); - } - - } - - if( PropertyName == "_CameraDepthTexture" ) - return Constants.CameraDepthTextureValue; - else - return "uniform sampler2D " + PropertyName + ";"; - } - - //Texture3D - public string GetTexture3DPropertyValue() - { - return PropertyName + "(\"" + m_propertyInspectorName + "\", 3D) = \"" + m_defaultTextureValue + "\" {}"; - } - - public string GetTexture3DUniformValue() - { - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationSRPMacros[ TextureType.Texture3D ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerSRPMacros[ TextureType.Texture3D ], PropertyName ); - } - else - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationStandardMacros[ TextureType.Texture3D ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerStandardMacros[ TextureType.Texture3D ], PropertyName ); - } - } - return "uniform sampler3D " + PropertyName + ";"; - } - - // Cube - public string GetCubePropertyValue() - { - return PropertyName + "(\"" + m_propertyInspectorName + "\", CUBE) = \"" + m_defaultTextureValue + "\" {}"; - } - - public string GetCubeUniformValue() - { - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationSRPMacros[ TextureType.Cube ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerSRPMacros[ TextureType.Cube ], PropertyName ); - } - else - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationStandardMacros[ TextureType.Cube ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerStandardMacros[ TextureType.Cube ], PropertyName ); - } - } - - return "uniform samplerCUBE " + PropertyName + ";"; - } - - // Texture2DArray - public string GetTexture2DArrayPropertyValue() - { - return PropertyName + "(\"" + m_propertyInspectorName + "\", 2DArray) = \"" + m_defaultTextureValue + "\" {}"; - } - - public string GetTexture2DArrayUniformValue() - { - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationSRPMacros[ TextureType.Texture2DArray ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerSRPMacros[ TextureType.Texture2DArray ], PropertyName ); - } - else - { - if( m_useSamplerArrayIdx == 0 ) - return string.Format( Constants.TexDeclarationStandardMacros[ TextureType.Texture2DArray ], PropertyName ); - else - return string.Format( Constants.TexDeclarationNoSamplerStandardMacros[ TextureType.Texture2DArray ], PropertyName ); - } - } - - return "uniform TEXTURE2D_ARRAY( " + PropertyName + " );" + "\nuniform SAMPLER( sampler" + PropertyName + " );"; - } - - public override void DrawMainPropertyBlock() - { - DrawTexturePropertyType(); - base.DrawMainPropertyBlock(); - } - - public override void DrawSubProperties() - { - ShowDefaults(); - - - EditorGUI.BeginChangeCheck(); - Type currType = ( m_autocastMode == AutoCastType.Auto ) ? typeof( Texture ) : m_textureType; - m_defaultValue = EditorGUILayoutObjectField( Constants.DefaultValueLabel, m_defaultValue, currType, false ) as Texture; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - } - } - - public override void DrawMaterialProperties() - { - ShowDefaults(); - - EditorGUI.BeginChangeCheck(); - Type currType = ( m_autocastMode == AutoCastType.Auto ) ? typeof( Texture ) : m_textureType; - m_materialValue = EditorGUILayoutObjectField( Constants.MaterialValueLabel, m_materialValue, currType, false ) as Texture; - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - } - } - - new void ShowDefaults() - { - m_defaultTextureValue = (TexturePropertyValues)EditorGUILayoutEnumPopup( DefaultTextureStr, m_defaultTextureValue ); - - if( !m_drawAutocast ) - return; - - AutoCastType newAutoCast = (AutoCastType)EditorGUILayoutEnumPopup( AutoCastModeStr, m_autocastMode ); - if( newAutoCast != m_autocastMode ) - { - m_autocastMode = newAutoCast; - if( m_autocastMode != AutoCastType.Auto ) - { - ConfigTextureData( m_currentType ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - } - } - - private void ConfigurePortsFromReference() - { - m_sizeIsDirty = true; - } - - public virtual void ConfigureOutputPorts() - { - switch( m_currentType ) - { - case TextureType.Texture1D: - m_outputPorts[ 0 ].ChangeType( WirePortDataType.SAMPLER1D, false ); - break; - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - m_outputPorts[ 0 ].ChangeType( WirePortDataType.SAMPLER2D, false ); - break; - case TextureType.Texture3D: - m_outputPorts[ 0 ].ChangeType( WirePortDataType.SAMPLER3D, false ); - break; - case TextureType.Cube: - m_outputPorts[ 0 ].ChangeType( WirePortDataType.SAMPLERCUBE, false ); - break; - case TextureType.Texture2DArray: - m_outputPorts[ 0 ].ChangeType( WirePortDataType.SAMPLER2D, false ); - break; - } - - m_sizeIsDirty = true; - } - - public virtual void ConfigureInputPorts() - { - } - - public virtual void AdditionalCheck() - { - } - - public virtual void CheckTextureImporter( bool additionalCheck, bool writeDefault = true ) - { - m_requireMaterialUpdate = true; - Texture texture = m_materialMode ? m_materialValue : m_defaultValue; - TextureImporter importer = AssetImporter.GetAtPath( AssetDatabase.GetAssetPath( texture ) ) as TextureImporter; - if( importer != null ) - { - -#if UNITY_5_5_OR_NEWER - m_isNormalMap = importer.textureType == TextureImporterType.NormalMap; -#else - m_isNormalMap = importer.normalmap; -#endif - if( writeDefault && !UIUtils.IsLoading ) - { - if( m_defaultTextureValue == TexturePropertyValues.bump && !m_isNormalMap ) - m_defaultTextureValue = TexturePropertyValues.white; - else if( m_isNormalMap ) - m_defaultTextureValue = TexturePropertyValues.bump; - } - - if( additionalCheck ) - AdditionalCheck(); - m_linearTexture = !importer.sRGBTexture; - } - - if( ( texture as Texture2DArray ) != null ) - { - ConfigTextureData( TextureType.Texture2DArray ); - } - else if( ( texture as Texture2D ) != null ) - { - ConfigTextureData( TextureType.Texture2D ); - } - else if( ( texture as Texture3D ) != null ) - { - ConfigTextureData( TextureType.Texture3D ); - } - else if( ( texture as Cubemap ) != null ) - { - ConfigTextureData( TextureType.Cube ); - } -#if !UNITY_2018_1_OR_NEWER - // Disabling Substance Deprecated warning -#pragma warning disable 0618 - else if( ( texture as ProceduralTexture ) != null ) - { - ConfigTextureData( TextureType.ProceduralTexture ); - } -#pragma warning restore 0618 -#endif - - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - - public override void OnObjectDropped( UnityEngine.Object obj ) - { - base.OnObjectDropped( obj ); - ConfigFromObject( obj ); - } - - public override void SetupFromCastObject( UnityEngine.Object obj ) - { - base.SetupFromCastObject( obj ); - ConfigFromObject( obj ); - } - - protected void ConfigFromObject( UnityEngine.Object obj, bool writeDefault = true, bool additionalCheck = true ) - { - Texture texture = obj as Texture; - if( texture ) - { - m_materialValue = texture; - m_defaultValue = texture; - CheckTextureImporter( additionalCheck, writeDefault ); - } - } - - - - public override void DrawGUIControls( DrawInfo drawInfo ) - { - base.DrawGUIControls( drawInfo ); - - if( !( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp || drawInfo.CurrentEventType == EventType.ExecuteCommand || drawInfo.CurrentEventType == EventType.DragPerform ) ) - return; - - bool insideBox = m_previewRect.Contains( drawInfo.MousePosition ); - - bool closePicker = false; - if( insideBox ) - { - m_isEditingPicker = true; - } - else if( m_isEditingPicker && !insideBox && drawInfo.CurrentEventType != EventType.ExecuteCommand ) - { - closePicker = true; - } - - if( m_isEditingPicker && drawInfo.CurrentEventType == EventType.ExecuteCommand && - Event.current.commandName.Equals( ObjectSelectorCmdStr ) ) - { - closePicker = true; - } - - if( closePicker ) - { - GUI.FocusControl( null ); - m_isEditingPicker = false; - } - - } - - public override void OnNodeLayout( DrawInfo drawInfo ) - { - base.OnNodeLayout( drawInfo ); - ConfigTextureType(); - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - if( m_dropdownEditing ) - { - PropertyType parameterType = (PropertyType)EditorGUIIntPopup( m_dropdownRect, (int)m_currentParameterType, AvailablePropertyTypeLabels, AvailablePropertyTypeValues, UIUtils.PropertyPopUp ); - if( parameterType != m_currentParameterType ) - { - ChangeParameterType( parameterType ); - DropdownEditing = false; - } - } - - if( m_isEditingPicker && m_drawPicker && m_currentParameterType != PropertyType.Global ) - { - Rect hitRect = m_previewRect; - hitRect.height = 14 * drawInfo.InvertedZoom; - hitRect.y = m_previewRect.yMax - hitRect.height; - hitRect.width = 4 * 14 * drawInfo.InvertedZoom; - - bool restoreMouse = false; - if( Event.current.type == EventType.MouseDown && hitRect.Contains( drawInfo.MousePosition ) ) - { - restoreMouse = true; - Event.current.type = EventType.Ignore; - } - - EditorGUI.BeginChangeCheck(); - m_colorBuffer = GUI.color; - GUI.color = Color.clear; - Type currType = ( m_autocastMode == AutoCastType.Auto ) ? typeof( Texture ) : m_textureType; - if( m_materialMode ) - { - m_materialValue = EditorGUIObjectField( m_previewRect, m_materialValue, currType, false ) as Texture; - } - else - { - m_defaultValue = EditorGUIObjectField( m_previewRect, m_defaultValue, currType, false ) as Texture; - } - GUI.color = m_colorBuffer; - - if( EditorGUI.EndChangeCheck() ) - { - CheckTextureImporter( true ); - SetTitleText( m_propertyInspectorName ); - SetAdditonalTitleText( string.Format( Constants.PropertyValueLabel, GetPropertyValStr() ) ); - ConfigureInputPorts(); - ConfigureOutputPorts(); - BeginDelayedDirtyProperty(); - PreviewIsDirty = true; - } - //else if( drawInfo.CurrentEventType == EventType.ExecuteCommand ) - //{ - // GUI.FocusControl( null ); - // m_isEditingPicker = false; - //} - - if( restoreMouse ) - { - Event.current.type = EventType.MouseDown; - } - - if( ( drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp ) ) - DrawPreviewMaskButtonsLayout( drawInfo, m_previewRect ); - } - - if( !m_drawPicker ) - return; - - if( drawInfo.CurrentEventType == EventType.Repaint ) - { - DrawTexturePicker( drawInfo ); - } - } - - - - protected void DrawTexturePicker( DrawInfo drawInfo ) - { - Rect newRect = m_previewRect; - Texture currentValue = m_materialMode ? m_materialValue : m_defaultValue; - - //??? - //m_showPreview = true; - bool showButtons = m_currentParameterType != PropertyType.Global; - - if( currentValue == null ) - GUI.Label( newRect, string.Empty, UIUtils.ObjectFieldThumb ); - else - DrawPreview( drawInfo, m_previewRect ); - - if( ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2 ) - { - Rect butRect = m_previewRect; - butRect.y -= 1; - butRect.x += 1; - - Rect smallButton = newRect; - smallButton.height = 14 * drawInfo.InvertedZoom; - smallButton.y = newRect.yMax - smallButton.height - 2; - smallButton.width = 40 * drawInfo.InvertedZoom; - smallButton.x = newRect.xMax - smallButton.width - 2; - if( currentValue == null ) - { - if( m_previousType != m_currentType ) - { - m_previousType = m_currentType; - m_labelText = "None (" + m_currentType.ToString() + ")"; - } - - GUI.Label( newRect, m_labelText, UIUtils.ObjectFieldThumbOverlay ); - } - else if( showButtons ) - { - DrawPreviewMaskButtonsRepaint( drawInfo, butRect ); - } - - if( showButtons ) - GUI.Label( smallButton, "Select", UIUtils.GetCustomStyle( CustomStyle.SamplerButton ) ); - } - - GUI.Label( newRect, string.Empty, UIUtils.GetCustomStyle( CustomStyle.SamplerFrame ) ); - } - - public string BaseGenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - return PropertyName; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - return BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - } - - public override void UpdateMaterial( Material mat ) - { - base.UpdateMaterial( mat ); - if( UIUtils.IsProperty( m_currentParameterType ) && !InsideShaderFunction ) - { - OnPropertyNameChanged(); - if( mat.HasProperty( PropertyName ) ) - { - mat.SetTexture( PropertyName, m_materialValue ); - } - } - } - - public override void SetMaterialMode( Material mat, bool fetchMaterialValues ) - { - base.SetMaterialMode( mat, fetchMaterialValues ); - if( fetchMaterialValues && m_materialMode && UIUtils.IsProperty( m_currentParameterType ) ) - { - if( mat.HasProperty( PropertyName ) ) - { - m_materialValue = mat.GetTexture( PropertyName ); - CheckTextureImporter( false, false ); - } - } - } - - public override void ForceUpdateFromMaterial( Material material ) - { - if( UIUtils.IsProperty( m_currentParameterType ) && material.HasProperty( PropertyName ) ) - { - m_materialValue = material.GetTexture( PropertyName ); - CheckTextureImporter( false, false ); - PreviewIsDirty = true; - } - } - - public override bool UpdateShaderDefaults( ref Shader shader, ref TextureDefaultsDataColector defaultCol/* ref string metaStr */) - { - if( m_defaultValue != null ) - { - defaultCol.AddValue( PropertyName, m_defaultValue ); - } - - return true; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - ReadAdditionalData( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 17101 ) - { - m_useSamplerArrayIdx = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - } - - public virtual void ReadAdditionalData( ref string[] nodeParams ) - { - string defaultTextureGUID = GetCurrentParam( ref nodeParams ); - //m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( defaultTextureGUID ) ); - string materialTextureGUID = GetCurrentParam( ref nodeParams ); - m_materialValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( materialTextureGUID ) ); - } - else - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( defaultTextureGUID ); - } - - m_isNormalMap = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_defaultTextureValue = (TexturePropertyValues)Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_autocastMode = (AutoCastType)Enum.Parse( typeof( AutoCastType ), GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 15306 ) - { - m_currentType = (TextureType)Enum.Parse( typeof( TextureType ), GetCurrentParam( ref nodeParams ) ); - } - else - { - m_currentType = TextureType.Texture2D; - } - - ConfigTextureData( m_currentType ); - - //ConfigFromObject( m_defaultValue ); - if( m_materialValue == null ) - { - ConfigFromObject( m_defaultValue ); - } - else - { - CheckTextureImporter( true, true ); - } - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - - public override void ReadAdditionalClipboardData( ref string[] nodeParams ) - { - base.ReadAdditionalClipboardData( ref nodeParams ); - string textureName = GetCurrentParam( ref nodeParams ); - m_materialValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName ); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - WriteAdditionalToString( ref nodeInfo, ref connectionsInfo ); - if( m_useSamplerArrayIdx > 0 ) - { - TexturePropertyNode samplerNode = UIUtils.GetTexturePropertyNode( m_useSamplerArrayIdx - 1 ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( samplerNode != null ? samplerNode.UniqueId : -1 ) ); - } - else - { - IOUtils.AddFieldValueToString( ref nodeInfo, -1 ); - } - } - - public virtual void WriteAdditionalToString( ref string nodeInfo, ref string connectionsInfo ) - { - //IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.GetAssetPath( m_defaultValue ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_defaultValue ) ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_materialValue ) ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_isNormalMap.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autocastMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentType ); - } - - public override void WriteAdditionalClipboardData( ref string nodeInfo ) - { - base.WriteAdditionalClipboardData( ref nodeInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialValue != null ) ? AssetDatabase.GetAssetPath( m_materialValue ) : Constants.NoStringValue ); - } - - public override void Destroy() - { - base.Destroy(); - m_defaultValue = null; - m_materialValue = null; - m_textureProperty = null; - UIUtils.UnregisterPropertyNode( this ); - UIUtils.UnregisterTexturePropertyNode( this ); - } - - public override string GetPropertyValStr() - { - return m_materialMode ? ( m_materialValue != null ? m_materialValue.name : IOUtils.NO_TEXTURES ) : ( m_defaultValue != null ? m_defaultValue.name : IOUtils.NO_TEXTURES ); - } - - public override string GetPropertyValue() - { - switch( m_currentType ) - { - case TextureType.Texture1D: - { - return PropertyAttributes + GetTexture1DPropertyValue(); - } - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - { - return PropertyAttributes + GetTexture2DPropertyValue(); - } - case TextureType.Texture3D: - { - return PropertyAttributes + GetTexture3DPropertyValue(); - } - case TextureType.Cube: - { - return PropertyAttributes + GetCubePropertyValue(); - } - case TextureType.Texture2DArray: - { - return PropertyAttributes + GetTexture2DArrayPropertyValue(); - } - } - return string.Empty; - } - - public override string GetUniformValue() - { - switch( m_currentType ) - { - case TextureType.Texture1D: - { - return GetTexture1DUniformValue(); - } - case TextureType.ProceduralTexture: - case TextureType.Texture2D: - { - return GetTexture2DUniformValue(); - } - case TextureType.Texture3D: - { - return GetTexture3DUniformValue(); - } - case TextureType.Cube: - { - return GetCubeUniformValue(); - } - case TextureType.Texture2DArray: - { - return GetTexture2DArrayUniformValue(); - } - } - - return string.Empty; - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - m_excludeUniform = false; - ParentGraph outsideGraph = UIUtils.CurrentWindow.OutsideGraph; - if( outsideGraph.SamplingThroughMacros ) - { - if( outsideGraph.IsSRP ) - { - if( Constants.TexDeclarationSRPMacros.ContainsKey( m_currentType ) ) - { - if( m_useSamplerArrayIdx == 0 ) - dataName = string.Format( Constants.TexDeclarationSRPMacros[ m_currentType ], PropertyName ); - else - dataName = string.Format( Constants.TexDeclarationNoSamplerSRPMacros[ m_currentType ], PropertyName ); - dataType = string.Empty; - fullValue = true; - return true; - } - } - else if( Constants.TexDeclarationStandardMacros.ContainsKey( m_currentType ) ) - { - if( m_useSamplerArrayIdx == 0 ) - dataName = string.Format( Constants.TexDeclarationStandardMacros[ m_currentType ], PropertyName ); - else - dataName = string.Format( Constants.TexDeclarationNoSamplerStandardMacros[ m_currentType ], PropertyName ); - dataType = string.Empty; - fullValue = true; - return true; - } - } - - if( PropertyName == "_CameraDepthTexture" ) - { - m_excludeUniform = true; - dataType = "UNITY_DECLARE_DEPTH_TEXTURE("; - dataName = m_propertyName + " )"; - return true; - } - - if( m_currentType == TextureType.Texture2DArray ) - { - MasterNode masterNode = UIUtils.CurrentWindow.OutsideGraph.CurrentMasterNode; - if( masterNode.CurrentDataCollector.IsTemplate && masterNode.CurrentDataCollector.IsSRP ) - { - dataType = "TEXTURE2D_ARRAY( " + PropertyName + ""; - dataName = ");\nuniform SAMPLER( sampler" + PropertyName + " )"; - return true; - } - dataType = "UNITY_DECLARE_TEX2DARRAY("; - dataName = m_propertyName + " )"; - return true; - } - - - dataType = UIUtils.TextureTypeToCgType( m_currentType ); - dataName = m_propertyName; - return true; - } - - public virtual string CurrentPropertyReference - { - get - { - string propertyName = string.Empty; - propertyName = PropertyName; - return propertyName; - } - } - - public Texture Value - { - get { return m_materialMode ? m_materialValue : m_defaultValue; } - set - { - if( m_materialMode ) - m_materialValue = value; - else - m_defaultValue = value; - } - } - - public Texture MaterialValue - { - get { return m_materialValue; } - set { m_materialValue = value; } - } - - public Texture DefaultValue - { - get { return m_defaultValue; } - set { m_defaultValue = value; } - } - - public void SetInspectorName( string newName ) - { - m_propertyInspectorName = newName; - } - - public void SetPropertyName( string newName ) - { - m_propertyName = newName; - } - - public bool IsValid { get { return m_materialMode ? ( m_materialValue != null ) : ( m_defaultValue != null ); } } - - public virtual bool IsNormalMap { get { return m_isNormalMap; } } - public bool IsLinearTexture { get { return m_linearTexture; } } - - public override void OnPropertyNameChanged() - { - base.OnPropertyNameChanged(); - UIUtils.UpdateTexturePropertyDataNode( UniqueId, PropertyName ); - } - - public override void SetGlobalValue() { Shader.SetGlobalTexture( m_propertyName, m_defaultValue ); } - public override void FetchGlobalValue() { m_materialValue = Shader.GetGlobalTexture( m_propertyName ); } - public override string DataToArray { get { return PropertyName; } } - public TextureType CurrentType { get { return m_currentType; } } - - public bool DrawAutocast - { - get { return m_drawAutocast; } - set { m_drawAutocast = value; } - } - - public TexturePropertyValues DefaultTextureValue - { - get { return m_defaultTextureValue; } - set { m_defaultTextureValue = value; } - } - - public AutoCastType AutocastMode - { - get { return m_autocastMode; } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs.meta deleted file mode 100644 index 721cc6df..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TexturePropertyNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c1210b3dd22dafe418c5a998df2c3443 -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs deleted file mode 100644 index c35e550d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs +++ /dev/null @@ -1,355 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System; -using System.Collections.Generic; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Texture Transform", "Textures", "Gives access to texture tiling and offset as set on the material inspector" )] - public sealed class TextureTransformNode : ParentNode - { - private readonly string[] Dummy = { string.Empty }; - private const string InstancedLabelStr = "Instanced"; - - [SerializeField] - private bool m_instanced = false; - - [SerializeField] - private int m_referenceSamplerId = -1; - - [SerializeField] - private int m_referenceNodeId = -1; - - [SerializeField] - private TexturePropertyNode m_inputReferenceNode = null; - - private TexturePropertyNode m_referenceNode = null; - - private Vector4Node m_texCoordsHelper; - - 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 ); - AddOutputPort( WirePortDataType.FLOAT2, "Tiling" ); - AddOutputPort( WirePortDataType.FLOAT2, "Offset" ); - m_textLabelWidth = 80; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "25ba2903568b00343ae06788994cab54"; - } - - 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 RenderNodePreview() - { - //Runs at least one time - if( !m_initialized ) - { - // nodes with no preview don't update at all - PreviewIsDirty = false; - return; - } - - if( !PreviewIsDirty ) - return; - - SetPreviewInputs(); - - RenderTexture temp = RenderTexture.active; - - RenderTexture.active = m_outputPorts[ 0 ].OutputPreviewTexture; - PreviewMaterial.SetInt( "_PreviewID", 0 ); - Graphics.Blit( null, m_outputPorts[ 0 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId ); - - RenderTexture.active = m_outputPorts[ 1 ].OutputPreviewTexture; - PreviewMaterial.SetInt( "_PreviewID", 1 ); - Graphics.Blit( null, m_outputPorts[ 1 ].OutputPreviewTexture, PreviewMaterial, m_previewMaterialPassId ); - RenderTexture.active = temp; - - PreviewIsDirty = m_continuousPreviewRefresh; - - FinishPreviewRender = true; - } - - 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 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(); - } - - m_instanced = EditorGUILayoutToggle( InstancedLabelStr, m_instanced ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( !m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - string texTransform = string.Empty; - - if( m_inputPorts[ 0 ].IsConnected ) - { - texTransform = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + "_ST"; - } - else if( m_referenceNode != null ) - { - m_referenceNode.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ); - texTransform = m_referenceNode.PropertyName + "_ST"; - } - else - { - texTransform = "_ST"; - UIUtils.ShowMessage( UniqueId, "Please specify a texture sample on the Texture Transform Size node", MessageSeverity.Warning ); - } - - //bool excludeUniformKeyword = UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader || UIUtils.CurrentWindow.OutsideGraph.IsSRP; - //string uniformRegister = UIUtils.GenerateUniformName( excludeUniformKeyword, WirePortDataType.FLOAT4, texTransform ); - //dataCollector.AddToUniforms( UniqueId, uniformRegister, true ); - if( m_texCoordsHelper == null ) - { - m_texCoordsHelper = CreateInstance<Vector4Node>(); - m_texCoordsHelper.ContainerGraph = ContainerGraph; - m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ); - m_texCoordsHelper.RegisterPropertyOnInstancing = false; - m_texCoordsHelper.AddGlobalToSRPBatcher = true; - } - - if( m_instanced ) - { - m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty; - } - else - { - m_texCoordsHelper.CurrentParameterType = PropertyType.Global; - } - m_texCoordsHelper.ResetOutputLocals(); - m_texCoordsHelper.SetRawPropertyName( texTransform ); - texTransform = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ); - - m_outputPorts[ 0 ].SetLocalValue( texTransform+ ".xy", dataCollector.PortCategory ); - m_outputPorts[ 1 ].SetLocalValue( texTransform + ".zw", dataCollector.PortCategory ); - } - - return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ); - } - - 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(); - m_referenceNode = UIUtils.GetNode( m_referenceNodeId ) as TexturePropertyNode; - m_referenceSamplerId = UIUtils.GetTexturePropertyNodeRegisterId( m_referenceNodeId ); - UpdateTitle(); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 17200 ) - { - m_instanced = 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_referenceNodeId ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_instanced ); - } - - public override void Destroy() - { - base.Destroy(); - m_referenceNode = null; - m_inputReferenceNode = null; - m_upperLeftWidget = null; - if( m_texCoordsHelper != null ) - { - //Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff - DestroyImmediate( m_texCoordsHelper ); - m_texCoordsHelper = null; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs.meta deleted file mode 100644 index be1ce29d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TextureTransformNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4f9ca941b3f5014448e530c761a418d9 -timeCreated: 1512045037 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs deleted file mode 100644 index 364cfcca..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -namespace AmplifyShaderEditor -{ - [NodeAttributes( "Unpack Scale Normal", "Textures", "Applies UnpackNormal/UnpackScaleNormal function" )] - [Serializable] - public class UnpackScaleNormalNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT4, false, "Value" ); - AddInputPort( WirePortDataType.FLOAT, false, "Scale" ); - m_inputPorts[ 1 ].FloatInternalData = 1; - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_useInternalPortData = true; - m_previewShaderGUID = "8b0ae05e25d280c45af81ded56f8012e"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string src = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - - bool isScaledNormal = false; - if ( m_inputPorts[ 1 ].IsConnected ) - { - isScaledNormal = true; - } - else - { - if ( m_inputPorts[ 1 ].FloatInternalData != 1 ) - { - isScaledNormal = true; - } - } - - string normalMapUnpackMode = string.Empty; - string scaleValue = isScaledNormal?m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):"1.0"; - normalMapUnpackMode = string.Format( TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, isScaledNormal, scaleValue ), src); - if( isScaledNormal && !( dataCollector.IsTemplate && dataCollector.IsSRP ) ) - { - dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ); - } - - int outputUsage = 0; - for ( int i = 0; i < m_outputPorts.Count; i++ ) - { - if ( m_outputPorts[ i ].IsConnected ) - outputUsage += 1; - } - - - if ( outputUsage > 1 ) - { - string varName = "localUnpackNormal" + OutputId; - dataCollector.AddLocalVariable( UniqueId, "float3 " + varName + " = " + normalMapUnpackMode + ";" ); - return GetOutputVectorItem( 0, outputId, varName ); - } - else - { - return GetOutputVectorItem( 0, outputId, normalMapUnpackMode ); - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs.meta deleted file mode 100644 index 270e519f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/UnpackScaleNormalNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ad04713692e9f124e86030d792c3e648 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs deleted file mode 100644 index 339cdc24..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs +++ /dev/null @@ -1,296 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using UnityEditor; -using System; - -namespace AmplifyShaderEditor -{ - public enum VirtualPreset - { - Unity_Legacy, - Unity5, - Alloy, - UBER, - Skyshop, - Lux - } - - public enum VirtualChannel - { - Albedo = 0, - Base, - Normal, - Height, - Occlusion, - Displacement, - Specular, - SpecMet, - Material, - } - - [Serializable] - [NodeAttributes( "Virtual Texture Object", "Textures", "Represents a Virtual Texture Asset", SortOrderPriority = 1 )] - public class VirtualTextureObject : TexturePropertyNode - { - protected const string VirtualPresetStr = "Layout Preset"; - protected const string VirtualChannelStr = "Virtual Layer"; - - private const string VirtualTextureObjectInfo = "Can only be used alongside a Texture Sample node by connecting to its Tex Input Port.\n" + - "\nProperty name must match the value set on your Virtual Texture.\n" + - "Default e.g Albedo = _MainTex\n" + - "\nName your node according to the respective channel property in your Virtual Texture. The Albedo must be set to _MainTex ( temporary requirement )."; - private readonly string[] ChannelTypeStr = { - "Albedo - D.RGBA", - "Base - D.RGBA", - "Normal - N.GA", - "Height - N.B", - "Occlusion - N.R", - "Displacement - N.B", - "Specular - S.RGBA", - "Specular|Metallic - S.RGBA", - "Material - S.RGBA",}; - - private readonly string[] Dummy = { string.Empty }; - private string[] m_channelTypeStr; - - [SerializeField] - protected VirtualPreset m_virtualPreset = VirtualPreset.Unity5; - - [SerializeField] - protected VirtualChannel m_virtualChannel = VirtualChannel.Albedo; - - [SerializeField] - private int m_selectedChannelInt = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - ChangeChannels(); - } - - protected override void OnUniqueIDAssigned() - { - base.OnUniqueIDAssigned(); - if ( UniqueId != -1 ) - UIUtils.AddVirtualTextureCount(); - } - - public override void DrawSubProperties() - { - ShowDefaults(); - - base.DrawSubProperties(); - } - - public override void DrawMaterialProperties() - { - ShowDefaults(); - - base.DrawMaterialProperties(); - } - - new void ShowDefaults() - { - EditorGUI.BeginChangeCheck(); - m_virtualPreset = ( VirtualPreset ) EditorGUILayoutEnumPopup( VirtualPresetStr, m_virtualPreset ); - if ( EditorGUI.EndChangeCheck() ) - { - ChangeChannels(); - } - - EditorGUI.BeginChangeCheck(); - m_selectedChannelInt = EditorGUILayoutPopup( VirtualChannelStr, m_selectedChannelInt, m_channelTypeStr ); - if ( EditorGUI.EndChangeCheck() ) - { - m_virtualChannel = GetChannel( m_selectedChannelInt ); - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUILayout.HelpBox( VirtualTextureObjectInfo, MessageType.Info ); - } - - private VirtualChannel GetChannel( int popupInt ) - { - int remapInt = 0; - switch ( m_virtualPreset ) - { - case VirtualPreset.Unity_Legacy: - remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 4 : popupInt == 3 ? 5 : 0; - break; - default: - case VirtualPreset.Unity5: - case VirtualPreset.UBER: - remapInt = popupInt == 0 ? 0 : popupInt == 1 ? 7 : popupInt == 2 ? 2 : popupInt == 3 ? 3 : popupInt == 4 ? 4 : 0; - break; - case VirtualPreset.Alloy: - remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 8 : popupInt == 3 ? 3 : 0; - break; - case VirtualPreset.Skyshop: - case VirtualPreset.Lux: - remapInt = popupInt == 0 ? 1 : popupInt == 1 ? 2 : popupInt == 2 ? 6 : 0; - break; - } - - return ( VirtualChannel ) remapInt; - } - - private void ChangeChannels() - { - m_channelTypeStr = Dummy; - switch ( m_virtualPreset ) - { - case VirtualPreset.Unity_Legacy: - m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 4 ], ChannelTypeStr[ 5 ] }; - break; - default: - case VirtualPreset.Unity5: - case VirtualPreset.UBER: - m_channelTypeStr = new string[] { ChannelTypeStr[ 0 ], ChannelTypeStr[ 7 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 3 ], ChannelTypeStr[ 4 ] }; - break; - case VirtualPreset.Alloy: - m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 8 ], ChannelTypeStr[ 3 ] }; - break; - case VirtualPreset.Skyshop: - case VirtualPreset.Lux: - m_channelTypeStr = new string[] { ChannelTypeStr[ 1 ], ChannelTypeStr[ 2 ], ChannelTypeStr[ 6 ] }; - break; - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - dataCollector.AddToProperties( UniqueId, "[HideInInspector] _VTInfoBlock( \"VT( auto )\", Vector ) = ( 0, 0, 0, 0 )", -1 ); - - return PropertyName; - } - - public override string GetPropertyValue() - { - string propertyValue = string.Empty; - switch ( m_virtualChannel ) - { - default: - case VirtualChannel.Albedo: - case VirtualChannel.Base: - propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}"; - break; - case VirtualChannel.Normal: - propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}"; - break; - case VirtualChannel.SpecMet: - propertyValue = PropertyName + "(\"" + m_propertyInspectorName + "\", 2D) = \"" + m_defaultTextureValue + "\" {}"; - break; - } - return PropertyAttributes + propertyValue; - } - - public override string GetUniformValue() - { - return "uniform sampler2D " + PropertyName + ";"; - } - - public override bool GetUniformData( out string dataType, out string dataName, ref bool fullValue ) - { - dataType = "sampler2D"; - dataName = PropertyName; - return true; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - string defaultTextureGUID = GetCurrentParam( ref nodeParams ); - //m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName ); - if( UIUtils.CurrentShaderVersion() > 14101 ) - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( defaultTextureGUID ) ); - string materialTextureGUID = GetCurrentParam( ref nodeParams ); - m_materialValue = AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( materialTextureGUID ) ); - } - else - { - m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( defaultTextureGUID ); - } - m_isNormalMap = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - m_defaultTextureValue = ( TexturePropertyValues ) Enum.Parse( typeof( TexturePropertyValues ), GetCurrentParam( ref nodeParams ) ); - m_autocastMode = ( AutoCastType ) Enum.Parse( typeof( AutoCastType ), GetCurrentParam( ref nodeParams ) ); - m_virtualPreset = ( VirtualPreset ) Enum.Parse( typeof( VirtualPreset ), GetCurrentParam( ref nodeParams ) ); - m_selectedChannelInt = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - ChangeChannels(); - m_virtualChannel = GetChannel( m_selectedChannelInt ); - - //m_forceNodeUpdate = true; - - //ConfigFromObject( m_defaultValue ); - if( m_materialValue == null ) - { - ConfigFromObject( m_defaultValue ); - } - else - { - CheckTextureImporter( true, true ); - } - ConfigureInputPorts(); - ConfigureOutputPorts(); - } - - public override void ReadAdditionalData( ref string[] nodeParams ) { } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - //IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.GetAssetPath( m_defaultValue ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_defaultValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_defaultValue ) ) : Constants.NoStringValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, ( m_materialValue != null ) ? AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_materialValue ) ) : Constants.NoStringValue ); - - IOUtils.AddFieldValueToString( ref nodeInfo, m_isNormalMap.ToString() ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_defaultTextureValue ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_autocastMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_virtualPreset ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_selectedChannelInt ); - } - - public override void WriteAdditionalToString( ref string nodeInfo, ref string connectionsInfo ) { } - - //public override string PropertyName - //{ - // get - // { - // string propertyName = string.Empty; - // switch ( m_virtualChannel ) - // { - // default: - // case VirtualChannel.Albedo: - // case VirtualChannel.Base: - // propertyName = "_MainTex"; - // break; - // case VirtualChannel.Normal: - // propertyName = "_BumpMap"; - // break; - // case VirtualChannel.SpecMet: - // propertyName = "_MetallicGlossMap"; - // break; - // case VirtualChannel.Occlusion: - // propertyName = "_OcclusionMap"; - // break; - // } - // return propertyName; - // } - //} - - public override void Destroy() - { - base.Destroy(); - UIUtils.RemoveVirtualTextureCount(); - } - - public override bool IsNormalMap { get { return m_isNormalMap || m_virtualChannel == VirtualChannel.Normal; } } - public VirtualChannel Channel { get { return m_virtualChannel; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs.meta deleted file mode 100644 index f2719119..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/VirtualTextureObject.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bacb12043c5bc504aa49e0a5a9bbc534 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs deleted file mode 100644 index 4b6dc9af..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs +++ /dev/null @@ -1,692 +0,0 @@ -using UnityEditor; -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - public class UndoParentNode : ScriptableObject - { - private const string MessageFormat = "Changing value {0} on node {1}"; - - [SerializeField] - protected NodeAttributes m_nodeAttribs; - - [SerializeField] - protected ParentGraph m_containerGraph; - - public void UndoRecordObject( string name ) - { - UIUtils.MarkUndoAction(); - Undo.RegisterCompleteObjectUndo( UIUtils.CurrentWindow, name ); - Undo.RecordObject( this, name ); - } - - public virtual void RecordObject( string Id ) - { - Undo.RecordObject( this, Id ); - } - public virtual void RecordObjectOnDestroy( string Id ) - { - Undo.RecordObject( this, Id ); - } - - public string EditorGUILayoutStringField( string name, string value, params GUILayoutOption[] options ) - { - string newValue = EditorGUILayout.TextField( name, value, options ); - if( !newValue.Equals( value ) ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUILayoutStringField", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string EditorGUILayoutTextField( GUIContent label, string text, params GUILayoutOption[] options ) - { - string newValue = EditorGUILayout.TextField( label, text, options ); - if( !text.Equals( newValue ) ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string EditorGUILayoutTextField( string label, string text, params GUILayoutOption[] options ) - { - string newValue = EditorGUILayout.TextField( label, text, options ); - if( !text.Equals( newValue ) ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Enum EditorGUILayoutEnumPopup( GUIContent label, Enum selected, params GUILayoutOption[] options ) - { - Enum newValue = EditorGUILayout.EnumPopup( label, selected, options ); - if( !newValue.ToString().Equals( selected.ToString() ) ) - { - UndoRecordObject( string.Concat( "Changing value ", label, " on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - //UndoRecordObject(string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Enum EditorGUILayoutEnumPopup( string label, Enum selected, params GUILayoutOption[] options ) - { - Enum newValue = EditorGUILayout.EnumPopup( label, selected, options ); - if( !newValue.ToString().Equals( selected.ToString() ) ) - { - UndoRecordObject( string.Concat( "Changing value ", label, " on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - //UndoRecordObject(string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Enum EditorGUILayoutEnumPopup( Enum selected, params GUILayoutOption[] options ) - { - Enum newValue = EditorGUILayout.EnumPopup( selected, options ); - if( !newValue.ToString().Equals( selected.ToString() ) ) - { - UndoRecordObject( string.Concat( "Changing value EditorGUILayoutEnumPopup on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - //UndoRecordObject(string.Format( MessageFormat, "EditorGUILayoutEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntPopup( string label, int selectedValue, string[] displayedOptions, int[] optionValues, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntPopup( label, selectedValue, displayedOptions, optionValues, options ); - if( newValue != selectedValue ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - - public int EditorGUILayoutPopup( string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, style, options ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - - public int EditorGUILayoutPopup( GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, options ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutPopup( GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, style, options ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutPopup( int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.Popup( selectedIndex, displayedOptions, options ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUILayoutPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutPopup( string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.Popup( label, selectedIndex, displayedOptions, options ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutToggle( GUIContent label, bool value, params GUILayoutOption[] options ) - { - bool newValue = EditorGUILayout.Toggle( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutToggle( string label, bool value, params GUILayoutOption[] options ) - { - bool newValue = EditorGUILayout.Toggle( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutToggle( string label, bool value, GUIStyle style, params GUILayoutOption[] options ) - { - bool newValue = EditorGUILayout.Toggle( label, value, style, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntField( int value, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntField( value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUILayoutIntField", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntField( GUIContent label, int value, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntField( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntField( string label, int value, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntField( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUILayoutFloatField( GUIContent label, float value, params GUILayoutOption[] options ) - { - float newValue = EditorGUILayout.FloatField( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUILayoutFloatField( string label, float value, params GUILayoutOption[] options ) - { - float newValue = EditorGUILayout.FloatField( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUILayoutRangedFloatField( string label, float value, float min, float max, params GUILayoutOption[] options ) - { - float newValue = Mathf.Clamp( EditorGUILayout.FloatField( label, value, options ), min, max ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Color EditorGUILayoutColorField( string label, Color value, params GUILayoutOption[] options ) - { - Color newValue = EditorGUILayout.ColorField( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#if UNITY_2018_1_OR_NEWER - public Color EditorGUILayoutColorField( GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, params GUILayoutOption[] options ) - { - Color newValue = EditorGUILayout.ColorField( label, value, showEyedropper, showAlpha, hdr, options ); - if( newValue != value ) - { - UndoRecordObject(string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#else - public Color EditorGUILayoutColorField( GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig, params GUILayoutOption[] options ) - { - Color newValue = EditorGUILayout.ColorField( label, value, showEyedropper, showAlpha, hdr, hdrConfig, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#endif - public float EditorGUILayoutSlider( string label, float value, float leftValue, float rightValue, params GUILayoutOption[] options ) - { - float newValue = EditorGUILayout.Slider( label, value, leftValue, rightValue, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUILayoutSlider( GUIContent label, float value, float leftValue, float rightValue, params GUILayoutOption[] options ) - { - float newValue = EditorGUILayout.Slider( label, value, leftValue, rightValue, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - public UnityEngine.Object EditorGUILayoutObjectField( string label, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects, params GUILayoutOption[] options ) - { - UnityEngine.Object newValue = EditorGUILayout.ObjectField( label, obj, objType, allowSceneObjects, options ); - if( newValue != obj ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Vector2 EditorGUIVector2Field( Rect position, string label, Vector2 value ) - { - Vector2 newValue = EditorGUI.Vector2Field( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - - public Vector2 EditorGUILayoutVector2Field( string label, Vector2 value, params GUILayoutOption[] options ) - { - Vector2 newValue = EditorGUILayout.Vector2Field( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Vector3 EditorGUIVector3Field( Rect position, string label, Vector3 value ) - { - Vector3 newValue = EditorGUI.Vector3Field( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Vector3 EditorGUILayoutVector3Field( string label, Vector3 value, params GUILayoutOption[] options ) - { - Vector3 newValue = EditorGUILayout.Vector3Field( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Vector4 EditorGUIVector4Field( Rect position, string label, Vector4 value ) - { - Vector4 newValue = EditorGUI.Vector4Field( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Vector4 EditorGUILayoutVector4Field( string label, Vector4 value, params GUILayoutOption[] options ) - { - Vector4 newValue = EditorGUILayout.Vector4Field( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntSlider( GUIContent label, int value, int leftValue, int rightValue, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntSlider( label, value, leftValue, rightValue, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUILayoutIntSlider( string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options ) - { - int newValue = EditorGUILayout.IntSlider( label, value, leftValue, rightValue, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutToggleLeft( string label, bool value, params GUILayoutOption[] options ) - { - bool newValue = EditorGUILayout.ToggleLeft( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutToggleLeft( GUIContent label, bool value, params GUILayoutOption[] options ) - { - bool newValue = EditorGUILayout.ToggleLeft( label, value, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string EditorGUILayoutTextArea( string text, GUIStyle style, params GUILayoutOption[] options ) - { - string newValue = EditorGUILayout.TextArea( text, style, options ); - if( !newValue.Equals( text ) ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUILayoutTextArea", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUILayoutFoldout( bool foldout, string content ) - { - bool newValue = EditorGUILayout.Foldout( foldout, content ); - if( newValue != foldout ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUILayoutFoldout", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUIFoldout( Rect position, bool foldout, string content ) - { - bool newValue = EditorGUI.Foldout( position, foldout, content ); - if( newValue != foldout ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIFoldout", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string EditorGUITextField( Rect position, string label, string text ) - { - string newValue = EditorGUI.TextField( position, label, text ); - if( !newValue.Equals( text ) ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string EditorGUITextField( Rect position, string label, string text, [UnityEngine.Internal.DefaultValue( "EditorStyles.textField" )] GUIStyle style ) - { - string newValue = EditorGUI.TextField( position, label, text, style ); - if( !newValue.Equals( text ) ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#if UNITY_2018_1_OR_NEWER - public Color EditorGUIColorField( Rect position, GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr ) - { - Color newValue = EditorGUI.ColorField( position, label, value, showEyedropper, showAlpha, hdr ); - if( newValue != value ) - { - UndoRecordObject(string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#else - public Color EditorGUIColorField( Rect position, GUIContent label, Color value, bool showEyedropper, bool showAlpha, bool hdr, ColorPickerHDRConfig hdrConfig ) - { - Color newValue = EditorGUI.ColorField( position, label, value, showEyedropper, showAlpha, hdr, hdrConfig ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } -#endif - public Color EditorGUIColorField( Rect position, string label, Color value ) - { - Color newValue = EditorGUI.ColorField( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - - public int EditorGUIIntField( Rect position, string label, int value ) - { - int newValue = EditorGUI.IntField( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUIIntField( Rect position, string label, int value, [UnityEngine.Internal.DefaultValue( "EditorStyles.numberField" )] GUIStyle style ) - { - int newValue = EditorGUI.IntField( position, label, value, style ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUIFloatField( Rect position, string label, float value ) - { - float newValue = EditorGUI.FloatField( position, label, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUIFloatField( Rect position, string label, float value, [UnityEngine.Internal.DefaultValue( "EditorStyles.numberField" )] GUIStyle style ) - { - float newValue = EditorGUI.FloatField( position, label, value, style ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, label, ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float EditorGUIFloatField( Rect position, float value, [UnityEngine.Internal.DefaultValue( "EditorStyles.numberField" )] GUIStyle style ) - { - float newValue = EditorGUI.FloatField( position, value, style ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIFloatField", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public float GUIHorizontalSlider( Rect position, float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb ) - { - float newValue = GUI.HorizontalSlider( position, value, leftValue, rightValue, slider, thumb ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "GUIHorizontalSlider", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Enum EditorGUIEnumPopup( Rect position, Enum selected ) - { - Enum newValue = EditorGUI.EnumPopup( position, selected ); - if( !newValue.ToString().Equals( selected.ToString() ) ) - { - UndoRecordObject( string.Concat( "Changing value EditorGUIEnumPopup on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - //UndoRecordObject(string.Format( MessageFormat, "EditorGUIEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public Enum EditorGUIEnumPopup( Rect position, Enum selected, [UnityEngine.Internal.DefaultValue( "EditorStyles.popup" )] GUIStyle style ) - { - Enum newValue = EditorGUI.EnumPopup( position, selected, style ); - if( !newValue.ToString().Equals( selected.ToString() ) ) - { - UndoRecordObject( string.Concat( "Changing value EditorGUIEnumPopup on node ", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - //UndoRecordObject(string.Format( MessageFormat, "EditorGUIEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUIIntPopup( Rect position, int selectedValue, GUIContent[] displayedOptions, int[] optionValues, [UnityEngine.Internal.DefaultValue( "EditorStyles.popup" )] GUIStyle style ) - { - int newValue = EditorGUI.IntPopup( position, selectedValue, displayedOptions, optionValues, style ); - if( newValue != selectedValue ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIIntEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUIPopup( Rect position, string label, int selectedIndex, string[] displayedOptions ) - { - int newValue = EditorGUI.Popup( position, label, selectedIndex, displayedOptions ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUIPopup( Rect position, int selectedIndex, GUIContent[] displayedOptions, [UnityEngine.Internal.DefaultValue( "EditorStyles.popup" )] GUIStyle style ) - { - int newValue = EditorGUI.Popup( position, selectedIndex, displayedOptions, style ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public int EditorGUIPopup( Rect position, int selectedIndex, string[] displayedOptions, [UnityEngine.Internal.DefaultValue( "EditorStyles.popup" )] GUIStyle style ) - { - int newValue = EditorGUI.Popup( position, selectedIndex, displayedOptions, style ); - if( newValue != selectedIndex ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIEnumPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public UnityEngine.Object EditorGUIObjectField( Rect position, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects ) - { - UnityEngine.Object newValue = EditorGUI.ObjectField( position, obj, objType, allowSceneObjects ); - if( newValue != obj ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIObjectField", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - public int EditorGUIIntPopup( Rect position, int selectedValue, string[] displayedOptions, int[] optionValues, [UnityEngine.Internal.DefaultValue( "EditorStyles.popup" )] GUIStyle style ) - { - int newValue = EditorGUI.IntPopup( position, selectedValue, displayedOptions, optionValues, style ); - if( newValue != selectedValue ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIIntPopup", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUIToggle( Rect position, bool value ) - { - bool newValue = EditorGUI.Toggle( position, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIToggle", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool EditorGUIToggle( Rect position, string text, bool value ) - { - bool newValue = EditorGUI.Toggle( position,text, value ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "EditorGUIToggle", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public string GUITextField( Rect position, string text, GUIStyle style ) - { - string newValue = GUI.TextField( position, text, style ); - if( !newValue.Equals( text ) ) - { - UndoRecordObject( string.Format( MessageFormat, "GUITextfield", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - - public bool GUILayoutToggle( bool value, string text, GUIStyle style, params GUILayoutOption[] options ) - { - bool newValue = GUILayout.Toggle( value, text, style, options ); - if( newValue != value ) - { - UndoRecordObject( string.Format( MessageFormat, "GUILayoutToggle", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return newValue; - } - - public bool GUILayoutButton( string text, GUIStyle style, params GUILayoutOption[] options ) - { - bool value = GUILayout.Button( text, style, options ); - if( value ) - { - UndoRecordObject( string.Format( MessageFormat, "GUILayoutButton", ( ( m_nodeAttribs != null ) ? m_nodeAttribs.Name : GetType().ToString() ) ) ); - } - return value; - } - - /// <summary> - /// It's the graph the node exists in, this is set after node creation and it's not available on CommonInit - /// </summary> - public ParentGraph ContainerGraph - { - get { return m_containerGraph; } - set { m_containerGraph = value; } - } - } -} - diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs.meta deleted file mode 100644 index f320dc17..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/UndoParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: bcc69b2f388d45f43a9157ce814b5aae -timeCreated: 1490183752 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex.meta deleted file mode 100644 index 9c22229c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 579ecde4d9d1a0e45a655588b39f457a -folderAsset: yes -timeCreated: 1481126945 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs deleted file mode 100644 index 0cb8787a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Billboard", "Miscellaneous", "Calculates new Vertex positions and normals to achieve a billboard effect." )] - public sealed class BillboardNode : ParentNode - { - private const string ErrorMessage = "Billboard node should only be connected to vertex ports."; - private const string WarningMessage = "This node is a bit different from all others as it injects the necessary code into the vertex body and writes directly on the vertex position and normal.\nIt outputs a value of 0 so it can be connected directly to a vertex port.\n[Only if that port is a relative vertex offset]."; - - [SerializeField] - private BillboardType m_billboardType = BillboardType.Cylindrical; - - [SerializeField] - private bool m_rotationIndependent = false; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputPort( WirePortDataType.FLOAT3, "Out" ); - m_textLabelWidth = 115; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_billboardType ) ); - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - 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 Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - m_upperLeftWidget.DrawWidget<BillboardType>( ref m_billboardType, this, OnWidgetUpdate ); - } - - private readonly Action<ParentNode> OnWidgetUpdate = ( x ) => - { - x.SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, ( x as BillboardNode ).Type ) ); - }; - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, () => - { - EditorGUI.BeginChangeCheck(); - m_billboardType = (BillboardType)EditorGUILayoutEnumPopup( BillboardOpHelper.BillboardTypeStr, m_billboardType ); - if( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_billboardType ) ); - } - m_rotationIndependent = EditorGUILayoutToggle( BillboardOpHelper.BillboardRotIndStr, m_rotationIndependent ); - } ); - EditorGUILayout.HelpBox( WarningMessage, MessageType.Warning ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsFragmentCategory ) - { - UIUtils.ShowMessage( UniqueId, ErrorMessage,MessageSeverity.Error ); - return m_outputPorts[0].ErrorValue; - } - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].ErrorValue; - - m_outputPorts[ 0 ].SetLocalValue( "0", dataCollector.PortCategory ); - string vertexPosValue = dataCollector.IsTemplate ? dataCollector.TemplateDataCollectorInstance.GetVertexPosition( WirePortDataType.OBJECT, CurrentPrecisionType ) : "v.vertex"; - string vertexNormalValue = dataCollector.IsTemplate ? dataCollector.TemplateDataCollectorInstance.GetVertexNormal( CurrentPrecisionType ) : "v.normal"; - bool vertexIsFloat3 = false; - if( dataCollector.IsTemplate ) - { - InterpDataHelper info = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.POSITION ); - if( info != null ) - { - vertexIsFloat3 = info.VarType == WirePortDataType.FLOAT3; - } - } - - BillboardOpHelper.FillDataCollector( ref dataCollector, m_billboardType, m_rotationIndependent, vertexPosValue, vertexNormalValue, vertexIsFloat3 ); - - return "0"; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_billboardType = (BillboardType)Enum.Parse( typeof( BillboardType ), GetCurrentParam( ref nodeParams ) ); - m_rotationIndependent = 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_billboardType ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_rotationIndependent ); - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, m_billboardType ) ); - } - - public BillboardType Type { get { return m_billboardType; } } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs.meta deleted file mode 100644 index 7b2c540b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BillboardNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 08fd3dd8f623aca42b7eb9962a89753d -timeCreated: 1501161489 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs deleted file mode 100644 index 828a4993..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vertex Bitangent", "Vertex Data", "Calculated bitangent vector in object space, can be used in both local vertex offset and fragment outputs. Already has tangent sign and object transform into account" )] - public sealed class BitangentVertexDataNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "76873532ab67d2947beaf07151383cbe"; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if ( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - dataCollector.ForceNormal = true; - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - string vertexBitangent = GeneratorUtils.GenerateVertexBitangent( ref dataCollector, UniqueId, CurrentPrecisionType ); - return GetOutputVectorItem( 0, outputId, vertexBitangent ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs.meta deleted file mode 100644 index 1c5ff97a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/BitangentVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 839ecbdfc8ed4fd4d8a08ec07f7159fa -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs deleted file mode 100644 index 0cea1618..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "[VS] Vertex Color", "Vertex Data", "Vertex color. Only works on Vertex Shaders ports ( p.e. Local Vertex Offset Port ).", null,KeyCode.None,true,true,"Vertex Color",typeof(VertexColorNode))] - public sealed class ColorVertexDataNode : VertexDataNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "color"; - ConvertFromVectorToColorPorts(); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs.meta deleted file mode 100644 index b8990fe9..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ColorVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ca76669baa9fa204b8ce5200eb07c1db -timeCreated: 1481126959 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs deleted file mode 100644 index b5fc4b5f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vertex Normal", "Vertex Data", "Vertex normal vector in object space, can be used in both local vertex offset and fragment outputs" )] - public sealed class NormalVertexDataNode : VertexDataNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "normal"; - ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 ); - m_outputPorts[ 4 ].Visible = false; - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "6b24b06c33f9fe84c8a2393f13ab5406"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - string vertexNormal = string.Empty; - - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - vertexNormal = dataCollector.TemplateDataCollectorInstance.GetVertexNormal( CurrentPrecisionType ); - return GetOutputVectorItem( 0, outputId, vertexNormal ); - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - if( dataCollector.DirtyNormal ) - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - dataCollector.ForceNormal = true; - } - } - - vertexNormal = GeneratorUtils.GenerateVertexNormal( ref dataCollector, UniqueId, CurrentPrecisionType ); - return GetOutputVectorItem( 0, outputId, vertexNormal ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs.meta deleted file mode 100644 index 62b8c9d6..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/NormalVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4c7b60515f9cf6043bf8d03531d268f9 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs deleted file mode 100644 index 6dd1b8d3..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Object Scale", "Vertex Data", "Object Scale extracted directly from its transform matrix" )] - public class ObjectScaleNode : ParentNode - { - private const string RotationIndependentScaleStr = "Rotation Independent Scale"; - - [SerializeField] - private bool m_rotationIndependentScale = false; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "5540033c6c52f51468938c1a42bd2730"; - m_textLabelWidth = 180; - UpdateMaterialPass(); - m_autoWrapProperties = true; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_rotationIndependentScale = EditorGUILayoutToggle( RotationIndependentScaleStr, m_rotationIndependentScale ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateMaterialPass(); - } - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - string objectScale = m_rotationIndependentScale ? GeneratorUtils.GenerateRotationIndependentObjectScale( ref dataCollector, UniqueId ): - GeneratorUtils.GenerateObjectScale( ref dataCollector, UniqueId ); - - return GetOutputVectorItem( 0, outputId, objectScale ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() < 17402 ) - { - m_rotationIndependentScale = false; - } - else - { - m_rotationIndependentScale = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - } - UpdateMaterialPass(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_rotationIndependentScale ); - } - - void UpdateMaterialPass() - { - m_previewMaterialPassId = m_rotationIndependentScale ? 1 : 0; - PreviewIsDirty = true; - } - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs.meta deleted file mode 100644 index 7103bef2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/ObjectScaleNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ef1fe46d0cc472e45ad13ac737db2c1e -timeCreated: 1493993914 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs deleted file mode 100644 index cec8fb39..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs +++ /dev/null @@ -1,366 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; - -using UnityEngine; -using UnityEditor; -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Outline", "Miscellaneous", "Uses vertices to simulate an outline around the object" )] - public sealed class OutlineNode : ParentNode - { - enum OutlineAlphaModes - { - None = 0, - Masked, - Transparent, - AlphaPremultiplied - }; - - private const string CullModePortNameStr = "Cull Mode"; - private const string AlphaModePortNameStr = "Alpha"; - private const string MaskedModePortNamStr = "Opacity Mask"; - private const string OutlineAlphaModeStr = "Alpha Mode"; - private const string OpacityMaskClipValueStr = "Mask Clip Value"; - private const string ErrorMessage = "Outline node should only be connected to vertex ports."; - - [SerializeField] - private bool m_noFog = true; - - [SerializeField] - private string[] AvailableOutlineModes = { "Vertex Offset", "Vertex Scale", "Custom" }; - - [SerializeField] - private int[] AvailableOutlineValues = { 0, 1, 2 }; - - [SerializeField] - private int m_currentSelectedMode = 0; - - [SerializeField] - private OutlineAlphaModes m_currentAlphaMode = OutlineAlphaModes.None; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - [NonSerialized] - private StandardSurfaceOutputNode m_masterNode = null; - - [SerializeField] - private int m_zTestMode = 0; - - [SerializeField] - private int m_zWriteMode = 0; - - [SerializeField] - private CullMode m_cullMode = CullMode.Front; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - - AddOutputPort( WirePortDataType.FLOAT3, "Out" ); - - AddInputPort( WirePortDataType.FLOAT3, false, "Color", -1, MasterNodePortCategory.Fragment, 0 ); - AddInputPort( WirePortDataType.FLOAT, false, "Alpha", -1, MasterNodePortCategory.Fragment, 2 ); - AddInputPort( WirePortDataType.FLOAT, false, "Width", -1, MasterNodePortCategory.Fragment, 1 ); - GetInputPortByUniqueId( 2 ).Visible = false; - m_textLabelWidth = 115; - m_hasLeftDropdown = true; - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, AvailableOutlineModes[ m_currentSelectedMode ] ) ); - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( GetInputPortByUniqueId( 0 ).IsConnected ) - dataCollector.UsingCustomOutlineColor = true; - - if( GetInputPortByUniqueId( 1 ).IsConnected ) - dataCollector.UsingCustomOutlineWidth = true; - - if( GetInputPortByUniqueId( 2 ).IsConnected ) - dataCollector.UsingCustomOutlineAlpha = true; - - if( !dataCollector.IsTemplate ) - { - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.ZWriteMode = m_zWriteMode; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.OffsetMode = m_currentSelectedMode; - } - } - - 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_currentSelectedMode = m_upperLeftWidget.DrawWidget( this, m_currentSelectedMode, AvailableOutlineModes ); - if( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, AvailableOutlineModes[ m_currentSelectedMode ] ) ); - UpdatePorts(); - } - } - - void CheckAlphaPortVisibility() - { - InputPort alphaPort = GetInputPortByUniqueId( 2 ); - if( m_currentAlphaMode != OutlineAlphaModes.None ) - { - if( !alphaPort.Visible ) - alphaPort.Visible = true; - - if( m_currentAlphaMode == OutlineAlphaModes.Masked ) - { - GetInputPortByUniqueId( 2 ).Name = MaskedModePortNamStr; - } - else - { - GetInputPortByUniqueId( 2 ).Name = AlphaModePortNameStr; - } - m_sizeIsDirty = true; - } - - if( m_currentAlphaMode == OutlineAlphaModes.None && alphaPort.Visible ) - { - alphaPort.Visible = false; - m_sizeIsDirty = true; - } - } - - public override void DrawProperties() - { - base.DrawProperties(); - NodeUtils.DrawPropertyGroup( ref m_propertiesFoldout, Constants.ParameterLabelStr, () => - { - EditorGUI.BeginChangeCheck(); - m_currentSelectedMode = EditorGUILayoutIntPopup( "Type", m_currentSelectedMode, AvailableOutlineModes, AvailableOutlineValues ); - if( EditorGUI.EndChangeCheck() ) - { - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, AvailableOutlineModes[ m_currentSelectedMode ] ) ); - UpdatePorts(); - } - - EditorGUI.BeginChangeCheck(); - m_currentAlphaMode = (OutlineAlphaModes)EditorGUILayoutEnumPopup( OutlineAlphaModeStr, m_currentAlphaMode ); - if( EditorGUI.EndChangeCheck() ) - { - CheckAlphaPortVisibility(); - } - - if( m_currentAlphaMode == OutlineAlphaModes.Masked ) - { - if( m_masterNode == null ) - { - m_masterNode = UIUtils.CurrentWindow.OutsideGraph.CurrentMasterNode as StandardSurfaceOutputNode; - } - - if( m_masterNode != null ) - { - m_masterNode.ShowOpacityMaskValueUI(); - } - } - - m_cullMode = (CullMode)EditorGUILayoutEnumPopup( CullModePortNameStr, m_cullMode ); - m_zWriteMode = EditorGUILayoutPopup( ZBufferOpHelper.ZWriteModeStr, m_zWriteMode, ZBufferOpHelper.ZWriteModeValues ); - m_zTestMode = EditorGUILayoutPopup( ZBufferOpHelper.ZTestModeStr, m_zTestMode, ZBufferOpHelper.ZTestModeLabels ); - m_noFog = EditorGUILayoutToggle( "No Fog", m_noFog ); - - } ); - } - - void UpdatePorts() - { - if( m_currentSelectedMode == 2 ) //custom mode - { - GetInputPortByUniqueId( 1 ).ChangeProperties( "Offset", WirePortDataType.FLOAT3, false ); - } - else - { - GetInputPortByUniqueId( 1 ).ChangeProperties( "Width", WirePortDataType.FLOAT, false ); - } - - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if( dataCollector.IsTemplate ) - return m_outputPorts[0].ErrorValue; - - if( dataCollector.IsFragmentCategory ) - { - UIUtils.ShowMessage( UniqueId, ErrorMessage ); - return m_outputPorts[ 0 ].ErrorValue; - } - - if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) - return m_outputPorts[ 0 ].ErrorValue; - - m_outputPorts[ 0 ].SetLocalValue( "0", dataCollector.PortCategory ); - - StandardSurfaceOutputNode masterNode = UIUtils.CurrentWindow.OutsideGraph.CurrentMasterNode as StandardSurfaceOutputNode; - - MasterNodeDataCollector outlineDataCollector = new MasterNodeDataCollector(); - outlineDataCollector.IsOutlineDataCollector = true; - outlineDataCollector.DirtyNormal = true; - InputPort colorPort = GetInputPortByUniqueId( 0 ); - InputPort alphaPort = GetInputPortByUniqueId( 2 ); - InputPort vertexPort = GetInputPortByUniqueId( 1 ); - - if( vertexPort.IsConnected ) - { - outlineDataCollector.PortCategory = MasterNodePortCategory.Vertex; - string outlineWidth = vertexPort.GenerateShaderForOutput( ref outlineDataCollector, vertexPort.DataType, true, true ); - outlineDataCollector.AddToVertexLocalVariables( UniqueId, PrecisionType.Float, vertexPort.DataType, "outlineVar", outlineWidth ); - - outlineDataCollector.AddVertexInstruction( outlineDataCollector.SpecialLocalVariables, UniqueId, false ); - outlineDataCollector.ClearSpecialLocalVariables(); - - outlineDataCollector.AddVertexInstruction( outlineDataCollector.VertexLocalVariables, UniqueId, false ); - outlineDataCollector.ClearVertexLocalVariables(); - - // need to check whether this breaks other outputs or not - UIUtils.CurrentWindow.OutsideGraph.ResetNodesLocalVariables(); - } - - outlineDataCollector.PortCategory = MasterNodePortCategory.Fragment; - string outlineColor = colorPort.GeneratePortInstructions( ref outlineDataCollector );// "\to.Emission = " + colorPort.GeneratePortInstructions( ref outlineDataCollector ) + ";"; - string alphaValue = alphaPort.Visible ? alphaPort.GeneratePortInstructions( ref outlineDataCollector ) : string.Empty; - - bool addTabs = outlineDataCollector.DirtySpecialLocalVariables || alphaPort.Available; - outlineDataCollector.AddInstructions( "\t" + outlineDataCollector.SpecialLocalVariables.TrimStart( '\t' ) ); - outlineDataCollector.ClearSpecialLocalVariables(); - outlineDataCollector.AddInstructions( ( addTabs ? "\t\t\t" : "" ) + "o.Emission = " + outlineColor + ";" ); - if( alphaPort.Visible ) - { - if( m_currentAlphaMode == OutlineAlphaModes.Masked ) - { - float maskClipValue = 0.5f; - - if( masterNode != null ) - maskClipValue = masterNode.OpacityMaskClipValue; - - if( masterNode.InlineOpacityMaskClipValue.IsValid ) - { - RangedFloatNode fnode = UIUtils.GetNode( masterNode.InlineOpacityMaskClipValue.NodeId ) as RangedFloatNode; - if( fnode != null ) - { - outlineDataCollector.AddToProperties( fnode.UniqueId, fnode.GetPropertyValue(), fnode.OrderIndex ); - outlineDataCollector.AddToUniforms( fnode.UniqueId, fnode.GetUniformValue() ); - } - else - { - IntNode inode = UIUtils.GetNode( masterNode.InlineOpacityMaskClipValue.NodeId ) as IntNode; - outlineDataCollector.AddToProperties( inode.UniqueId, inode.GetPropertyValue(), inode.OrderIndex ); - outlineDataCollector.AddToUniforms( inode.UniqueId, inode.GetUniformValue() ); - } - } - else - { - outlineDataCollector.AddToProperties( -1, string.Format( IOUtils.MaskClipValueProperty, OpacityMaskClipValueStr, maskClipValue ), -1 ); - outlineDataCollector.AddToUniforms( -1, string.Format( IOUtils.MaskClipValueUniform, maskClipValue ) ); - } - - outlineDataCollector.AddInstructions( ( addTabs ? "\n\t\t\t" : "" ) + "clip( " + alphaValue + " - " + masterNode.InlineOpacityMaskClipValue.GetValueOrProperty( IOUtils.MaskClipValueName, false ) + " );" ); - } - else - { - outlineDataCollector.AddInstructions( ( addTabs ? "\n\t\t\t" : "" ) + "o.Alpha = " + alphaValue + ";" ); - } - } - - if( outlineDataCollector.UsingWorldNormal ) - outlineDataCollector.AddInstructions( ( addTabs ? "\n\t\t\t" : "" ) + "o.Normal = float3(0,0,-1);" ); - - if( masterNode != null ) - { - //masterNode.AdditionalIncludes.AddToDataCollector( ref outlineDataCollector ); - //masterNode.AdditionalPragmas.AddToDataCollector( ref outlineDataCollector ); - //masterNode.AdditionalDefines.AddToDataCollector( ref outlineDataCollector ); - masterNode.AdditionalDirectives.AddAllToDataCollector( ref outlineDataCollector ); - } - - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.InputList = outlineDataCollector.InputList; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Inputs = outlineDataCollector.Inputs; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.DirtyInput = outlineDataCollector.DirtyInputs; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Includes = outlineDataCollector.Includes; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Pragmas = outlineDataCollector.Pragmas; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Defines = outlineDataCollector.Defines; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Uniforms = outlineDataCollector.Uniforms; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.InstancedProperties = outlineDataCollector.InstancedProperties; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.GrabPasses = outlineDataCollector.GrabPass; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.UniformList = outlineDataCollector.UniformsList; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.InstancedPropertiesList = outlineDataCollector.InstancedPropertiesList; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.VertexData = outlineDataCollector.VertexData; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Instructions = outlineDataCollector.Instructions; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.Functions = outlineDataCollector.Functions; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.LocalFunctions = outlineDataCollector.LocalFunctions; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.OutlineCullMode = m_cullMode; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.ZTestMode = m_zTestMode; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.ZWriteMode = m_zWriteMode; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.OffsetMode = m_currentSelectedMode; - UIUtils.CurrentWindow.OutsideGraph.CurrentStandardSurface.OutlineHelper.CustomNoFog = m_noFog; - dataCollector.CustomOutlineSelectedAlpha = (int)m_currentAlphaMode; - - for( int i = 0; i < outlineDataCollector.PropertiesList.Count; i++ ) - { - dataCollector.AddToProperties( UniqueId, outlineDataCollector.PropertiesList[ i ].PropertyName, outlineDataCollector.PropertiesList[ i ].OrderIndex ); - } - - UIUtils.CurrentWindow.OutsideGraph.ResetNodesLocalVariablesIfNot( MasterNodePortCategory.Vertex ); - return "0"; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - m_currentSelectedMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_noFog = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); - if( UIUtils.CurrentShaderVersion() > 14202 ) - m_currentAlphaMode = (OutlineAlphaModes)Enum.Parse( typeof( OutlineAlphaModes ), GetCurrentParam( ref nodeParams ) ); - - if( UIUtils.CurrentShaderVersion() > 14302 ) - { - m_zWriteMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - m_zTestMode = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 15304 ) - { - m_cullMode = (CullMode)Enum.Parse( typeof( CullMode ), GetCurrentParam( ref nodeParams ) ); - } - - SetAdditonalTitleText( string.Format( Constants.SubTitleTypeFormatStr, AvailableOutlineModes[ m_currentSelectedMode ] ) ); - UpdatePorts(); - CheckAlphaPortVisibility(); - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentSelectedMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_noFog ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_currentAlphaMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_zWriteMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_zTestMode ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_cullMode ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs.meta deleted file mode 100644 index 60f49a8e..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/OutlineNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 24f267627c002964badad2901309c96a -timeCreated: 1501161489 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs deleted file mode 100644 index a71ed207..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Vertex Position", "Vertex Data", "Vertex position vector in object space, can be used in both local vertex offset and fragment outputs" )] - public sealed class PosVertexDataNode : VertexDataNode - { - private const string PropertyLabel = "Size"; - private readonly string[] SizeLabels = { "XYZ", "XYZW" }; - - [SerializeField] - private int m_sizeOption = 0; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "vertex"; - ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 ); - m_drawPreviewAsSphere = true; - m_outputPorts[ 4 ].Visible = false; - m_hasLeftDropdown = true; - m_autoWrapProperties = true; - m_previewShaderGUID = "a5c14f759dd021b4b8d4b6eeb85ac227"; - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_sizeOption = m_upperLeftWidget.DrawWidget( this, m_sizeOption, SizeLabels ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - } - - public override void DrawProperties() - { - EditorGUI.BeginChangeCheck(); - m_sizeOption = EditorGUILayoutPopup( PropertyLabel, m_sizeOption, SizeLabels ); - if ( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - } - - void UpdatePorts() - { - if ( m_sizeOption == 0 ) - { - ChangeOutputProperties( 0, SizeLabels[ 0 ], WirePortDataType.FLOAT3, false ); - m_outputPorts[ 4 ].Visible = false; - } - else - { - ChangeOutputProperties( 0, SizeLabels[ 1 ], WirePortDataType.FLOAT4, false ); - m_outputPorts[ 4 ].Visible = true; - } - } - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - - if ( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - string vertexPos = dataCollector.TemplateDataCollectorInstance.GetVertexPosition( ( m_sizeOption == 0 ) ? WirePortDataType.FLOAT3 : WirePortDataType.FLOAT4, CurrentPrecisionType ); - return GetOutputVectorItem( 0, outputId, vertexPos ); - } - - - if ( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - - WirePortDataType sizeType = m_sizeOption == 0 ? WirePortDataType.FLOAT3 : WirePortDataType.FLOAT4; - - string vertexPosition = GeneratorUtils.GenerateVertexPosition( ref dataCollector, UniqueId, sizeType ); - return GetOutputVectorItem( 0, outputId, vertexPosition ); - - //if ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - //{ - // string vertexVar = base.GenerateShaderForOutput( 0, ref dataCollector, ignoreLocalVar ); - // if ( outputId != 0 ) - // { - // return GetOutputVectorItem( 0, outputId, vertexVar ); - // } - // else if ( m_sizeOption == 0 ) - // { - // vertexVar += ".xyz"; - // } - - // return vertexVar; - //} - //else - //{ - - // string vertexVar = GeneratorUtils.GenerateVertexPositionOnFrag( ref dataCollector, UniqueId, m_currentPrecisionType ); - // if ( outputId != 0 ) - // { - // return GetOutputVectorItem( 0, outputId, vertexVar ); - // } - // else if ( m_sizeOption == 0 ) - // { - // vertexVar += ".xyz"; - // } - // return GetOutputVectorItem( 0, outputId, vertexVar ); - //} - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if ( UIUtils.CurrentShaderVersion() > 7101 ) - { - m_sizeOption = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdatePorts(); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_sizeOption ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs.meta deleted file mode 100644 index 9ff223e8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/PosVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fc77801277f0faf4ca0be33f565b5604 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs deleted file mode 100644 index f9beb05c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vertex Tangent Sign", "Vertex Data", "Vertex tangent sign in object space, return the W value of tangent vector that contains only the sign of the tangent" )] - public sealed class TangentSignVertexDataNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputVectorPorts( WirePortDataType.FLOAT, "Sign" ); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "f5466d126f4bb1f49917eac88b1cb6af"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - return GeneratorUtils.GenerateVertexTangentSign( ref dataCollector, UniqueId, CurrentPrecisionType ); ; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs.meta deleted file mode 100644 index c07ffb6c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentSignVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1f79f23d5c10c9e4fb6a59c1ef70f6fc -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs deleted file mode 100644 index da6d25ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs +++ /dev/null @@ -1,120 +0,0 @@ -// 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( "Vertex Tangent", "Vertex Data", "Vertex tangent vector in object space, can be used in both local vertex offset and fragment outputs" )] - public sealed class TangentVertexDataNode : VertexDataNode - { - private const string PropertyLabel = "Size"; - private readonly string[] SizeLabels = { "XYZ", "XYZW" }; - - [SerializeField] - private int m_sizeOption = 0; - - private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper(); - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "tangent"; - ChangeOutputProperties( 0, "XYZ", WirePortDataType.FLOAT3 ); - m_outputPorts[ 4 ].Visible = false; - m_drawPreviewAsSphere = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "0a44bb521d06d6143a4acbc3602037f8"; - } - - public override void Destroy() - { - base.Destroy(); - m_upperLeftWidget = null; - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - EditorGUI.BeginChangeCheck(); - m_sizeOption = m_upperLeftWidget.DrawWidget( this, m_sizeOption, SizeLabels ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - } - - public override void DrawProperties() - { - EditorGUI.BeginChangeCheck(); - m_sizeOption = EditorGUILayoutPopup( PropertyLabel, m_sizeOption, SizeLabels ); - if( EditorGUI.EndChangeCheck() ) - { - UpdatePorts(); - } - } - - void UpdatePorts() - { - if( m_sizeOption == 0 ) - { - ChangeOutputProperties( 0, SizeLabels[ 0 ], WirePortDataType.FLOAT3, false ); - m_outputPorts[ 4 ].Visible = false; - } - else - { - ChangeOutputProperties( 0, SizeLabels[ 1 ], WirePortDataType.FLOAT4, false ); - m_outputPorts[ 4 ].Visible = true; - } - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - string vertexTangent = string.Empty; - if ( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - vertexTangent = dataCollector.TemplateDataCollectorInstance.GetVertexTangent( WirePortDataType.FLOAT4, CurrentPrecisionType ); - if( m_sizeOption == 0 ) - vertexTangent += ".xyz"; - - return GetOutputVectorItem( 0, outputId, vertexTangent ); - } - - if ( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - dataCollector.ForceNormal = true; - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - WirePortDataType sizeType = m_sizeOption == 0 ? WirePortDataType.FLOAT3 : WirePortDataType.FLOAT4; - - vertexTangent = GeneratorUtils.GenerateVertexTangent( ref dataCollector, UniqueId, CurrentPrecisionType, sizeType ); - return GetOutputVectorItem( 0, outputId, vertexTangent ); - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 16100 ) - { - m_sizeOption = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdatePorts(); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_sizeOption ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs.meta deleted file mode 100644 index 2ce6f77a..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TangentVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b544118f39abfe84581b8249973d52c5 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation.meta deleted file mode 100644 index 89948ec8..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 518d8e72c2385b9488817fee5368f56c -folderAsset: yes -timeCreated: 1482150091 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs deleted file mode 100644 index c49df07f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs +++ /dev/null @@ -1,30 +0,0 @@ - -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Distance-based Tessellation", "Miscellaneous", "Calculates tessellation based on distance from camera" )] - public sealed class DistanceBasedTessNode : TessellationParentNode - { - private const string FunctionBody = "UnityDistanceBasedTess( v0.vertex, v1.vertex, v2.vertex, {0},{1},{2})"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false,"Factor"); - AddInputPort( WirePortDataType.FLOAT, false, "Min Dist" ); - AddInputPort( WirePortDataType.FLOAT, false, "Max Dist" ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - } - - protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector ) - { - return string.Format( FunctionBody, - m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ), - m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ), - m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs.meta deleted file mode 100644 index 18016c1b..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5a83fb450d164d34bb756f46b3f4290e -timeCreated: 1482150091 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs deleted file mode 100644 index 48c5db07..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Edge Length Tessellation With Cull", "Miscellaneous", "Tessellation level computed based on triangle edge length on the screen with patch frustum culling" )] - public sealed class EdgeLengthCullTessNode : TessellationParentNode - { - private const string FunctionBody = "UnityEdgeLengthBasedTessCull( v0.vertex, v1.vertex, v2.vertex, {0},{1})"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Edge Length" ); - AddInputPort( WirePortDataType.FLOAT, false, "Max Disp." ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - } - - protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector ) - { - return string.Format( FunctionBody, - m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), - m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs.meta deleted file mode 100644 index 20d4dd27..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthCullTessNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4b09c64ce2fd06a4cb4036d8cc0f8b2a -timeCreated: 1482150962 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs deleted file mode 100644 index f4905bf1..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Edge Length Tessellation", "Miscellaneous", "Tessellation level computed based on triangle edge length on the screen" )] - public sealed class EdgeLengthTessNode : TessellationParentNode - { - private const string FunctionBody = "UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, {0})"; - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddInputPort( WirePortDataType.FLOAT, false, "Edge Length" ); - AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); - } - - protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector ) - { - return string.Format( FunctionBody, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs.meta deleted file mode 100644 index 2c936ef7..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/EdgeLengthTessNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: abe3e8fa4d49c9742a95ac801fd14d7d -timeCreated: 1482150962 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs deleted file mode 100644 index be14febc..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace AmplifyShaderEditor -{ - public class TessellationParentNode : ParentNode - { - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_useInternalPortData = true; - } - - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.PortCategory != MasterNodePortCategory.Tessellation ) - { - UIUtils.ShowMessage( UniqueId, m_nodeAttribs.Name + " can only be used on Master Node Tessellation port" ); - return "(-1)"; - } - - return BuildTessellationFunction( ref dataCollector ); - } - - protected virtual string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector ) - { - return string.Empty; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs.meta deleted file mode 100644 index 0799224c..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/TessellationParentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 79c24faef1fec884d937e74bdc9209da -timeCreated: 1482162387 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs deleted file mode 100644 index 5297ac7d..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "[VS] Vertex TexCoord1", "Vertex Data", "Second set of vertex texture coordinates. Only works on Vertex Shaders ports ( p.e. Local Vertex Offset Port )." ,null,UnityEngine.KeyCode.None,true,true, "[VS] Vertex TexCoord" )] - public sealed class TexCoord1VertexDataNode : VertexDataNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "texcoord1"; - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs.meta deleted file mode 100644 index 68529273..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoord1VertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ebd7eb3a7f6149e4e9dacbcda2d8089f -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs deleted file mode 100644 index 832b02a2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs +++ /dev/null @@ -1,235 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using System; -using UnityEngine; -using UnityEditor; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "Vertex TexCoord", "Vertex Data", "Vertex texture coordinates, can be used in both local vertex offset and fragment outputs", tags: "uv" )] - public sealed class TexCoordVertexDataNode : VertexDataNode - { - [SerializeField] - private int m_texcoordSize = 2; - - [SerializeField] - private int m_index = 0; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "texcoord"; - ChangeOutputProperties( 0, "UV", WirePortDataType.FLOAT2, false ); - m_outputPorts[ 1 ].Name = "U"; - m_outputPorts[ 2 ].Name = "V"; - m_outputPorts[ 3 ].Visible = false; - m_outputPorts[ 4 ].Visible = false; - m_outputPorts[ 3 ].Name = "W"; - m_outputPorts[ 4 ].Name = "T"; - m_autoWrapProperties = true; - m_hasLeftDropdown = true; - m_previewShaderGUID = "6c1bee77276896041bbb73b1b9e7f8ac"; - } - - public override void DrawProperties() - { - base.DrawProperties(); - EditorGUI.BeginChangeCheck(); - m_texcoordSize = EditorGUILayoutIntPopup( Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateOutput(); - } - - EditorGUI.BeginChangeCheck(); - m_index = EditorGUILayoutIntPopup( Constants.AvailableUVChannelLabel, m_index, Constants.AvailableUVSetsStr, Constants.AvailableUVChannels ); - if( EditorGUI.EndChangeCheck() ) - { - m_currentVertexData = ( m_index == 0 ) ? "texcoord" : "texcoord" + Constants.AvailableUVChannelsStr[ m_index ]; - } - } - - public override void Draw( DrawInfo drawInfo ) - { - base.Draw( drawInfo ); - - if( m_dropdownEditing ) - { - EditorGUI.BeginChangeCheck(); - m_texcoordSize = EditorGUIIntPopup( m_dropdownRect, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes, UIUtils.PropertyPopUp ); - if( EditorGUI.EndChangeCheck() ) - { - UpdateOutput(); - DropdownEditing = false; - } - } - } - - private void UpdateOutput() - { - if( m_texcoordSize == 3 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT3, false ); - m_outputPorts[ 0 ].Name = "UVW"; - m_outputPorts[ 3 ].Visible = true; - m_outputPorts[ 4 ].Visible = false; - } - else if( m_texcoordSize == 4 ) - { - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false ); - m_outputPorts[ 0 ].Name = "UVWT"; - m_outputPorts[ 3 ].Visible = true; - m_outputPorts[ 4 ].Visible = true; - } - else - { - m_texcoordSize = 2; - m_outputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT2, false ); - m_outputPorts[ 0 ].Name = "UV"; - m_outputPorts[ 3 ].Visible = false; - m_outputPorts[ 4 ].Visible = false; - } - m_sizeIsDirty = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if( dataCollector.IsTemplate ) - { - if( !dataCollector.TemplateDataCollectorInstance.HasUV( m_index ) ) - { - dataCollector.TemplateDataCollectorInstance.RegisterUV( m_index, m_outputPorts[ 0 ].DataType ); - } - - if( dataCollector.TemplateDataCollectorInstance.HasUV( m_index ) ) - { - InterpDataHelper info = dataCollector.TemplateDataCollectorInstance.GetUVInfo( m_index ); - if( outputId == 0 ) - { - return dataCollector.TemplateDataCollectorInstance.GetUVName( m_index, m_outputPorts[ 0 ].DataType ); - } - else if( outputId <= TemplateHelperFunctions.DataTypeChannelUsage[ info.VarType ] ) - { - return GetOutputVectorItem( 0, outputId, info.VarName ); - } - Debug.LogWarning( "Attempting to access inexisting UV channel" ); - } - else - { - Debug.LogWarning( "Attempting to access non-registered UV" ); - } - return "0"; - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - if( m_texcoordSize > 2 ) - dataCollector.UsingHigherSizeTexcoords = true; - } - - WirePortDataType size = (WirePortDataType)( 1 << ( m_texcoordSize + 1 ) ); - string texcoords = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_index, null, size ); - return GetOutputVectorItem( 0, outputId, texcoords ); - } - - /// <summary> - /// Generates UV properties and uniforms and returns the varible name to use in the fragment shader - /// </summary> - /// <param name="dataCollector"></param> - /// <param name="uniqueId"></param> - /// <param name="index"></param> - /// <returns>frag variable name</returns> - static public string GenerateFragUVs( ref MasterNodeDataCollector dataCollector, int uniqueId, int index, string propertyName = null, WirePortDataType size = WirePortDataType.FLOAT2 ) - { - string dummyPropUV = "_texcoord" + ( index > 0 ? ( index + 1 ).ToString() : "" ); - string dummyUV = "uv" + ( index > 0 ? ( index + 1 ).ToString() : "" ) + dummyPropUV; - - dataCollector.AddToProperties( uniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 ); - dataCollector.AddToInput( uniqueId, dummyUV, size ); - - string result = Constants.InputVarStr + "." + dummyUV; - if( !string.IsNullOrEmpty( propertyName ) ) - { - dataCollector.AddToUniforms( uniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddToLocalVariables( uniqueId, PrecisionType.Float, size, "uv" + propertyName, result + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); - result = "uv" + propertyName; - } - - return result; - } - - static public string GenerateVertexUVs( ref MasterNodeDataCollector dataCollector, int uniqueId, int index, string propertyName = null, WirePortDataType size = WirePortDataType.FLOAT2 ) - { - - string result = Constants.VertexShaderInputStr + ".texcoord"; - if( index > 0 ) - { - result += index.ToString(); - } - - switch( size ) - { - default: - case WirePortDataType.FLOAT2: - { - result += ".xy"; - } - break; - case WirePortDataType.FLOAT3: - { - result += ".xyz"; - } - break; - case WirePortDataType.FLOAT4: break; - } - - if( !string.IsNullOrEmpty( propertyName ) ) - { - dataCollector.AddToUniforms( uniqueId, "uniform float4 " + propertyName + "_ST;" ); - dataCollector.AddToVertexLocalVariables( uniqueId, UIUtils.WirePortToCgType( size ) + " uv" + propertyName + " = " + Constants.VertexShaderInputStr + ".texcoord" + ( index > 0 ? index.ToString() : string.Empty ) + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" ); - result = "uv" + propertyName; - } - - return result; - } - - public override void ReadFromString( ref string[] nodeParams ) - { - base.ReadFromString( ref nodeParams ); - if( UIUtils.CurrentShaderVersion() > 2502 ) - { - m_index = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - } - - if( UIUtils.CurrentShaderVersion() > 5111 ) - { - m_texcoordSize = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); - UpdateOutput(); - } - } - - public override void WriteToString( ref string nodeInfo, ref string connectionsInfo ) - { - base.WriteToString( ref nodeInfo, ref connectionsInfo ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_index ); - IOUtils.AddFieldValueToString( ref nodeInfo, m_texcoordSize ); - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - if( dataCollector.IsTemplate ) - { - dataCollector.TemplateDataCollectorInstance.SetUVUsage( m_index, m_texcoordSize ); - } - else if( m_index > 3 ) - { - dataCollector.AddCustomAppData( string.Format( TemplateHelperFunctions.TexUVFullSemantic, m_index ) ); - } - } - - - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs.meta deleted file mode 100644 index 54fd39ff..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/TexCoordVertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b865968ce22b9d949993e5e60126eb11 -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs deleted file mode 100644 index 70a7d7b5..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Vertex Binormal World -// Donated by Community Member Kebrus - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Bitangent", "Surface Data", "Per pixel world bitangent vector", null, KeyCode.None, true, false, null, null, "kebrus" )] - public sealed class VertexBinormalNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "76873532ab67d2947beaf07151383cbe"; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData, ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.IsTemplate ) - return GetOutputVectorItem( 0, outputId, dataCollector.TemplateDataCollectorInstance.GetWorldBinormal( CurrentPrecisionType ) ); - - if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - dataCollector.ForceNormal = true; - - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - string worldBitangent = GeneratorUtils.GenerateWorldBitangent( ref dataCollector, UniqueId ); - - return GetOutputVectorItem( 0, outputId, worldBitangent ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs.meta deleted file mode 100644 index b990b9a0..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexBinormalNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8ae297dac4e208f4e86c8f7a022fc5bd -timeCreated: 1481126957 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs deleted file mode 100644 index 53ef5763..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vertex Color", "Vertex Data", "Vertex color interpolated on fragment" )] - public sealed class VertexColorNode : VertexDataNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "color"; - m_outputPorts[ 0 ].Name = "RGBA"; - ConvertFromVectorToColorPorts(); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "ca1d22db6470c5f4d9f93a9873b4f5bc"; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) - { - string color = dataCollector.TemplateDataCollectorInstance.GetVertexColor( CurrentPrecisionType ); - return GetOutputColorItem( 0, outputId, color ); - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) - { - return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - } - else - { - dataCollector.AddToInput( UniqueId, SurfaceInputs.COLOR ); - string result = Constants.InputVarStr + "." + Constants.ColorVariable; - switch( outputId ) - { - case 1: result += ".r"; break; - case 2: result += ".g"; break; - case 3: result += ".b"; break; - case 4: result += ".a"; break; - } - return result; - } - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs.meta deleted file mode 100644 index ac1eee78..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexColorNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6271f602b9ab61e4c9a96a91e473c1e0 -timeCreated: 1481126956 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs deleted file mode 100644 index 9fa8cffd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - //public enum VertexData - //{ - // vertex = 0, - // tangent, - // normal, - // texcoord, - // texcoord1, - // color - //} - - [Serializable] - public class VertexDataNode : ParentNode - { - [SerializeField] - protected string m_currentVertexData; - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_currentVertexData = "vertex"; - -// Type type = typeof( StandardSurfaceOutputNode ); - //m_restictions.AddPortRestriction( type, 0 ); - //m_restictions.AddPortRestriction( type, 2 ); - //m_restictions.AddPortRestriction( type, 3 ); - //m_restictions.AddPortRestriction( type, 4 ); - //m_restictions.AddPortRestriction( type, 5 ); - //m_restictions.AddPortRestriction( type, 6 ); - //m_restictions.AddPortRestriction( type, 7 ); - //m_restictions.AddPortRestriction( type, 8 ); - //m_restictions.AddPortRestriction( type, 9 ); - //m_restictions.AddPortRestriction( type, 10 ); - AddOutputVectorPorts( WirePortDataType.FLOAT4, "Out" ); - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) - { - base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); - return GetOutputVectorItem( 0, outputId, Constants.VertexShaderInputStr + "." + m_currentVertexData ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs.meta deleted file mode 100644 index 66737ecd..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexDataNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e5f8fa23e49e4be478b283a704459767 -timeCreated: 1481126960 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs deleted file mode 100644 index b4e6064f..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Vertex Tangent World -// Donated by Community Member Kebrus - -using UnityEngine; -using System; - -namespace AmplifyShaderEditor -{ - [Serializable] - [NodeAttributes( "World Tangent", "Surface Data", "Per pixel world tangent vector", null, KeyCode.None, true, false, null, null, "kebrus" )] - public sealed class VertexTangentNode : ParentNode - { - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" ); - m_drawPreviewAsSphere = true; - m_previewShaderGUID = "61f0b80493c9b404d8c7bf56d59c3f81"; - } - - public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector ) - { - base.PropagateNodeData( nodeData , ref dataCollector ); - dataCollector.DirtyNormal = true; - } - - public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) - { - if ( dataCollector.IsTemplate ) - { - return GetOutputVectorItem( 0, outputId, dataCollector.TemplateDataCollectorInstance.GetWorldTangent( CurrentPrecisionType ) ); - } - - if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug ) - { - dataCollector.ForceNormal = true; - - dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, CurrentPrecisionType ); - dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ); - } - - string worldTangent = GeneratorUtils.GenerateWorldTangent( ref dataCollector, UniqueId ); - - return GetOutputVectorItem( 0, outputId, worldTangent ); - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs.meta deleted file mode 100644 index d3f0bbf2..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexTangentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3aca1dfe55df44d4cbaf99d5a40f7470 -timeCreated: 1481126955 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs deleted file mode 100644 index 844675f4..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Amplify Shader Editor - Visual Shader Editing Tool -// Copyright (c) Amplify Creations, Lda <info@amplify.pt> -// -// Custom Node Vertex To Fragment -// Donated by Jason Booth - http://u3d.as/DND - -using UnityEngine; - -namespace AmplifyShaderEditor -{ - [System.Serializable] - [NodeAttributes( "Vertex To Fragment", "Miscellaneous", "Pass vertex data to the pixel shader", null, KeyCode.None, true, false, null, null, "Jason Booth - http://u3d.as/DND" )] - public sealed class VertexToFragmentNode : SingleInputOp - { - - protected override void CommonInit( int uniqueId ) - { - base.CommonInit( uniqueId ); - m_inputPorts[ 0 ].AddPortForbiddenTypes( WirePortDataType.FLOAT3x3, - WirePortDataType.FLOAT4x4, - WirePortDataType.SAMPLER1D, - WirePortDataType.SAMPLER2D, - WirePortDataType.SAMPLER3D, - WirePortDataType.SAMPLERCUBE ); - m_inputPorts[ 0 ].Name = "(VS) In"; - m_outputPorts[ 0 ].Name = "Out"; - m_useInternalPortData = false; - m_previewShaderGUID = "74e4d859fbdb2c0468de3612145f4929"; - } - - 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 varName = GenerateInputInVertex( ref dataCollector, 0, "vertexToFrag" + OutputId,true ); - m_outputPorts[ 0 ].SetLocalValue( varName, dataCollector.PortCategory ); - - return varName; - - ////TEMPLATES - //if( dataCollector.IsTemplate ) - //{ - // if( !dataCollector.IsFragmentCategory ) - // return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - // string varName = "vertexToFrag" + OutputId; - // if( dataCollector.TemplateDataCollectorInstance.HasCustomInterpolatedData( varName ) ) - // return varName; - - // MasterNodePortCategory category = dataCollector.PortCategory; - // dataCollector.PortCategory = MasterNodePortCategory.Vertex; - // bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - - // string data = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - - // dataCollector.PortCategory = category; - // if( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables ) - // { - // dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariables, UniqueId, false ); - // dataCollector.ClearVertexLocalVariables(); - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - // } - - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Fragment ); - - // dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( varName, m_inputPorts[ 0 ].DataType, m_currentPrecisionType, data ); - // //return varName; - - // m_outputPorts[ 0 ].SetLocalValue( varName ); - // return m_outputPorts[ 0 ].LocalValue; - //} - - ////SURFACE - //{ - // if( !dataCollector.IsFragmentCategory ) - // { - // return m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - // } - - // if( dataCollector.TesselationActive ) - // { - // UIUtils.ShowMessage( "Unable to use Vertex to Frag when Tessellation is active" ); - // return m_outputPorts[ 0 ].ErrorValue; - // } - - - // string interpName = "data" + OutputId; - // dataCollector.AddToInput( UniqueId, interpName, m_inputPorts[ 0 ].DataType, m_currentPrecisionType ); - - // MasterNodePortCategory portCategory = dataCollector.PortCategory; - // dataCollector.PortCategory = MasterNodePortCategory.Vertex; - - // bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; - - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - - // string vertexVarValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); - // dataCollector.AddLocalVariable( UniqueId, Constants.VertexShaderOutputStr + "." + interpName, vertexVarValue + ";" ); - - // dataCollector.PortCategory = portCategory; - - // if( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables ) - // { - // dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariables, UniqueId, false ); - // dataCollector.ClearVertexLocalVariables(); - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); - // } - - // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Fragment ); - - // //return Constants.InputVarStr + "." + interpName; - - // m_outputPorts[ 0 ].SetLocalValue( Constants.InputVarStr + "." + interpName ); - // return m_outputPorts[ 0 ].LocalValue; - //} - } - } -} diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs.meta deleted file mode 100644 index 0131f745..00000000 --- a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/VertexToFragmentNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9ecea5c13558ad4499dd4bc558670b8e -timeCreated: 1481126958 -licenseType: Store -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: |