public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            GeneratorUtils.RegisterUnity2019MatrixDefines(ref dataCollector);

            string result  = m_inputPorts[0].GeneratePortInstructions(ref dataCollector);
            string varName = string.Empty;

            if ((int)m_from == (int)m_to)
            {
                RegisterLocalVariable(0, result, ref dataCollector);
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            switch (m_from)
            {
            case TransformSpaceFrom.Object:
            {
                switch (m_to)
                {
                default:
                case TransformSpaceTo.Object: break;

                case TransformSpaceTo.World:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.View:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, CurrentPrecisionType);
                    CalculateTransform(m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseObjectToTangentDirVarName + OutputId;
                }
                break;
                }
            }
            break;

            case TransformSpaceFrom.World:
            {
                switch (m_to)
                {
                case TransformSpaceTo.Object:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                default:
                case TransformSpaceTo.World: break;

                case TransformSpaceTo.View:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, CurrentPrecisionType);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseWorldToTangentDirVarName + OutputId;
                }
                break;
                }
            }
            break;

            case TransformSpaceFrom.View:
            {
                switch (m_to)
                {
                case TransformSpaceTo.Object:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.World:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                default:
                case TransformSpaceTo.View: break;

                case TransformSpaceTo.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpaceTo.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, CurrentPrecisionType);
                    CalculateTransform(m_from, TransformSpaceTo.World, ref dataCollector, ref varName, ref result);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseViewToTangentDirVarName + OutputId;
                }
                break;
                }
            }
            break;

            //case TransformSpace.Clip:
            //{
            //	switch( m_to )
            //	{
            //		case TransformSpace.Object:
            //		{
            //			CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
            //		}
            //		break;
            //		case TransformSpace.World:
            //		{
            //			CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
            //		}
            //		break;
            //		case TransformSpace.View:
            //		{
            //			CalculateTransform( m_from, m_to, ref dataCollector, ref varName, ref result );
            //		}
            //		break;
            //		case TransformSpace.Clip: break;
            //		case TransformSpace.Tangent:
            //		{
            //			GeneratorUtils.GenerateWorldToTangentMatrix( ref dataCollector, UniqueId, CurrentPrecisionType );
            //			CalculateTransform( m_from, TransformSpace.World, ref dataCollector, ref varName, ref result );
            //			result = string.Format( ASEWorldToTangentFormat, result );
            //			varName = AseClipToTangentDirVarName + OutputId;
            //		}
            //		break;
            //		default:
            //		break;
            //	}
            //}break;
            case TransformSpaceFrom.Tangent:
            {
                string matrixVal = string.Empty;
                if (m_inverseTangentType == InverseTangentType.Fast)
                {
                    matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast(ref dataCollector, UniqueId, CurrentPrecisionType);
                }
                else
                {
                    matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise(ref dataCollector, UniqueId, CurrentPrecisionType);
                }

                switch (m_to)
                {
                case TransformSpaceTo.Object:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToObjectDirVarName + OutputId;
                }
                break;

                case TransformSpaceTo.World:
                {
                    result  = string.Format(ASEMulOpFormat, matrixVal, result);
                    varName = AseTangentToWorldDirVarName + OutputId;
                }
                break;

                case TransformSpaceTo.View:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToViewDirVarName + OutputId;
                }
                break;

                case TransformSpaceTo.Clip:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpaceFrom.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToClipDirVarName + OutputId;
                }
                break;

                case TransformSpaceTo.Tangent:
                default:
                    break;
                }
            }
            break;

            default: break;
            }

            if (m_normalize)
            {
                result = string.Format(NormalizeFunc, result);
            }

            RegisterLocalVariable(0, result, ref dataCollector, varName);
            return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
        }
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            string result  = m_inputPorts[0].GeneratePortInstructions(ref dataCollector);
            string varName = string.Empty;

            switch (m_from)
            {
            case TransformSpace.Object:
            {
                switch (m_to)
                {
                default:
                case TransformSpace.Object: break;

                case TransformSpace.World:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.View:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, m_currentPrecisionType);
                    CalculateTransform(m_from, TransformSpace.World, ref dataCollector, ref varName, ref result);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseObjectToTangentPosVarName;
                }
                break;
                }
            }
            break;

            case TransformSpace.World:
            {
                switch (m_to)
                {
                case TransformSpace.Object:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                default:
                case TransformSpace.World: break;

                case TransformSpace.View:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, m_currentPrecisionType);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseWorldToTangentPosVarName;
                }
                break;
                }
            }
            break;

            case TransformSpace.View:
            {
                switch (m_to)
                {
                case TransformSpace.Object:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.World:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);;
                }
                break;

                default:
                case TransformSpace.View: break;

                case TransformSpace.Clip:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, m_currentPrecisionType);
                    CalculateTransform(m_from, TransformSpace.World, ref dataCollector, ref varName, ref result);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseViewToTangentPosVarName;
                }
                break;
                }
            }
            break;

            case TransformSpace.Clip:
            {
                switch (m_to)
                {
                case TransformSpace.Object:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.World:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.View:
                {
                    CalculateTransform(m_from, m_to, ref dataCollector, ref varName, ref result);
                }
                break;

                case TransformSpace.Clip: break;

                case TransformSpace.Tangent:
                {
                    GeneratorUtils.GenerateWorldToTangentMatrix(ref dataCollector, UniqueId, m_currentPrecisionType);
                    CalculateTransform(m_from, TransformSpace.World, ref dataCollector, ref varName, ref result);
                    result  = string.Format(ASEWorldToTangentFormat, result);
                    varName = AseClipToTangentPosVarName;
                }
                break;

                default:
                    break;
                }
            }
            break;

            case TransformSpace.Tangent:
            {
                string matrixVal = string.Empty;
                if (m_inverseTangentType == InverseTangentType.Fast)
                {
                    matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixFast(ref dataCollector, UniqueId, m_currentPrecisionType);
                }
                else
                {
                    matrixVal = GeneratorUtils.GenerateTangentToWorldMatrixPrecise(ref dataCollector, UniqueId, m_currentPrecisionType);
                }

                switch (m_to)
                {
                case TransformSpace.Object:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpace.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToObjectPosVarName;
                }
                break;

                case TransformSpace.World:
                {
                    result  = string.Format(ASEMulOpFormat, matrixVal, result);
                    varName = AseTangentToWorldPosVarName;
                }
                break;

                case TransformSpace.View:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpace.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToViewPosVarName;
                }
                break;

                case TransformSpace.Clip:
                {
                    result = string.Format(ASEMulOpFormat, matrixVal, result);
                    CalculateTransform(TransformSpace.World, m_to, ref dataCollector, ref varName, ref result);
                    varName = AseTangentToClipPosVarName;
                }
                break;

                case TransformSpace.Tangent:
                default:
                    break;
                }
            }
            break;

            default: break;
            }

            if (m_to == TransformSpace.Clip)
            {
                if (m_perspectiveDivide)
                {
                    dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, varName, result);
                    result   = string.Format(AseClipToNDC, varName);
                    varName += "NDC";
                }
                else
                {
                    result += ".xyz";
                }
            }

            RegisterLocalVariable(0, result, ref dataCollector, varName);
            return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
        }