From 917e9e0b320775634dc2e710f7deac74fd0822f0 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 22 Oct 2020 23:30:02 +0800 Subject: * amplify shader editor --- .../Vertex/Tessellation/DistanceBasedTessNode.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs') diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs new file mode 100644 index 00000000..c49df07f --- /dev/null +++ b/Assets/AmplifyShaderEditor/Plugins/Editor/Nodes/Vertex/Tessellation/DistanceBasedTessNode.cs @@ -0,0 +1,30 @@ + +// Amplify Shader Editor - Visual Shader Editing Tool +// Copyright (c) Amplify Creations, Lda + + +namespace AmplifyShaderEditor +{ + [System.Serializable] + [NodeAttributes( "Distance-based Tessellation", "Miscellaneous", "Calculates tessellation based on distance from camera" )] + public sealed class DistanceBasedTessNode : TessellationParentNode + { + private const string FunctionBody = "UnityDistanceBasedTess( v0.vertex, v1.vertex, v2.vertex, {0},{1},{2})"; + protected override void CommonInit( int uniqueId ) + { + base.CommonInit( uniqueId ); + AddInputPort( WirePortDataType.FLOAT, false,"Factor"); + AddInputPort( WirePortDataType.FLOAT, false, "Min Dist" ); + AddInputPort( WirePortDataType.FLOAT, false, "Max Dist" ); + AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue ); + } + + protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector ) + { + return string.Format( FunctionBody, + m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ), + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ), + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) ); + } + } +} -- cgit v1.1-26-g67d0