You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. namespace AmplifyShaderEditor
  5. {
  6. [Serializable]
  7. [NodeAttributes( "Fmod", "Math Operators", "Floating point remainder of x/y with the same sign as x" )]
  8. public sealed class FmodOpNode : DynamicTypeNode
  9. {
  10. protected override void CommonInit( int uniqueId )
  11. {
  12. base.CommonInit( uniqueId );
  13. m_previewShaderGUID = "65083930f9d7812479fd6ff203ad2992";
  14. }
  15. public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  16. {
  17. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  18. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  19. base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
  20. if( m_inputPorts[ 0 ].DataType == WirePortDataType.INT )
  21. m_inputA = "(float)" + m_inputA;
  22. if( m_inputPorts[ 1 ].DataType == WirePortDataType.INT )
  23. m_inputB = "(float)" + m_inputB;
  24. string result = "fmod( " + m_inputA + " , " + m_inputB + " )";
  25. return CreateOutputLocalVariable( 0, result, ref dataCollector );
  26. }
  27. }
  28. }