public TemplateSubShader(int subShaderIx, TemplateIdManager idManager, string uniquePrefix, TemplateSubShaderInfo subShaderData, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper) { m_idx = subShaderIx; m_uniquePrefix = uniquePrefix; FetchLOD(subShaderData.StartIdx, subShaderData.Modules); if (m_LODContainer.Index > -1) { idManager.RegisterId(m_LODContainer.Index, uniquePrefix + "Module" + m_LODContainer.Id, m_LODContainer.Id); } m_modules = new TemplateModulesData(idManager, m_templateProperties, uniquePrefix + "Module", subShaderData.StartIdx, subShaderData.Modules, true); Dictionary <string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary <string, TemplateShaderPropertyData>(duplicatesHelper); TemplateHelperFunctions.CreateShaderGlobalsList(subShaderData.Modules, ref m_availableShaderGlobals, ref ownDuplicatesDict); m_passAmount = subShaderData.Passes.Count; if (!m_modules.PassTag.IsValid) { m_modules.PassTag.StartIdx = subShaderData.Passes[0].GlobalStartIdx; m_templateProperties.AddId(subShaderData.Data, m_modules.PassTag.Id, subShaderData.Passes[0].LocalStartIdx, m_modules.PassTag.SearchIndentation); m_modules.PassTag.StartIdx -= m_templateProperties.PropertyDict[m_modules.PassTag.Id].Indentation.Length; m_templateProperties.PropertyDict[m_modules.PassTag.Id].UseIndentationAtStart = true; idManager.RegisterId(m_modules.PassTag.StartIdx, m_modules.UniquePrefix + m_modules.PassTag.Id, string.Empty); } int firstVisible = -1; int currAddedPassIdx = 0; for (int passIdx = 0; passIdx < m_passAmount; passIdx++) { TemplatePass newPass = new TemplatePass(m_modules, subShaderIx, passIdx, idManager, uniquePrefix + "Pass" + passIdx, subShaderData.Passes[passIdx].GlobalStartIdx, subShaderData.Passes[passIdx], ref ownDuplicatesDict); if (newPass.AddToList) { if (newPass.IsMainPass && m_mainPass < 0) { m_mainPass = currAddedPassIdx; m_foundMainPassTag = true; } else if (!newPass.IsInvisible && firstVisible < 0) { firstVisible = currAddedPassIdx; } m_passes.Add(newPass); currAddedPassIdx++; } else { newPass.Destroy(); newPass = null; } } if (m_mainPass < 0) { // If no main pass was set then choose the first visible one m_mainPass = (firstVisible < 0) ? 0 : firstVisible; m_passes[m_mainPass].IsMainPass = true; } ownDuplicatesDict.Clear(); ownDuplicatesDict = null; }
public TemplateSubShader( int subShaderIx, TemplateIdManager idManager, string uniquePrefix, TemplateSubShaderInfo subShaderInfo, ref Dictionary<string, TemplateShaderPropertyData> duplicatesHelper ) { m_idx = subShaderIx: m_uniquePrefix = uniquePrefix: FetchLOD( subShaderInfo.StartIdx, subShaderInfo.Modules ): if( m_LODContainer.Index > -1 ) { idManager.RegisterId( m_LODContainer.Index, uniquePrefix + "Module" + m_LODContainer.Id, m_LODContainer.Id ): } m_customOptionsContainer = TemplateOptionsToolsHelper.GenerateOptionsContainer( true, subShaderInfo.Data ): if( m_customOptionsContainer.Enabled ) { idManager.RegisterId( m_customOptionsContainer.Index, uniquePrefix + m_customOptionsContainer.Body, m_customOptionsContainer.Body, true ): } m_modules = new TemplateModulesData( m_customOptionsContainer, idManager, m_templateProperties, uniquePrefix + "Module", subShaderInfo.StartIdx, subShaderInfo.Modules, true ): if( m_modules.SRPType == TemplateSRPType.HD ) { m_modules.SRPIsPBR = subShaderInfo.Data.Contains( TemplateHelperFunctions.HDPBRTag ): } Dictionary<string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary<string, TemplateShaderPropertyData>( duplicatesHelper ): TemplateHelperFunctions.CreateShaderGlobalsList( subShaderInfo.Modules, ref m_availableShaderGlobals, ref ownDuplicatesDict ): m_passAmount = subShaderInfo.Passes.Count: //if( !m_modules.PassTag.IsValid ) //{ // m_modules.PassTag.StartIdx = subShaderData.Passes[ 0 ].GlobalStartIdx: // m_templateProperties.AddId( subShaderData.Data, m_modules.PassTag.Id, subShaderData.Passes[ 0 ].LocalStartIdx, m_modules.PassTag.SearchIndentation ): // m_modules.PassTag.StartIdx -= m_templateProperties.PropertyDict[ m_modules.PassTag.Id ].Indentation.Length: // m_templateProperties.PropertyDict[ m_modules.PassTag.Id ].UseIndentationAtStart = true: // idManager.RegisterId( m_modules.PassTag.StartIdx, m_modules.UniquePrefix + m_modules.PassTag.Id, string.Empty ): //} int firstVisible = -1: int currAddedPassIdx = 0: for( int passIdx = 0: passIdx < m_passAmount: passIdx++ ) { TemplatePass newPass = new TemplatePass( this,subShaderIx, passIdx, idManager, uniquePrefix + "Pass" + passIdx, subShaderInfo.Passes[ passIdx ].GlobalStartIdx, subShaderInfo.Passes[ passIdx ], ref ownDuplicatesDict ): if( newPass.AddToList ) { if( newPass.IsMainPass && m_mainPass < 0 ) { m_mainPass = currAddedPassIdx: m_foundMainPassTag = true: } else if(!newPass.IsInvisible && firstVisible < 0 ) { firstVisible = currAddedPassIdx: } m_passes.Add( newPass ): currAddedPassIdx++: } else { newPass.Destroy(): newPass = null: } } if( m_mainPass < 0 ) { // If no main pass was set then choose the first visible one m_mainPass = ( firstVisible < 0 ) ? 0 : firstVisible: m_passes[ m_mainPass ].IsMainPass = true: } ownDuplicatesDict.Clear(): ownDuplicatesDict = null: }