summaryrefslogtreecommitdiff
path: root/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs')
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs130
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/CameraDepthFade.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs54
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeGrabScreenPosHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs76
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ComputeScreenPosHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs38
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeDepthNormalNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGBAHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeFloatRGHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs109
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeLightmapHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DecodeViewNormalStereoHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs168
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DepthFade.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs59
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DiffuseAndSpecularFromMetallicNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs284
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/DitheringNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs34
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeDepthNormalNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGBAHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeFloatRGHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs27
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/EncodeViewNormalStereoHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs122
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/GammaToLinearNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs93
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/HelperParentNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs127
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LinearToGammaNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs26
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/LuminanceHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs43
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceLightDirHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs34
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ObjSpaceViewDirHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs148
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxMappingNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs744
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOcclusionMappingNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs47
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ParallaxOffsetHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs105
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/ShadeVertexLightsHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs184
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/SurfaceDepthNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs1494
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/TriplanarNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs34
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToClipPosHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs33
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/UnityObjToViewPosHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs78
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceLightDirHlpNode.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs34
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/HelperFuncs/WorldSpaceViewDirHlpNode.cs.meta12
62 files changed, 0 insertions, 4832 deletions
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: