public static void CreateShaderGlobalsList(string propertyData, ref List <TemplateShaderPropertyData> propertiesList, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper)
        {
            int typeIdx = (int)TemplateShaderGlobalsIdx.Type;
            int nameIdx = (int)TemplateShaderGlobalsIdx.Name;

            foreach (Match globalMatch in Regex.Matches(propertyData, ShaderGlobalsOverallPattern))
            {
                if (globalMatch.Groups.Count > 0)
                {
                    foreach (Match lineMatch in Regex.Matches(globalMatch.Groups[0].Value, ShaderGlobalsMultilinePattern, RegexOptions.Multiline))
                    {
                        if (lineMatch.Groups.Count > 1)
                        {
                            if (!duplicatesHelper.ContainsKey(lineMatch.Groups[nameIdx].Value) && CgToWirePortType.ContainsKey(lineMatch.Groups[typeIdx].Value))
                            {
                                TemplateShaderPropertyData newData = new TemplateShaderPropertyData(string.Empty, lineMatch.Groups[nameIdx].Value,
                                                                                                    CgToWirePortType[lineMatch.Groups[typeIdx].Value],
                                                                                                    PropertyType.Global);
                                duplicatesHelper.Add(newData.PropertyName, newData);
                                propertiesList.Add(newData);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void FillDataCollector(TemplateMultiPassMasterNode owner, ref MasterNodeDataCollector dataCollector)
        {
            InputPort port = null;

            if (m_portId > -1)
            {
                port = owner.GetInputPortByUniqueId(m_portId);
            }
            else
            {
                port = owner.InputPorts.Find(x => x.Name.Equals(m_options.Name));
            }

            if (port != null)
            {
                int optionId = port.HasOwnOrLinkConnection ? 0 : 1;
                for (int i = 0; i < m_options.ActionsPerOption[optionId].Length; i++)
                {
                    switch (m_options.ActionsPerOption[optionId][i].ActionType)
                    {
                    case AseOptionsActionType.SetDefine:
                    {
                        List <TemplateMultiPassMasterNode> nodes = owner.ContainerGraph.GetMultiPassMasterNodes(owner.LODIndex);
                        int count = nodes.Count;
                        for (int nodeIdx = 0; nodeIdx < count; nodeIdx++)
                        {
                            nodes[nodeIdx].OptionsDefineContainer.AddDefine("#define " + m_options.ActionsPerOption[optionId][i].ActionData, false);
                        }
                        //dataCollector.AddToDefines( -1, m_options.ActionsPerOption[ optionId ][ i ].ActionData );
                    }
                    break;

                    case AseOptionsActionType.SetUndefine:
                    {
                        List <TemplateMultiPassMasterNode> nodes = owner.ContainerGraph.GetMultiPassMasterNodes(owner.LODIndex);
                        int count = nodes.Count;
                        for (int nodeIdx = 0; nodeIdx < count; nodeIdx++)
                        {
                            nodes[nodeIdx].OptionsDefineContainer.AddDefine("#undef " + m_options.ActionsPerOption[optionId][i].ActionData, false);
                        }
                        //dataCollector.AddToDefines( -1, m_options.ActionsPerOption[ optionId ][ i ].ActionData, false );
                    }
                    break;

                    case AseOptionsActionType.SetShaderProperty:
                    {
                        TemplateShaderPropertyData data = owner.CurrentTemplate.GetShaderPropertyData(m_options.ActionsPerOption[optionId][i].ActionData);
                        if (data != null)
                        {
                            string newPropertyValue = data.CreatePropertyForValue(m_options.ActionsPerOption[optionId][i].ActionBuffer);
                            owner.CurrentTemplate.IdManager.SetReplacementText(data.FullValue, newPropertyValue);
                        }
                    }
                    break;
                    }
                }
            }
        }
 public void TestPropertyInternalName(string name, ref List <TemplateShaderPropertyData> availableShaderProperties, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper)
 {
     if (!string.IsNullOrEmpty(name) && !duplicatesHelper.ContainsKey(name))
     {
         TemplateShaderPropertyData newData = new TemplateShaderPropertyData(-1, string.Empty, string.Empty, name, name, WirePortDataType.INT, PropertyType.Property);
         availableShaderProperties.Add(newData);
         duplicatesHelper.Add(newData.PropertyName, newData);
     }
 }
Exemple #4
0
        public void SubShaderFillDataCollector(TemplateMultiPassMasterNode owner, ref MasterNodeDataCollector dataCollector)
        {
            //TemplateMultiPassMasterNode targetNode = string.IsNullOrEmpty(m_options.Id) ? owner:owner.ContainerGraph.GetMasterNodeOfPass( m_options.Id , owner.LODIndex );
            TemplateMultiPassMasterNode targetNode = string.IsNullOrEmpty(m_options.Id) ?
                                                     owner.ContainerGraph.GetMainMasterNodeOfLOD(owner.LODIndex) :
                                                     owner.ContainerGraph.GetMasterNodeOfPass(m_options.Id, owner.LODIndex);

            InputPort port = null;

            if (m_portId > -1)
            {
                port = targetNode.GetInputPortByUniqueId(m_portId);
            }
            else
            {
                port = targetNode.InputPorts.Find(x => x.Name.Equals(m_options.Name));
            }

            if (port != null)
            {
                int optionId = port.HasOwnOrLinkConnection ? 0 : 1;
                for (int i = 0; i < m_options.ActionsPerOption[optionId].Length; i++)
                {
                    if (string.IsNullOrEmpty(m_options.ActionsPerOption[optionId][i].PassName) ||
                        m_options.ActionsPerOption[optionId][i].PassName.Equals(owner.PassName))
                    {
                        switch (m_options.ActionsPerOption[optionId][i].ActionType)
                        {
                        case AseOptionsActionType.SetDefine:
                        {
                            owner.OptionsDefineContainer.AddDefine("#define " + m_options.ActionsPerOption[optionId][i].ActionData, true);
                        }
                        break;

                        case AseOptionsActionType.SetUndefine:
                        {
                            owner.OptionsDefineContainer.AddDefine("#undef " + m_options.ActionsPerOption[optionId][i].ActionData, true);
                        }
                        break;

                        case AseOptionsActionType.SetShaderProperty:
                        {
                            TemplateShaderPropertyData data = owner.CurrentTemplate.GetShaderPropertyData(m_options.ActionsPerOption[optionId][i].ActionData);
                            if (data != null)
                            {
                                string newPropertyValue = data.CreatePropertyForValue(m_options.ActionsPerOption[optionId][i].ActionBuffer);
                                owner.CurrentTemplate.IdManager.SetReplacementText(data.FullValue, newPropertyValue);
                            }
                        }
                        break;
                        }
                    }
                }
            }
        }
        public static void CreateShaderPropertiesList(string propertyData, ref List <TemplateShaderPropertyData> propertiesList, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper)
        {
            int nameIdx = (int)TemplateShaderPropertiesIdx.Name;
            int typeIdx = (int)TemplateShaderPropertiesIdx.Type;

            foreach (Match match in Regex.Matches(propertyData, PropertiesPatternB))
            {
                if (match.Groups.Count > 1)
                {
                    if (!duplicatesHelper.ContainsKey(match.Groups[nameIdx].Value) && PropertyToWireType.ContainsKey(match.Groups[typeIdx].Value))
                    {
                        TemplateShaderPropertyData newData = new TemplateShaderPropertyData(match.Groups[(int)TemplateShaderPropertiesIdx.InspectorName].Value,
                                                                                            match.Groups[nameIdx].Value,
                                                                                            PropertyToWireType[match.Groups[typeIdx].Value],
                                                                                            PropertyType.Property);
                        propertiesList.Add(newData);
                        duplicatesHelper.Add(newData.PropertyName, newData);
                    }
                }
            }
        }
Exemple #6
0
		//This should only be used on template internal properties
		public void PropertyNameFromTemplate( TemplateShaderPropertyData data )
		{
			m_propertyName = data.PropertyName:
			m_propertyInspectorName = data.PropertyInspectorName:
		}