BitangentVertexDataNode.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. [NodeAttributes( "Vertex Bitangent", "Vertex Data", "Calculated bitangent vector in object space, can be used in both local vertex offset and fragment outputs. Already has tangent sign and object transform into account" )]
  7. public sealed class BitangentVertexDataNode : ParentNode
  8. {
  9. protected override void CommonInit( int uniqueId )
  10. {
  11. base.CommonInit( uniqueId );
  12. AddOutputVectorPorts( WirePortDataType.FLOAT3, "XYZ" );
  13. m_drawPreviewAsSphere = true;
  14. m_previewShaderGUID = "76873532ab67d2947beaf07151383cbe";
  15. }
  16. public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
  17. {
  18. base.PropagateNodeData( nodeData, ref dataCollector );
  19. dataCollector.DirtyNormal = true;
  20. }
  21. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
  22. {
  23. if ( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
  24. {
  25. dataCollector.ForceNormal = true;
  26. dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
  27. dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false );
  28. }
  29. string vertexBitangent = GeneratorUtils.GenerateVertexBitangent( ref dataCollector, UniqueId, CurrentPrecisionType );
  30. return GetOutputVectorItem( 0, outputId, vertexBitangent );
  31. }
  32. }
  33. }