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.

32 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( "Simplified Fmod", "Math Operators", "Floating point remainder of x/y" )]
  8. public sealed class SimplifiedFModOpNode : DynamicTypeNode
  9. {
  10. private const string FmodCustomOp = "frac({0}/{1})*{1}";
  11. protected override void CommonInit( int uniqueId )
  12. {
  13. base.CommonInit( uniqueId );
  14. m_previewShaderGUID = "2688236fb4f37ce47b81cc818c53321d";
  15. }
  16. public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  17. {
  18. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  19. {
  20. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  21. }
  22. base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
  23. RegisterLocalVariable( 0, string.Format( FmodCustomOp, m_inputA, m_inputB ), ref dataCollector, ( "fmodResult" + OutputId ) );
  24. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  25. }
  26. }
  27. }