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.

41 lines
1.5 KiB

  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. public class ParentTransfNode : ParentNode
  7. {
  8. protected string m_matrixName;
  9. protected string m_matrixHDName;
  10. protected override void CommonInit( int uniqueId )
  11. {
  12. base.CommonInit( uniqueId );
  13. AddInputPort( WirePortDataType.FLOAT4, false, string.Empty );
  14. AddOutputVectorPorts( WirePortDataType.FLOAT4, "XYZW" );
  15. m_useInternalPortData = true;
  16. m_inputPorts[ 0 ].Vector4InternalData = new UnityEngine.Vector4( 0, 0, 0, 1 );
  17. }
  18. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  19. {
  20. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  21. return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
  22. string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
  23. string matrixName = string.Empty;
  24. if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_matrixHDName ) )
  25. {
  26. matrixName = m_matrixHDName;
  27. }
  28. else
  29. {
  30. matrixName = m_matrixName;
  31. }
  32. RegisterLocalVariable( 0, string.Format( "mul({0},{1})", matrixName, value ),ref dataCollector,"transform"+ OutputId );
  33. return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) );
  34. }
  35. }
  36. }