summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.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/HelperFuncs/ComputeGrabScreenPosHlpNode.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs
new file mode 100644
index 00000000..362415d3
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs
@@ -0,0 +1,54 @@
+// 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 );
+ }
+ }
+}