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.

34 lines
1.3 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using UnityEngine;
  5. namespace AmplifyShaderEditor
  6. {
  7. [Serializable]
  8. [NodeAttributes( "Dot", "Vector Operators", "Scalar dot product of two vectors ( A . B )", null, KeyCode.Period )]
  9. public sealed class DotProductOpNode : DynamicTypeNode
  10. {
  11. protected override void CommonInit( int uniqueId )
  12. {
  13. base.CommonInit( uniqueId );
  14. m_inputPorts[ 0 ].ChangeType( WirePortDataType.FLOAT4, false );
  15. m_inputPorts[ 1 ].ChangeType( WirePortDataType.FLOAT4, false );
  16. m_dynamicOutputType = false;
  17. m_useInternalPortData = true;
  18. m_allowMatrixCheck = true;
  19. m_previewShaderGUID = "85f11fd5cb9bb954c8615a45c57a3784";
  20. }
  21. public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  22. {
  23. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  24. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  25. base.BuildResults( outputId, ref dataCollector, ignoreLocalvar );
  26. string result = "dot( " + m_inputA + " , " + m_inputB + " )";
  27. RegisterLocalVariable( 0, result, ref dataCollector, "dotResult" + OutputId );
  28. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  29. }
  30. }
  31. }