BlendIndicesNode.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace AmplifyShaderEditor
  7. {
  8. [Serializable]
  9. [NodeAttributes( "Bone Blend Indices" , "Vertex Data" , "Bone indices for skinned Meshes" )]
  10. public sealed class BlendIndicesNode : VertexDataNode
  11. {
  12. private const string IncorrectUnityVersionMessage = "This info is only available on Unity 2019.1 or above.";
  13. private const string StandardSurfaceErrorMessage = "This info is not available on standard surface shaders.";
  14. protected override void CommonInit( int uniqueId )
  15. {
  16. base.CommonInit( uniqueId );
  17. m_outputPorts[ 1 ].ChangeType( WirePortDataType.UINT , false );
  18. m_outputPorts[ 2 ].ChangeType( WirePortDataType.UINT , false );
  19. m_outputPorts[ 3 ].ChangeType( WirePortDataType.UINT , false );
  20. m_outputPorts[ 4 ].ChangeType( WirePortDataType.UINT , false );
  21. m_currentVertexData = GeneratorUtils.VertexBlendIndicesStr;
  22. m_errorMessageTypeIsError = NodeMessageType.Error;
  23. }
  24. public override void OnNodeLogicUpdate( DrawInfo drawInfo )
  25. {
  26. base.OnNodeLogicUpdate( drawInfo );
  27. if( UIUtils.CurrentWindow.OutsideGraph.IsStandardSurface )
  28. {
  29. if( !m_showErrorMessage )
  30. {
  31. m_showErrorMessage = true;
  32. m_errorMessageTooltip = StandardSurfaceErrorMessage;
  33. }
  34. }
  35. else
  36. {
  37. m_showErrorMessage = false;
  38. }
  39. }
  40. public override string GenerateShaderForOutput( int outputId , ref MasterNodeDataCollector dataCollector , bool ignoreLocalVar )
  41. {
  42. string blendIndices = string.Empty;
  43. if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
  44. {
  45. blendIndices = dataCollector.TemplateDataCollectorInstance.GetBlendIndices();
  46. return GetOutputVectorItem( 0 , outputId , blendIndices );
  47. }
  48. return GenerateErrorValue( outputId );
  49. }
  50. }
  51. }