EdgeLengthCullTessNode.cs 1.1 KB

123456789101112131415161718192021222324252627
  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 With Cull", "Miscellaneous", "Tessellation level computed based on triangle edge length on the screen with patch frustum culling" )]
  7. public sealed class EdgeLengthCullTessNode : TessellationParentNode
  8. {
  9. private const string FunctionBody = "UnityEdgeLengthBasedTessCull( v0.vertex, v1.vertex, v2.vertex, {0},{1})";
  10. protected override void CommonInit( int uniqueId )
  11. {
  12. base.CommonInit( uniqueId );
  13. AddInputPort( WirePortDataType.FLOAT, false, "Edge Length" );
  14. AddInputPort( WirePortDataType.FLOAT, false, "Max Disp." );
  15. AddOutputPort( WirePortDataType.FLOAT4, Constants.EmptyPortValue );
  16. }
  17. protected override string BuildTessellationFunction( ref MasterNodeDataCollector dataCollector )
  18. {
  19. return string.Format( FunctionBody,
  20. m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ),
  21. m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ) );
  22. }
  23. }
  24. }