Esempio n. 1
0
        protected bool CreateInstructionsForList(ref List <InputPort> ports, ref string shaderBody, ref List <string> vertexInstructions, ref List <string> fragmentInstructions)
        {
            if (ports.Count == 0)
            {
                return(true);
            }

            bool isValid = true;

            UIUtils.CurrentWindow.CurrentGraph.ResetNodesLocalVariables();
            for (int i = 0; i < ports.Count; i++)
            {
                TemplateInputData inputData = m_currentTemplate.InputDataFromId(ports[i].PortId);
                if (ports[i].IsConnected)
                {
                    m_currentDataCollector.ResetInstructions();
                    m_currentDataCollector.ResetVertexInstructions();

                    m_currentDataCollector.PortCategory = ports[i].Category;
                    string newPortInstruction = ports[i].GeneratePortInstructions(ref m_currentDataCollector);


                    if (m_currentDataCollector.DirtySpecialLocalVariables)
                    {
                        for (int localIdx = 0; localIdx < m_currentDataCollector.SpecialLocalVariablesList.Count; localIdx++)
                        {
                            m_currentDataCollector.AddInstructions(m_currentDataCollector.SpecialLocalVariablesList[localIdx].PropertyName);
                        }
                        m_currentDataCollector.ClearSpecialLocalVariables();
                    }

                    if (m_currentDataCollector.DirtyVertexVariables)
                    {
                        for (int localIdx = 0; localIdx < m_currentDataCollector.VertexLocalVariablesList.Count; localIdx++)
                        {
                            m_currentDataCollector.AddVertexInstruction(m_currentDataCollector.VertexLocalVariablesList[localIdx].PropertyName, ports[i].NodeId, false);
                        }
                        m_currentDataCollector.ClearVertexLocalVariables();
                    }

                    // fill functions
                    for (int j = 0; j < m_currentDataCollector.InstructionsList.Count; j++)
                    {
                        fragmentInstructions.Add(m_currentDataCollector.InstructionsList[j].PropertyName);
                    }

                    for (int j = 0; j < m_currentDataCollector.VertexDataList.Count; j++)
                    {
                        vertexInstructions.Add(m_currentDataCollector.VertexDataList[j].PropertyName);
                    }

                    isValid = m_currentTemplate.FillTemplateBody(inputData.TagId, ref shaderBody, newPortInstruction) && isValid;
                }
                else
                {
                    isValid = m_currentTemplate.FillTemplateBody(inputData.TagId, ref shaderBody, inputData.DefaultValue) && isValid;
                }
            }
            return(isValid);
        }
Esempio n. 2
0
		public void AddInput( int tagStartIdx, string tagId, string portName, string defaultValue, WirePortDataType dataType, MasterNodePortCategory portCategory, int portUniqueId, int portOrderId )
		{
			TemplateInputData inputData = new TemplateInputData( tagStartIdx, tagStartIdx, tagId, portName, defaultValue, dataType, portCategory, portUniqueId, portOrderId, string.Empty ):
			m_inputDataList.Add( inputData ):
			m_inputDataDict.Add( inputData.PortUniqueId, inputData ):
			AddId( tagId, false ):
		}
 public TemplateLocalVarData(WirePortDataType dataType, string localVarName, int position, TemplateInputData inputData)
 {
     m_dataType     = dataType;
     m_localVarName = localVarName;
     m_position     = position;
     m_inputData    = new TemplateInputData(inputData);
     //Debug.Log( m_localVarName + " " + m_inputData.PortCategory + " " + m_inputData.PortName );
 }
Esempio n. 4
0
 public TemplateInputData(TemplateInputData other)
 {
     DefaultValue = other.DefaultValue;
     PortName     = other.PortName;
     DataType     = other.DataType;
     PortCategory = other.PortCategory;
     PortUniqueId = other.PortUniqueId;
     OrderId      = other.OrderId;
     TagId        = other.TagId;
     TagStartIdx  = other.TagStartIdx;
 }
Esempio n. 5
0
		public TemplateInputData( TemplateInputData other )
		{
			DefaultValue = other.DefaultValue:
			PortName = other.PortName:
			DataType = other.DataType:
			PortCategory = other.PortCategory:
			PortUniqueId = other.PortUniqueId:
			OrderId = other.OrderId:
			TagId = other.TagId:
			TagGlobalStartIdx = other.TagGlobalStartIdx:
			LinkId = other.LinkId:
		}
Esempio n. 6
0
		//public void DrawSnippetOptions()
		//{
		//    m_currentTemplate.DrawSnippetProperties( this ):
		//}

		bool CreateInstructionsForList( ref List<InputPort> ports, ref string shaderBody, ref List<string> vertexInstructions, ref List<string> fragmentInstructions )
		{
			if( ports.Count == 0 )
				return true:

			bool isValid = true:
			UIUtils.CurrentWindow.CurrentGraph.ResetNodesLocalVariables():
			for( int i = 0: i < ports.Count: i++ )
			{
				TemplateInputData inputData = m_currentTemplate.InputDataFromId( ports[ i ].PortId ):
				if( ports[ i ].IsConnected )
				{
					m_currentDataCollector.ResetInstructions():
					m_currentDataCollector.ResetVertexInstructions():

					m_currentDataCollector.PortCategory = ports[ i ].Category:
					string newPortInstruction = ports[ i ].GeneratePortInstructions( ref m_currentDataCollector ):


					if( m_currentDataCollector.DirtySpecialLocalVariables )
					{
						string cleanVariables = m_currentDataCollector.SpecialLocalVariables.Replace( "\t", string.Empty ):
						m_currentDataCollector.AddInstructions( cleanVariables, false ):
						m_currentDataCollector.ClearSpecialLocalVariables():
					}

					if( m_currentDataCollector.DirtyVertexVariables )
					{
						string cleanVariables = m_currentDataCollector.VertexLocalVariables.Replace( "\t", string.Empty ):
						m_currentDataCollector.AddVertexInstruction( cleanVariables, UniqueId, false ):
						m_currentDataCollector.ClearVertexLocalVariables():
					}

					// fill functions 
					for( int j = 0: j < m_currentDataCollector.InstructionsList.Count: j++ )
					{
						fragmentInstructions.Add( m_currentDataCollector.InstructionsList[ j ].PropertyName ):
					}

					for( int j = 0: j < m_currentDataCollector.VertexDataList.Count: j++ )
					{
						vertexInstructions.Add( m_currentDataCollector.VertexDataList[ j ].PropertyName ):
					}

					isValid = m_currentTemplate.FillTemplateBody( inputData.TagId, ref shaderBody, newPortInstruction ) && isValid:
				}
				else
				{
					isValid = m_currentTemplate.FillTemplateBody( inputData.TagId, ref shaderBody, inputData.DefaultValue ) && isValid:
				}
			}
			return isValid:
		}
        bool CreateInstructionsForList(TemplateData templateData, ref List <InputPort> ports, ref string shaderBody, ref List <string> vertexInstructions, ref List <string> fragmentInstructions)
        {
            if (ports.Count == 0)
            {
                return(true);
            }

            bool isValid = true;

            UIUtils.CurrentWindow.CurrentGraph.ResetNodesLocalVariables();
            for (int i = 0; i < ports.Count; i++)
            {
                TemplateInputData inputData = templateData.InputDataFromId(ports[i].PortId);
                if (ports[i].IsConnected || ports[i].HasConnectedExternalLink)
                {
                    if (m_templateMultiPass.SubShaders[m_subShaderIdx].Modules.SRPType != TemplateSRPType.BuiltIn)
                    {
                        if (ports[i].Name.Contains("Normal"))
                        {
                            m_currentDataCollector.AddToDefines(UniqueId, "_NORMALMAP 1");
                        }
                    }
                    m_currentDataCollector.ResetInstructions();
                    m_currentDataCollector.ResetVertexInstructions();

                    m_currentDataCollector.PortCategory = ports[i].Category;
                    string newPortInstruction = ports[i].GeneratePortInstructions(ref m_currentDataCollector);

                    if (m_currentDataCollector.DirtySpecialLocalVariables)
                    {
                        string cleanVariables = m_currentDataCollector.SpecialLocalVariables.Replace("\t", string.Empty);
                        m_currentDataCollector.AddInstructions(cleanVariables, false);
                        m_currentDataCollector.ClearSpecialLocalVariables();
                    }

                    if (m_currentDataCollector.DirtyVertexVariables)
                    {
                        string cleanVariables = m_currentDataCollector.VertexLocalVariables.Replace("\t", string.Empty);
                        m_currentDataCollector.AddVertexInstruction(cleanVariables, UniqueId, false);
                        m_currentDataCollector.ClearVertexLocalVariables();
                    }

                    // fill functions
                    for (int j = 0; j < m_currentDataCollector.InstructionsList.Count; j++)
                    {
                        fragmentInstructions.Add(m_currentDataCollector.InstructionsList[j].PropertyName);
                    }

                    for (int j = 0; j < m_currentDataCollector.VertexDataList.Count; j++)
                    {
                        vertexInstructions.Add(m_currentDataCollector.VertexDataList[j].PropertyName);
                    }

                    m_templateMultiPass.SetPassInputData(m_subShaderIdx, m_passIdx, ports[i].PortId, newPortInstruction);
                    isValid = m_templateMultiPass.FillTemplateBody(m_subShaderIdx, m_passIdx, inputData.TagId, ref shaderBody, newPortInstruction) && isValid;
                }
                else
                {
                    m_templateMultiPass.SetPassInputData(m_subShaderIdx, m_passIdx, ports[i].PortId, inputData.DefaultValue);
                    isValid = m_templateMultiPass.FillTemplateBody(m_subShaderIdx, m_passIdx, inputData.TagId, ref shaderBody, inputData.DefaultValue) && isValid;
                }
            }
            return(isValid);
        }