Пример #1
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            GetInputData(ref dataCollector, ignoreLocalvar);

            string result = string.Empty;
            string avgSum = string.Empty;

            string localVarName = "weightedBlendVar" + m_uniqueId;

            dataCollector.AddToLocalVariables(m_uniqueId, m_currentPrecisionType, m_inputPorts[0].DataType, localVarName, m_inputData[0]);

            if (m_activeCount < 2)
            {
                return(CreateOutputLocalVariable(0, m_inputData[0], ref dataCollector));
            }
            else
            {
                for (int i = 0; i < m_activeCount; i++)
                {
                    result += localVarName + Constants.VectorSuffixes[i] + "*" + m_inputData[i + 1];
                    avgSum += localVarName + Constants.VectorSuffixes[i];
                    if (i != (m_activeCount - 1))
                    {
                        result += " + ";
                        avgSum += " + ";
                    }
                }
            }

            result = UIUtils.AddBrackets(result) + "/" + UIUtils.AddBrackets(avgSum);
            result = UIUtils.AddBrackets(result);
            return(CreateOutputLocalVariable(0, result, ref dataCollector));
        }
Пример #2
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            GetInputData(ref dataCollector, ignoreLocalvar);

            string result       = string.Empty;
            string localVarName = "layeredBlendVar" + m_uniqueId;

            dataCollector.AddToLocalVariables(m_uniqueId, m_currentPrecisionType, m_inputPorts[0].DataType, localVarName, m_inputData[0]);

            if (m_activeCount == 1)
            {
                result = m_inputData[0];
            }
            else if (m_activeCount == 2)
            {
                result += "lerp( " + m_inputData[1] + "," + m_inputData[2] + " , " + localVarName + " )";
            }
            else
            {
                result = m_inputData[1];
                for (int i = 1; i < m_activeCount; i++)
                {
                    result = "lerp( " + result + " , " + m_inputData[i + 1] + " , " + localVarName + Constants.VectorSuffixes[i - 1] + " )";
                }
            }
            result = UIUtils.AddBrackets(result);
            return(CreateOutputLocalVariable(0, result, ref dataCollector));
        }
Пример #3
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):

			GetInputData( ref dataCollector, ignoreLocalvar ):

			string result = string.Empty:
			string localVarName = "weightedBlendVar" + OutputId:
			dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].DataType, localVarName, m_inputData[ 0 ] ):

			if ( m_activeCount == 0 )
			{
				result = m_inputData[ 0 ]:
			}
			else if ( m_activeCount == 1 )
			{
				result += localVarName + "*" + m_inputData[ 1 ]:
			}
			else
			{
				for ( int i = 0: i < m_activeCount: i++ )
				{
					result += localVarName + Constants.VectorSuffixes[ i ] + "*" + m_inputData[ i + 1 ]:
					if ( i != ( m_activeCount - 1 ) )
					{
						result += " + ":
					}
				}
			}

			result = UIUtils.AddBrackets( result ):
			RegisterLocalVariable( 0, result, ref dataCollector, "weightedBlend" + OutputId ):
			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
Пример #4
0
        public override string GenerateShaderForOutput(int outputId, WirePortDataType inputPortType, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            string result = string.Empty;

            string colorTarget = m_inputPorts[0].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar);

            WirePortDataType dataType = m_inputPorts[0].ConnectionType();

            if (dataType != WirePortDataType.COLOR && dataType != WirePortDataType.FLOAT4)
            {
                colorTarget = UIUtils.CastPortType(new NodeCastInfo(m_uniqueId, outputId), null, dataType, WirePortDataType.FLOAT4, colorTarget);
            }

            string localVarName = "ChannelBlendNode" + m_uniqueId;
            string localVar     = "float4 " + localVarName + " = " + colorTarget + ";";

            dataCollector.AddToLocalVariables(m_uniqueId, localVar);
            m_inputPorts[1].InternalData = m_inputPorts[1].IsConnected ? m_inputPorts[1].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar) : m_defaultAmounts[0].ToString();
            m_inputPorts[2].InternalData = m_inputPorts[2].IsConnected ? m_inputPorts[2].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar) : m_defaultAmounts[1].ToString();
            m_inputPorts[3].InternalData = m_inputPorts[3].IsConnected ? m_inputPorts[3].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar) : m_defaultAmounts[2].ToString();
            m_inputPorts[4].InternalData = m_inputPorts[4].IsConnected ? m_inputPorts[4].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar) : m_defaultAmounts[3].ToString();

            if (m_isLayered)
            {
                string           layerMask = m_inputPorts[4].IsConnected ? m_inputPorts[4].GenerateShaderForOutput(ref dataCollector, inputPortType, ignoreLocalvar) : m_defaultLayerFactor.ToString();
                WirePortDataType dataType4 = m_inputPorts[4].ConnectionType();
                if (dataType4 != WirePortDataType.FLOAT)
                {
                    layerMask = UIUtils.CastPortType(new NodeCastInfo(m_uniqueId, outputId), null, dataType4, WirePortDataType.FLOAT, layerMask);
                }

                if (m_activePorts == 0)
                {
                    result = colorTarget;
                }
                else if (m_activePorts == 1)
                {
                    result += "lerp( " + layerMask + "," + m_inputPorts[1].InternalData + " , " + localVarName + ".r )";
                }
                else
                {
                    result = layerMask;
                    for (int i = 0; i < m_activePorts; i++)
                    {
                        result = "lerp( " + result + " , " + m_inputPorts[i + 1].InternalData + " , " + localVarName + UIUtils.GetComponentForPosition(i, m_inputPorts[0].DataType, true) + " )";
                    }
                }
            }
            else
            {
                if (m_activePorts == 0)
                {
                    result = colorTarget;
                }
                else if (m_activePorts == 1)
                {
                    result += localVarName + "*" + m_inputPorts[1].InternalData;
                }
                else
                {
                    for (int i = 1; i < (m_activePorts + 1); i++)
                    {
                        result += localVarName + UIUtils.GetComponentForPosition(i - 1, m_inputPorts[0].DataType, true) + "*" + m_inputPorts[i].InternalData;
                        if (i != m_activePorts)
                        {
                            result += " + ";
                        }
                    }
                }
            }
            result = UIUtils.AddBrackets(result);
            return(CreateOutputLocalVariable(0, result, ref dataCollector));
        }