summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs
new file mode 100644
index 00000000..3d778d9c
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/TFHCPixelate.cs
@@ -0,0 +1,54 @@
+// 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);
+
+ }
+ }
+}