示例#1
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;
                    }
                }
            }
        }
示例#2
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;
                        }
                    }
                }
            }
        }