EdgeLengthTessNode.cs 929 B

1234567891011121314151617181920212223
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. namespace AmplifyShaderEditor
  4. {
  5. [System.Serializable]
  6. [NodeAttributes( "Edge Length Tessellation", "Miscellaneous", "Tessellation level computed based on triangle edge length on the screen" )]
  7. public sealed class EdgeLengthTessNode : TessellationParentNode
  8. {
  9. private const string FunctionBody = "UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, {0})";
  10. protected override void CommonInit( int uniqueId )
  11. {
  12. base.CommonInit( uniqueId );
  13. AddInputPort( WirePortDataType.FLOAT, false, "Edge Length" );
  14. AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue );
  15. }
  16. protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector )
  17. {
  18. return string.Format( FunctionBody, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) );
  19. }
  20. }
  21. }