diff options
author | chai <chaifix@163.com> | 2020-10-23 13:08:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-10-23 13:08:43 +0800 |
commit | b82da95b5181ac8bbae38efb13e950d5e88a4caa (patch) | |
tree | 48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs | |
parent | 917e9e0b320775634dc2e710f7deac74fd0822f0 (diff) |
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs')
-rw-r--r-- | Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs new file mode 100644 index 00000000..fc1744f5 --- /dev/null +++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Textures/HeightMapBlendNode.cs @@ -0,0 +1,53 @@ +// Amplify Shader Editor - Visual Shader Editing Tool +// Copyright (c) Amplify Creations, Lda <info@amplify.pt> +// +// Custom Node HeightMap Texture Masking +// Donated by Rea + +using UnityEngine; +using System; + +namespace AmplifyShaderEditor +{ + [Serializable] + [NodeAttributes( "HeightMap Texture Blend", "Textures", "Advanced Texture Blending by using heightMap and splatMask, usefull for texture layering ", null, KeyCode.None, true, false, null, null, "Rea" )] + public sealed class HeightMapBlendNode : ParentNode + { + + protected override void CommonInit( int uniqueId ) + { + base.CommonInit( uniqueId ); + AddInputPort( WirePortDataType.FLOAT, false, "HeightMap" ); + AddInputPort( WirePortDataType.FLOAT, false, "SplatMask" ); + AddInputPort( WirePortDataType.FLOAT, false, "BlendStrength" ); + AddOutputVectorPorts( WirePortDataType.FLOAT, Constants.EmptyPortValue ); + m_textLabelWidth = 120; + m_useInternalPortData = true; + m_inputPorts[ 2 ].FloatInternalData = 1; + m_previewShaderGUID = "b2ac23d6d5dcb334982b6f31c2e7a734"; + } + + 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 ); + + string HeightMap = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ); + string SplatMask = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector); + string Blend = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ); + + string HeightMask = "saturate(pow(((" + HeightMap + "*" + SplatMask + ")*4)+(" + SplatMask + "*2)," + Blend + "))"; + string varName = "HeightMask" + OutputId; + + RegisterLocalVariable( 0, HeightMask, ref dataCollector , varName ); + return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ); + } + /* + A = (heightMap * SplatMask)*4 + B = SplatMask*2 + C = pow(A+B,Blend) + saturate(C) + saturate(pow(((heightMap * SplatMask)*4)+(SplatMask*2),Blend)); + */ + } +} |