summaryrefslogtreecommitdiff
path: root/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/SurfaceShaderInputs/UVCoordsParentNode.cs
blob: b259d89f2a54b48d1505fbc2959cd9a25660ce64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//// Amplify Shader Editor - Visual Shader Editing Tool
//// Copyright (c) Amplify Creations, Lda <info@amplify.pt>

//using UnityEngine;
//using UnityEditor;
//using System;

//namespace AmplifyShaderEditor
//{
//	[Serializable]
//	[NodeAttributes( "[Old]Texture Coordinates", "Surface Data", "Texture UV coordinates set", null, KeyCode.U, false )]
//	public sealed class UVCoordsParentNode : ParentNode
//	{
//		private const string TilingStr = "Tiling";

//		[SerializeField]
//		private int m_textureCoordChannel = 0;

//		[SerializeField]
//		private int m_textureCoordSet = 0;

//		[SerializeField]
//		private Vector2 m_tiling = new Vector2( 1, 1 );
		
//		protected override void CommonInit( int uniqueId )
//		{
//			base.CommonInit( uniqueId );
//			AddOutputVectorPorts( WirePortDataType.FLOAT2, Constants.EmptyPortValue );
//			m_textLabelWidth = 75;
//		}

//		public override void DrawProperties()
//		{
//			base.DrawProperties();
//			int newChannel = EditorGUILayoutIntPopup( Constants.AvailableUVChannelLabel, m_textureCoordChannel, Constants.AvailableUVChannelsStr, Constants.AvailableUVChannels );
//			if ( newChannel != m_textureCoordChannel )
//			{
//				if ( UIUtils.IsChannelAvailable( newChannel ) )
//				{
//					UIUtils.ShowMessage( "Attempting to use an unoccupied used texture channel" );
//				}
//				else
//				{
//					m_textureCoordChannel = newChannel;
//				}
//			}
//			else if ( m_textureCoordChannel > -1 && UIUtils.IsChannelAvailable( m_textureCoordChannel ) )
//			{
//				UIUtils.ShowMessage( "Texture Channel " + m_textureCoordChannel + " is unavailable for TextureCoordinate node" );
//				m_textureCoordChannel = -1;
//			}

//			m_textureCoordSet = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets );

//			m_tiling = EditorGUILayoutVector2Field( TilingStr, m_tiling );
//		}

//		public override void Draw( DrawInfo drawInfo )
//		{
//			base.Draw( drawInfo );
//			if ( m_isVisible )
//			{
//				m_propertyDrawPos.x = m_globalPosition.x + Constants.FLOAT_WIDTH_SPACING;
//				m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
//				m_propertyDrawPos.width = 2.7f * drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
//				m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;

//				m_propertyDrawPos.y = m_outputPorts[ 1 ].Position.y;
//				UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.x );

//				m_propertyDrawPos.y = m_outputPorts[ 2 ].Position.y;
//				UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_tiling.y );
//			}
//		}

//		public override void ReadFromString( ref string[] nodeParams )
//		{
//			base.ReadFromString( ref nodeParams );
//			m_textureCoordChannel = Convert.ToInt32( GetCurrentParam( ref nodeParams ) );
//			m_tiling.x = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
//			m_tiling.y = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
//		}

//		public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
//		{
//			base.WriteToString( ref nodeInfo, ref connectionsInfo );
//			IOUtils.AddFieldValueToString( ref nodeInfo, m_textureCoordChannel );
//			IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.x );
//			IOUtils.AddFieldValueToString( ref nodeInfo, m_tiling.y );
//		}

//		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
//		{
//			string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordChannel, m_textureCoordSet );
//			dataCollector.AddToInput( UniqueId, uvChannelDeclaration, true );

//			if ( dataCollector.GetChannelUsage( m_textureCoordChannel ) != TextureChannelUsage.Used )
//				dataCollector.SetChannelUsage( m_textureCoordChannel, TextureChannelUsage.Required );

//			string uvTileStr = string.Empty;
//			switch ( outputId )
//			{
//				case 0: { uvTileStr = "float2( " + m_tiling.x + " , " + m_tiling.y + " )"; } break;
//				case 1: { uvTileStr = m_tiling.x.ToString(); } break;
//				case 2: { uvTileStr = m_tiling.y.ToString(); } break;
//			}
//			string uvChannelName = IOUtils.GetUVChannelName( UIUtils.GetChannelName( m_textureCoordChannel ), m_textureCoordSet );
//			return ( uvTileStr + "*" + GetOutputVectorItem( 0, outputId, Constants.InputVarStr + "." + uvChannelName ) );
//		}

//	}
//}