You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
17 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using System.Collections.Generic;
  5. namespace AmplifyShaderEditor
  6. {
  7. public struct Constants
  8. {
  9. public readonly static char SemiColonSeparator = '@';
  10. public readonly static string AppDataFullName = "appdata_full";
  11. public readonly static string CustomAppDataFullName = "appdata_full_custom";
  12. public readonly static string CustomAppDataFullBody =
  13. "\n\t\tstruct appdata_full_custom\n" +
  14. "\t\t{\n" +
  15. "\t\t\tfloat4 vertex : POSITION;\n" +
  16. "\t\t\tfloat4 tangent : TANGENT;\n" +
  17. "\t\t\tfloat3 normal : NORMAL;\n" +
  18. "\t\t\tfloat4 texcoord : TEXCOORD0;\n" +
  19. "\t\t\tfloat4 texcoord1 : TEXCOORD1;\n" +
  20. "\t\t\tfloat4 texcoord2 : TEXCOORD2;\n" +
  21. "\t\t\tfloat4 texcoord3 : TEXCOORD3;\n" +
  22. "\t\t\tfixed4 color : COLOR;\n" +
  23. "\t\t\tUNITY_VERTEX_INPUT_INSTANCE_ID\n";
  24. public readonly static string IncludeFormat = "#include \"{0}\"";
  25. public readonly static string PragmaFormat = "#pragma {0}";
  26. public readonly static string DefineFormat = "#define {0}";
  27. public readonly static string RenderTypeHelperStr = "RenderType";
  28. public readonly static string RenderQueueHelperStr = "Queue";
  29. public readonly static string DefaultShaderName = "New Amplify Shader";
  30. public readonly static string UndoReplaceMasterNodeId = "Replacing Master Node";
  31. public readonly static string UnityLightingLib = "Lighting.cginc";
  32. public readonly static string UnityAutoLightLib = "AutoLight.cginc";
  33. public readonly static string UnityBRDFLib = "UnityStandardBRDF.cginc";
  34. public readonly static string LocalValueDecWithoutIdent = "{0} {1} = {2};";
  35. public readonly static string LocalValueDefWithoutIdent = "{0} {1} {2};";
  36. public readonly static string TilingOffsetFormat = "{0} * {1} + {2}";
  37. public static string InvalidPostProcessDatapath = "__DELETED_GUID_Trash";
  38. //TEMPLATES
  39. public static float PlusMinusButtonLayoutWidth = 15;
  40. public static float NodeButtonSizeX = 16;
  41. public static float NodeButtonSizeY = 16;
  42. public static float NodeButtonDeltaX = 5;
  43. public static float NodeButtonDeltaY = 11;
  44. public readonly static string ReservedPropertyNameStr = "Property name '{0}' is reserved and cannot be used";
  45. public readonly static string NumericPropertyNameStr = "Property name '{0}' is numeric thus cannot be used";
  46. public readonly static string DeprecatedMessageStr = "Node '{0}' is deprecated. Use node '{1}' instead.";
  47. public readonly static string DeprecatedNoAlternativeMessageStr = "Node '{0}' is deprecated and should be removed.";
  48. public readonly static string UndoChangePropertyTypeNodesId = "Changing Property Types";
  49. public readonly static string UndoChangeTypeNodesId = "Changing Nodes Types";
  50. public readonly static string UndoMoveNodesId = "Moving Nodes";
  51. public readonly static string UndoRegisterFullGrapId = "Register Graph";
  52. public readonly static string UndoAddNodeToCommentaryId = "Add node to Commentary";
  53. public readonly static string UndoRemoveNodeFromCommentaryId = "Remove node from Commentary";
  54. public readonly static string UndoCreateDynamicPortId = "Create Dynamic Port";
  55. public readonly static string UndoDeleteDynamicPortId = "Destroy Dynamic Port";
  56. public readonly static string UndoRegisterNodeId = "Register Object";
  57. public readonly static string UndoUnregisterNodeId = "Unregister Object";
  58. public readonly static string UndoCreateNodeId = "Create Object";
  59. public readonly static string UndoPasteNodeId = "Paste Object";
  60. public readonly static string UndoDeleteNodeId = "Destroy Object";
  61. public readonly static string UndoDeleteConnectionId = "Destroy Connection";
  62. public readonly static string UndoCreateConnectionId = "Create Connection";
  63. public readonly static float MenuDragSpeed = -0.5f;
  64. public readonly static string DefaultCustomInspector = "ASEMaterialInspector";
  65. public readonly static string ReferenceTypeStr = "Mode";
  66. public readonly static string AvailableReferenceStr = "Reference";
  67. public readonly static string InstancePostfixStr = " (Reference) ";
  68. public readonly static string ASEMenuName = "Amplify Shader";
  69. public readonly static string LodCrossFadeOption2017 = "dithercrossfade";
  70. public readonly static string UnityShaderVariables = "UnityShaderVariables.cginc";
  71. public readonly static string UnityCgLibFuncs = "UnityCG.cginc";
  72. public readonly static string UnityStandardUtilsLibFuncs = "UnityStandardUtils.cginc";
  73. public readonly static string UnityPBSLightingLib = "UnityPBSLighting.cginc";
  74. public readonly static string UnityDeferredLightLib = "UnityDeferredLibrary.cginc";
  75. public readonly static string ATSharedLibGUID = "ba242738c4be3324aa88d126f7cc19f9";
  76. public readonly static string HelpURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor";
  77. //public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Nodes#";
  78. //public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Community_Nodes#";
  79. public readonly static string NodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
  80. public readonly static string CommunityNodeCommonUrl = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/";
  81. public readonly static Color InfiniteLoopColor = Color.red;
  82. public readonly static Color DefaultCategoryColor = new Color( 0.26f, 0.35f, 0.44f, 1.0f );
  83. public readonly static Color NodeBodyColor = new Color( 1f, 1f, 1f, 1.0f );
  84. public readonly static Color ModeTextColor = new Color( 1f, 1f, 1f, 0.25f );
  85. public readonly static Color ModeIconColor = new Color( 1f, 1f, 1f, 0.75f );
  86. public readonly static Color PortTextColor = new Color( 1f, 1f, 1f, 0.5f );
  87. public readonly static Color PortLockedTextColor = new Color( 1f, 1f, 1f, 0.35f );
  88. public readonly static Color BoxSelectionColor = new Color( 1f, 1f, 1f, 0.5f );
  89. public readonly static Color SpecialRegisterLocalVarSelectionColor = new Color( 0.27f, 0.52f, 1.0f, 1f );
  90. public readonly static Color SpecialGetLocalVarSelectionColor = new Color( 0.2f, 0.8f, 0.4f, 1f );
  91. public readonly static Color NodeSelectedColor = new Color( 0.85f, 0.56f, 0f, 1f );
  92. public readonly static Color NodeDefaultColor = new Color( 1f, 1f, 1f, 1f );
  93. public readonly static Color NodeConnectedColor = new Color( 1.0f, 1f, 0.0f, 1f );
  94. public readonly static Color NodeErrorColor = new Color( 1f, 0.5f, 0.5f, 1f );
  95. public readonly static string NoSpecifiedCategoryStr = "<None>";
  96. public readonly static int MINIMIZE_WINDOW_LOCK_SIZE = 630;
  97. public readonly static int FoldoutMouseId = 0; // Left Mouse Button
  98. public readonly static float SNAP_SQR_DIST = 200f;
  99. public readonly static int INVALID_NODE_ID = -1;
  100. public readonly static float WIRE_WIDTH = 7f;
  101. public readonly static float WIRE_CONTROL_POINT_DIST = 0.7f;
  102. public readonly static float WIRE_CONTROL_POINT_DIST_INV = 1.7f;
  103. public readonly static float IconsLeftRightMargin = 5f;
  104. public readonly static float PropertyPickerWidth = 16f;
  105. public readonly static float PropertyPickerHeight = 16f;
  106. public readonly static float PreviewExpanderWidth = 16f;
  107. public readonly static float PreviewExpanderHeight = 16f;
  108. public readonly static float TextFieldFontSize = 11f;
  109. public readonly static float DefaultFontSize = 15f;
  110. public readonly static float DefaultTitleFontSize = 13f;
  111. public readonly static float PropertiesTitleFontSize = 11f;
  112. public readonly static float MessageFontSize = 40f;
  113. public readonly static float SelectedObjectFontSize = 30f;
  114. public readonly static float PORT_X_ADJUST = 10;
  115. public readonly static float PORT_INITIAL_X = 10;
  116. public readonly static float PORT_INITIAL_Y = 40;
  117. public readonly static float INPUT_PORT_DELTA_Y = 5;
  118. public readonly static float PORT_TO_LABEL_SPACE_X = 5;
  119. public readonly static float NODE_HEADER_HEIGHT = 32;
  120. public readonly static float NODE_HEADER_EXTRA_HEIGHT = 5;
  121. public readonly static float NODE_HEADER_LEFTRIGHT_MARGIN = 10;
  122. public readonly static float MULTIPLE_SELECION_BOX_ALPHA = 0.5f;
  123. public readonly static float RMB_CLICK_DELTA_TIME = 0.1f;
  124. public readonly static float RMB_SCREEN_DIST = 10f;
  125. public readonly static float CAMERA_MAX_ZOOM = 2f;
  126. public readonly static float CAMERA_MIN_ZOOM = 1f;
  127. public readonly static float CAMERA_ZOOM_SPEED = 0.1f;
  128. public readonly static float ALT_CAMERA_ZOOM_SPEED = -0.05f;
  129. public readonly static object INVALID_VALUE = null;
  130. public readonly static float HORIZONTAL_TANGENT_SIZE = 100f;
  131. public readonly static float OUTSIDE_WIRE_MARGIN = 5f;
  132. public readonly static string SubTitleNameFormatStr = "Name( {0} )";
  133. public readonly static string SubTitleSpaceFormatStr = "Space( {0} )";
  134. public readonly static string SubTitleTypeFormatStr = "Type( {0} )";
  135. public readonly static string SubTitleValueFormatStr = "Value( {0} )";
  136. public readonly static string SubTitleConstFormatStr = "Const( {0} )";
  137. public readonly static string SubTitleVarNameFormatStr = "Var( {0} )";
  138. public readonly static string CodeWrapper = "( {0} )";
  139. public readonly static string NodesDumpFormat = "{0}:,{1},{2}\n";
  140. public readonly static string TagFormat = " \"{0}\" = \"{1}\"";
  141. public readonly static string LocalVarIdentation = "\t\t\t";
  142. public readonly static string SimpleLocalValueDec = LocalVarIdentation + "{0} {1};\n";
  143. public readonly static string LocalValueDec = LocalVarIdentation + LocalValueDecWithoutIdent + '\n';
  144. public readonly static string LocalValueDef = LocalVarIdentation + "{0} = {1};\n";
  145. public readonly static string CastHelper = "({0}).{1}";
  146. public readonly static string PropertyLocalVarDec = "{0} {1} = {0}({2});";
  147. public readonly static string[] UniformDec = { "uniform {0} {1};", "{0} {1};" };
  148. public readonly static string PropertyValueLabel = "Value( {0} )";
  149. public readonly static string ConstantsValueLabel = "Const( {0} )";
  150. public readonly static string PropertyFloatFormatLabel = "0.###";
  151. public readonly static string PropertyBigFloatFormatLabel = "0.###e+0";
  152. public readonly static string PropertyIntFormatLabel = "0";
  153. public readonly static string PropertyBigIntFormatLabel = "0e+0";
  154. public readonly static string PropertyVectorFormatLabel = "0.##";
  155. public readonly static string PropertyBigVectorFormatLabel = "0.##e+0";
  156. public readonly static string PropertyMatrixFormatLabel = "0.#";
  157. public readonly static string PropertyBigMatrixFormatLabel = "0.#e+0";
  158. public readonly static string NoPropertiesLabel = "No assigned properties";
  159. public readonly static string ValueLabel = "Value";
  160. public readonly static string DefaultValueLabel = "Default Value";
  161. public readonly static string MaterialValueLabel = "Material Value";
  162. public readonly static GUIContent DefaultValueLabelContent = new GUIContent( "Default Value" );
  163. public readonly static GUIContent MaterialValueLabelContent = new GUIContent( "Material Value" );
  164. public readonly static string InputVarStr = "i";//"input";
  165. public readonly static string OutputVarStr = "o";//"output";
  166. public readonly static string CustomLightOutputVarStr = "s";
  167. public readonly static string CustomLightStructStr = "Custom";
  168. public readonly static string VertexShaderOutputStr = "o";
  169. public readonly static string VertexShaderInputStr = "v";//"vertexData";
  170. public readonly static string VertexDataFunc = "vertexDataFunc";
  171. public readonly static string VirtualCoordNameStr = "vcoord";
  172. public readonly static string VertexVecNameStr = "vertexVec";
  173. public readonly static string VertexVecDecStr = "float3 " + VertexVecNameStr;
  174. public readonly static string VertexVecVertStr = VertexShaderOutputStr + "." + VertexVecNameStr;
  175. public readonly static string NormalVecNameStr = "normalVec";
  176. public readonly static string NormalVecDecStr = "float3 " + NormalVecNameStr;
  177. public readonly static string NormalVecFragStr = InputVarStr + "." + NormalVecNameStr;
  178. public readonly static string NormalVecVertStr = VertexShaderOutputStr + "." + NormalVecNameStr;
  179. public readonly static string IncidentVecNameStr = "incidentVec";
  180. public readonly static string IncidentVecDecStr = "float3 " + IncidentVecNameStr;
  181. public readonly static string IncidentVecDefStr = VertexShaderOutputStr + "." + IncidentVecNameStr + " = normalize( " + VertexVecNameStr + " - _WorldSpaceCameraPos.xyz)";
  182. public readonly static string IncidentVecFragStr = InputVarStr + "." + IncidentVecNameStr;
  183. public readonly static string IncidentVecVertStr = VertexShaderOutputStr + "." + IncidentVecNameStr;
  184. public readonly static string WorldNormalLocalDecStr = "WorldNormalVector( " + Constants.InputVarStr + " , {0}( 0,0,1 ))";
  185. public readonly static string VFaceVariable = "ASEVFace";
  186. public readonly static string VFaceInput = "half ASEVFace : VFACE";
  187. public readonly static string ColorVariable = "vertexColor";
  188. public readonly static string ColorInput = "float4 vertexColor : COLOR";
  189. public readonly static string NoStringValue = "None";
  190. public readonly static string EmptyPortValue = " ";
  191. public readonly static string[] OverallInvalidChars = { "\r", "\n", "\\", " ", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
  192. public readonly static string[] ShaderInvalidChars = { "\r", "\n", "\\", "\'", "\"", };
  193. public readonly static string[] EnumInvalidChars = { "\r", "\n", "\\", ".", ">", ",", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-" };
  194. public readonly static string[] AttrInvalidChars = { "\r", "\n", "\\", ".", ">", "<", "\'", "\"", ";", ":", "[", "{", "]", "}", "=", "+", "`", "~", "/", "?", "!", "@", "#", "$", "%", "^", "&", "*" };
  195. public readonly static string[] WikiInvalidChars = { "#", "<", ">", "[", "]", "|", "{", "}", "%", "+", "?", "\\", "/", ",", ";", "." };
  196. public readonly static string[,] UrlReplacementStringValues =
  197. {
  198. { " = ", "Equals" },
  199. { " == ", "Equals" },
  200. { " != ", "NotEqual" },
  201. { " \u2260 ", "NotEqual" },
  202. { " > ", "Greater" },
  203. { " \u2265 " , "GreaterOrEqual" },
  204. { " >= ", "GreaterOrEqual" },
  205. { " < ", "Less" },
  206. { " \u2264 ", "LessOrEqual" },
  207. { " <= ", "LessOrEqual" },
  208. { " ", "_" },
  209. { "[", string.Empty },
  210. { "]", string.Empty }
  211. };
  212. public readonly static int UrlReplacementStringValuesLen = UrlReplacementStringValues.Length / 2;
  213. public readonly static string[,] ReplacementStringValues =
  214. {
  215. { " = ", "Equals" },
  216. { " == ", "Equals" },
  217. { " != ", "NotEqual" },
  218. { " \u2260 ", "NotEqual" },
  219. { " > ", "Greater" },
  220. { " \u2265 ", "GreaterOrEqual" },
  221. { " >= ", "GreaterOrEqual" },
  222. { " < ", "Less" },
  223. { " \u2264 ", "LessOrEqual" },
  224. { " <= ", "LessOrEqual" }
  225. };
  226. public readonly static int ReplacementStringValuesLen = ReplacementStringValues.Length / 2;
  227. public readonly static string InternalData = "INTERNAL_DATA";
  228. public readonly static string NoMaterialStr = "None";
  229. public readonly static string OptionalParametersSep = " ";
  230. public readonly static string NodeUndoId = "NODE_UNDO_ID";
  231. public readonly static string NodeCreateUndoId = "NODE_CREATE_UNDO_ID";
  232. public readonly static string NodeDestroyUndoId = "NODE_DESTROY_UNDO_ID";
  233. // Custom node tags
  234. //[InPortBegin:Id:Type:Name:InPortEnd]
  235. public readonly static string CNIP = "#IP";
  236. public readonly static float FLOAT_DRAW_HEIGHT_FIELD_SIZE = 16f;
  237. public readonly static float FLOAT_DRAW_WIDTH_FIELD_SIZE = 45f;
  238. public readonly static float FLOAT_WIDTH_SPACING = 3f;
  239. public readonly static Color LockedPortColor = new Color( 0.3f, 0.3f, 0.3f, 0.5f );
  240. #if UNITY_2018_2_OR_NEWER
  241. public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3, 4, 5, 6, 7 };
  242. public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3", "4", "5", "6", "7"};
  243. public readonly static string AvailableUVChannelLabel = "UV Channel";
  244. public readonly static int[] AvailableUVSets = { 0, 1, 2, 3, 4, 5, 6, 7 };
  245. public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4","5", "6", "7", "8" };
  246. public readonly static string AvailableUVSetsLabel = "UV Set";
  247. #else
  248. public readonly static int[] AvailableUVChannels = { 0, 1, 2, 3 };
  249. public readonly static string[] AvailableUVChannelsStr = { "0", "1", "2", "3" };
  250. public readonly static string AvailableUVChannelLabel = "UV Channel";
  251. public readonly static int[] AvailableUVSets = { 0, 1, 2, 3 };
  252. public readonly static string[] AvailableUVSetsStr = { "1", "2", "3", "4" };
  253. public readonly static string AvailableUVSetsLabel = "UV Set";
  254. #endif
  255. public readonly static int[] AvailableUVSizes = { 2, 3, 4 };
  256. public readonly static string[] AvailableUVSizesStr = { "Float 2", "Float 3", "Float 4" };
  257. public readonly static string AvailableUVSizesLabel = "Coord Size";
  258. public readonly static string LineSeparator = "________________________________";
  259. public readonly static Vector2 CopyPasteDeltaPos = new Vector2( 40, 40 );
  260. public readonly static string[] VectorSuffixes = { ".x", ".y", ".z", ".w" };
  261. public readonly static string[] ColorSuffixes = { ".r", ".g", ".b", ".a" };
  262. public const string InternalDataLabelStr = "Internal Data";
  263. public const string AttributesLaberStr = "Attributes";
  264. public const string ParameterLabelStr = "Parameters";
  265. public static readonly string[] ReferenceArrayLabels = { "Object", "Reference" };
  266. public static readonly string[] ChannelNamesVector = { "X", "Y", "Z", "W" };
  267. public static readonly string[] ChannelNamesColor = { "R", "G", "B", "A" };
  268. }
  269. }