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.

35 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( "Cross", "Vector Operators", "Cross product of two three-component vectors ( A x B )", null, KeyCode.X )]
  9. public sealed class CrossProductOpNode : ParentNode
  10. {
  11. protected override void CommonInit( int uniqueId )
  12. {
  13. base.CommonInit( uniqueId );
  14. AddInputPort( WirePortDataType.FLOAT3, false, "Lhs" );
  15. AddInputPort( WirePortDataType.FLOAT3, false, "Rhs" );
  16. AddOutputPort( WirePortDataType.FLOAT3, "Out" );
  17. m_useInternalPortData = true;
  18. m_previewShaderGUID = "65a9be5cc7037654db8e148d669f03ee";
  19. }
  20. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
  21. {
  22. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  23. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  24. string lhsStr = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
  25. string rhsStr = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector );
  26. string result = "cross( " + lhsStr + " , " + rhsStr + " )";
  27. return CreateOutputLocalVariable( 0, result, ref dataCollector );
  28. }
  29. }
  30. }