public void OnLogicUpdate(TemplateModulesData currentModule)
 {
     if (currentModule.TagData.DataCheck == TemplateDataCheck.Valid)
     {
         m_tagsHelper.OnLogicUpdate();
     }
 }
Exemplo n.º 2
0
        void FetchVertexAndInterpData(TemplateModulesData subShaderModule, int offsetIdx, string body)
        {
            // Vertex Data
            try
            {
                int vertexDataTagBegin = body.IndexOf(TemplatesManager.TemplateVertexDataTag);
                if (vertexDataTagBegin > -1)
                {
                    m_vertexDataContainer = new VertexDataContainer();
                    m_vertexDataContainer.VertexDataStartIdx = offsetIdx + vertexDataTagBegin;
                    int vertexDataTagEnd = body.IndexOf(TemplatesManager.TemplateEndOfLine, vertexDataTagBegin);
                    m_vertexDataContainer.VertexDataId = body.Substring(vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin);
                    int    dataBeginIdx = body.LastIndexOf('{', vertexDataTagBegin, vertexDataTagBegin);
                    string vertexData   = body.Substring(dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx);

                    int    parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
                    string parameters      = body.Substring(parametersBegin, vertexDataTagEnd - parametersBegin);
                    m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList(vertexData, parameters);
                    m_templateProperties.AddId(body, m_vertexDataContainer.VertexDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            // Available interpolators
            try
            {
                int interpDataBegin = body.IndexOf(TemplatesManager.TemplateInterpolatorBeginTag);
                if (interpDataBegin > -1)
                {
                    int    interpDataEnd = body.IndexOf(TemplatesManager.TemplateEndOfLine, interpDataBegin);
                    string interpDataId  = body.Substring(interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin);

                    int    dataBeginIdx = body.LastIndexOf('{', interpDataBegin, interpDataBegin);
                    string interpData   = body.Substring(dataBeginIdx + 1, interpDataBegin - dataBeginIdx);

                    int interpolatorAmount = TemplateHelperFunctions.AvailableInterpolators["2.5"];

                    if (m_modules.ShaderModel.IsValid)
                    {
                        interpolatorAmount = m_modules.ShaderModel.InterpolatorAmount;
                    }
                    else if (subShaderModule.ShaderModel.IsValid)
                    {
                        interpolatorAmount = subShaderModule.ShaderModel.InterpolatorAmount;
                    }

                    m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList(interpData, interpDataId, interpolatorAmount);
                    m_interpolatorDataContainer.InterpDataId       = interpDataId;
                    m_interpolatorDataContainer.InterpDataStartIdx = offsetIdx + interpDataBegin;
                    m_templateProperties.AddId(body, interpDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Exemplo n.º 3
0
        public void Destroy()
        {
            m_passNameContainer = null;
            if (m_templateProperties != null)
            {
                m_templateProperties.Destroy();
            }
            m_templateProperties = null;

            if (m_modules != null)
            {
                m_modules.Destroy();
            }

            m_modules = null;

            if (m_inputDataList != null)
            {
                m_inputDataList.Clear();
            }

            m_inputDataList = null;

            if (m_inputDataDict != null)
            {
                m_inputDataDict.Clear();
            }

            m_inputDataDict = null;

            m_vertexFunctionData   = null;
            m_fragmentFunctionData = null;

            if (m_vertexDataContainer != null)
            {
                m_vertexDataContainer.Destroy();
            }

            m_vertexDataContainer = null;

            if (m_interpolatorDataContainer != null)
            {
                m_interpolatorDataContainer.Destroy();
            }

            if (m_localVarsList != null)
            {
                m_localVarsList.Clear();
                m_localVarsList = null;
            }

            m_interpolatorDataContainer = null;

            if (m_availableShaderGlobals != null)
            {
                m_availableShaderGlobals.Clear();
            }

            m_availableShaderGlobals = null;
        }
Exemplo n.º 4
0
        public void FetchDataFromTemplate(TemplateModulesData module)
        {
            if (module.PragmaTag.IsValid)
            {
                m_additionalPragmas.MarkAsValid();
                m_additionalPragmas.FillNativeItems(module.IncludePragmaContainer.PragmasList);

                m_additionalIncludes.MarkAsValid();
                m_additionalIncludes.FillNativeItems(module.IncludePragmaContainer.IncludesList);

                m_additionalDefines.MarkAsValid();
                m_additionalDefines.FillNativeItems(module.IncludePragmaContainer.DefinesList);
            }

            if (module.BlendData.DataCheck == TemplateDataCheck.Valid)
            {
                m_blendOpHelper.ConfigureFromTemplateData(module.BlendData);
                m_hasValidData = true;
            }

            if (module.CullModeData.DataCheck == TemplateDataCheck.Valid)
            {
                m_cullModeHelper.ConfigureFromTemplateData(module.CullModeData);
                m_hasValidData = true;
            }

            if (module.ColorMaskData.DataCheck == TemplateDataCheck.Valid)
            {
                m_colorMaskHelper.ConfigureFromTemplateData(module.ColorMaskData);
                m_hasValidData = true;
            }

            if (module.StencilData.DataCheck == TemplateDataCheck.Valid)
            {
                m_stencilBufferHelper.ConfigureFromTemplateData(module.StencilData);
                m_hasValidData = true;
            }

            if (module.DepthData.DataCheck == TemplateDataCheck.Valid)
            {
                m_depthOphelper.ConfigureFromTemplateData(module.DepthData);
                m_hasValidData = true;
            }

            if (module.TagData.DataCheck == TemplateDataCheck.Valid)
            {
                m_tagsHelper.ConfigureFromTemplateData(module.TagData);
                m_hasValidData = true;
            }

            if (module.ShaderModel.DataCheck == TemplateDataCheck.Valid)
            {
                m_shaderModelHelper.ConfigureFromTemplateData(module.ShaderModel);
                m_hasValidData = true;
            }
        }
Exemplo n.º 5
0
        public void Destroy()
        {
            m_LODContainer = null;

            m_templateProperties.Destroy();
            m_templateProperties = null;

            m_passes.Clear();
            m_passes = null;

            m_modules.Destroy();
            m_modules = null;

            m_availableShaderGlobals.Clear();
            m_availableShaderGlobals = null;
        }
Exemplo n.º 6
0
        public TemplatePass(TemplateSubShader subShader, int subshaderIdx, int passIdx, TemplateIdManager idManager, string uniquePrefix, int offsetIdx, TemplatePassInfo passInfo, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper)
        {
            m_idx = passIdx;

            m_uniquePrefix = uniquePrefix;
            idManager.RegisterPassId(passInfo.Data);
            m_isMainPass = passInfo.Data.Contains(TemplatesManager.TemplateMainPassTag);
            if (!m_isMainPass)
            {
                string id      = string.Empty;
                int    idIndex = 0;
                m_isInvisible = TemplateHelperFunctions.FetchInvisibleInfo(passInfo.Data, ref m_invisibleOptions, ref id, ref idIndex);
                if (m_isInvisible)
                {
                    idManager.RegisterId(idIndex, uniquePrefix + id, id, true);
                }
            }

            FetchPassName(offsetIdx, passInfo.Data);
            if (m_passNameContainer.Index > -1)
            {
                idManager.RegisterId(m_passNameContainer.Index, uniquePrefix + m_passNameContainer.Id, m_passNameContainer.Id);
            }
            else
            {
                m_passNameContainer.Data = string.Format(DefaultPassNameStr, subshaderIdx, passIdx);
            }

#if CUSTOM_OPTIONS_AVAILABLE
            m_customOptionsContainer = TemplateOptionsToolsHelper.GenerateOptionsContainer(false, passInfo.Data);
            if (m_customOptionsContainer.Enabled)
            {
                idManager.RegisterId(m_customOptionsContainer.Index, uniquePrefix + m_customOptionsContainer.Body, m_customOptionsContainer.Body, true);
            }
            //m_customOptionsContainer.CopyPortOptionsFrom( subShader.CustomOptionsContainer, m_passNameContainer.Data );
#endif
            m_modules = new TemplateModulesData(m_customOptionsContainer, idManager, m_templateProperties, uniquePrefix + "Module", offsetIdx, passInfo.Data, false);

            if (!m_modules.PassTag.IsValid)
            {
                m_modules.PassTag.StartIdx = passInfo.GlobalStartIdx;
                m_templateProperties.AddId(passInfo.Data, m_modules.PassTag.Id, passInfo.LocalStartIdx, false);
                //m_modules.PassTag.StartIdx -= m_templateProperties.PropertyDict[ m_modules.PassTag.Id ].Indentation.Length;
                //m_templateProperties.PropertyDict[ m_modules.PassTag.Id ].UseIndentationAtStart = false;
                idManager.RegisterId(m_modules.PassTag.StartIdx, m_modules.UniquePrefix + m_modules.PassTag.Id, string.Empty);
            }
            m_modules.SetPassUniqueNameIfUndefined(m_passNameContainer.Data);

            m_modules.SRPType = subShader.Modules.SRPType;
            if (m_modules.SRPType == TemplateSRPType.HD)
            {
                m_modules.SRPIsPBR = passInfo.Data.Contains(TemplateHelperFunctions.HDPBRTag);
            }

            Dictionary <string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary <string, TemplateShaderPropertyData>(duplicatesHelper);
            TemplateHelperFunctions.CreateShaderGlobalsList(passInfo.Data, ref m_availableShaderGlobals, ref ownDuplicatesDict);

            // Vertex and Interpolator data
            FetchVertexAndInterpData(subShader.Modules, offsetIdx, passInfo.Data);
            if (m_vertexDataContainer != null)
            {
                idManager.RegisterId(m_vertexDataContainer.VertexDataStartIdx, uniquePrefix + m_vertexDataContainer.VertexDataId, m_vertexDataContainer.VertexDataId);
            }

            if (m_interpolatorDataContainer != null)
            {
                idManager.RegisterId(m_interpolatorDataContainer.InterpDataStartIdx, uniquePrefix + m_interpolatorDataContainer.InterpDataId, m_interpolatorDataContainer.InterpDataId);
            }

            //Fetch function code areas
            FetchCodeAreas(offsetIdx, TemplatesManager.TemplateVertexCodeBeginArea, MasterNodePortCategory.Vertex, passInfo.Data);
            if (m_vertexFunctionData != null)
            {
                idManager.RegisterId(m_vertexFunctionData.Position, uniquePrefix + m_vertexFunctionData.Id, m_vertexFunctionData.Id);
            }

            FetchCodeAreas(offsetIdx, TemplatesManager.TemplateFragmentCodeBeginArea, MasterNodePortCategory.Fragment, passInfo.Data);
            if (m_fragmentFunctionData != null)
            {
                idManager.RegisterId(m_fragmentFunctionData.Position, uniquePrefix + m_fragmentFunctionData.Id, m_fragmentFunctionData.Id);
            }

            //Fetching inputs, must be do
            if (m_fragmentFunctionData != null)
            {
                FetchInputs(offsetIdx, MasterNodePortCategory.Fragment, passInfo.Data);
            }

            if (m_vertexFunctionData != null)
            {
                FetchInputs(offsetIdx, MasterNodePortCategory.Vertex, passInfo.Data);
            }

            //Fetch local variables must be done after fetching code areas as it needs them to see is variable is on vertex or fragment
            TemplateHelperFunctions.FetchLocalVars(passInfo.Data, ref m_localVarsList, m_vertexFunctionData, m_fragmentFunctionData);

            int localVarCount = m_localVarsList.Count;
            if (localVarCount > 0)
            {
                idManager.RegisterTag(TemplatesManager.TemplateLocalVarTag);
                for (int i = 0; i < localVarCount; i++)
                {
                    if (m_localVarsList[i].IsSpecialVar)
                    {
                        idManager.RegisterTag(m_localVarsList[i].Id);
                    }
                }
            }

            int inputsCount = m_inputDataList.Count;
            for (int i = 0; i < inputsCount; i++)
            {
                if (m_inputDataList[i] != null)
                {
                    idManager.RegisterId(m_inputDataList[i].TagGlobalStartIdx, uniquePrefix + m_inputDataList[i].TagId, m_inputDataList[i].TagId);
                }
            }

            //int passEndIndex = passInfo.Data.LastIndexOf( "}" );
            //if( passEndIndex > 0 )
            //{
            //	int identationIndex = -1;
            //	for( int i = passEndIndex; i >= 0; i-- )
            //	{
            //		if( passInfo.Data[ i ] == TemplatesManager.TemplateNewLine )
            //		{
            //			identationIndex = i + 1;
            //			break;
            //		}

            //		if( i == 0 )
            //		{
            //			identationIndex = 0;
            //		}
            //	}

            //	if( identationIndex > -1 )
            //	{
            //		int length = passEndIndex - identationIndex;
            //		string indentation = ( length > 0 ) ? passInfo.Data.Substring( identationIndex, length ) : string.Empty;
            //		TemplateProperty templateProperty = new TemplateProperty( TemplatesManager.TemplateEndPassTag, indentation, false );
            //		m_templateProperties.AddId( templateProperty );
            //		idManager.RegisterId( offsetIdx + passEndIndex, uniquePrefix + TemplatesManager.TemplateEndPassTag, string.Empty );
            //	}
            //}

            ownDuplicatesDict.Clear();
            ownDuplicatesDict = null;
        }
Exemplo n.º 7
0
        public TemplatePass(int subshaderIdx, int passIdx, TemplateIdManager idManager, string uniquePrefix, int offsetIdx, TemplatePassInfo passInfo, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper)
        {
            m_idx = passIdx;

            m_uniquePrefix = uniquePrefix;

            m_isMainPass = passInfo.Data.Contains(TemplatesManager.TemplateMainPassTag);
            if (!m_isMainPass)
            {
                m_isInvisible = passInfo.Data.Contains(TemplatesManager.TemplateExcludeFromGraphTag);
            }

            FetchPassName(offsetIdx, passInfo.Data);
            if (m_passNameContainer.Index > -1)
            {
                idManager.RegisterId(m_passNameContainer.Index, uniquePrefix + m_passNameContainer.Id, m_passNameContainer.Id);
            }
            else
            {
                m_passNameContainer.Data = string.Format(DefaultPassNameStr, subshaderIdx, passIdx);
            }

            m_modules = new TemplateModulesData(idManager, m_templateProperties, uniquePrefix + "Module", offsetIdx, passInfo.Data, false);

            Dictionary <string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary <string, TemplateShaderPropertyData>(duplicatesHelper);

            TemplateHelperFunctions.CreateShaderGlobalsList(passInfo.Data, ref m_availableShaderGlobals, ref ownDuplicatesDict);

            // Vertex and Interpolator data
            FetchVertexAndInterpData(offsetIdx, passInfo.Data);
            if (m_vertexDataContainer != null)
            {
                idManager.RegisterId(m_vertexDataContainer.VertexDataStartIdx, uniquePrefix + m_vertexDataContainer.VertexDataId, m_vertexDataContainer.VertexDataId);
            }

            if (m_interpolatorDataContainer != null)
            {
                idManager.RegisterId(m_interpolatorDataContainer.InterpDataStartIdx, uniquePrefix + m_interpolatorDataContainer.InterpDataId, m_interpolatorDataContainer.InterpDataId);
            }

            //Fetch function code areas
            FetchCodeAreas(offsetIdx, TemplatesManager.TemplateVertexCodeBeginArea, MasterNodePortCategory.Vertex, passInfo.Data);
            if (m_vertexFunctionData != null)
            {
                idManager.RegisterId(m_vertexFunctionData.Position, uniquePrefix + m_vertexFunctionData.Id, m_vertexFunctionData.Id);
            }

            FetchCodeAreas(offsetIdx, TemplatesManager.TemplateFragmentCodeBeginArea, MasterNodePortCategory.Fragment, passInfo.Data);
            if (m_fragmentFunctionData != null)
            {
                idManager.RegisterId(m_fragmentFunctionData.Position, uniquePrefix + m_fragmentFunctionData.Id, m_fragmentFunctionData.Id);
            }

            //Fetching inputs, must be do
            if (m_fragmentFunctionData != null)
            {
                FetchInputs(offsetIdx, MasterNodePortCategory.Fragment, passInfo.Data);
            }

            if (m_vertexFunctionData != null)
            {
                FetchInputs(offsetIdx, MasterNodePortCategory.Vertex, passInfo.Data);
            }

            //Fetch local variables must be done after fetching code areas as it needs them to see is variable is on vertex or fragment
            TemplateHelperFunctions.FetchLocalVars(passInfo.Data, ref m_localVarsList, m_vertexFunctionData, m_fragmentFunctionData);

            int localVarCount = m_localVarsList.Count;

            if (localVarCount > 0)
            {
                idManager.RegisterTag(TemplatesManager.TemplateLocalVarTag);
                for (int i = 0; i < localVarCount; i++)
                {
                    if (m_localVarsList[i].IsSpecialVar)
                    {
                        idManager.RegisterTag(m_localVarsList[i].Id);
                    }
                }
            }

            int inputsCount = m_inputDataList.Count;

            for (int i = 0; i < inputsCount; i++)
            {
                if (m_inputDataList[i] != null)
                {
                    idManager.RegisterId(m_inputDataList[i].TagGlobalStartIdx, uniquePrefix + m_inputDataList[i].TagId, m_inputDataList[i].TagId);
                }
            }

            ownDuplicatesDict.Clear();
            ownDuplicatesDict = null;
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
		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:
		}
        public void Draw(ParentNode owner, TemplateModulesData currentModule, TemplateModulesHelper parent = null)
        {
            if (currentModule.ShaderModel.DataCheck == TemplateDataCheck.Valid)
            {
                m_shaderModelHelper.Draw(owner);
            }

            m_isDirty = m_shaderModelHelper.IsDirty;

            if (currentModule.CullModeData.DataCheck == TemplateDataCheck.Valid)
            {
                m_cullModeHelper.Draw(owner);
            }

            m_isDirty = m_isDirty || m_cullModeHelper.IsDirty;

            if (currentModule.ColorMaskData.DataCheck == TemplateDataCheck.Valid)
            {
                m_colorMaskHelper.Draw(owner);
            }

            m_isDirty = m_isDirty || m_colorMaskHelper.IsDirty;

            if (currentModule.DepthData.DataCheck == TemplateDataCheck.Valid)
            {
                m_depthOphelper.Draw(owner, false);
            }

            m_isDirty = m_isDirty || m_depthOphelper.IsDirty;

            if (currentModule.BlendData.DataCheck == TemplateDataCheck.Valid)
            {
                m_blendOpHelper.Draw(owner, false);
            }

            m_isDirty = m_isDirty || m_blendOpHelper.IsDirty;


            if (currentModule.StencilData.DataCheck == TemplateDataCheck.Valid)
            {
                CullMode cullMode = CullMode.Back;
                if (currentModule.CullModeData.DataCheck == TemplateDataCheck.Valid)
                {
                    cullMode = m_cullModeHelper.CurrentCullMode;
                }
                else if (parent != null && parent.CullModeHelper.ValidData)
                {
                    cullMode = parent.CullModeHelper.CurrentCullMode;
                }
                m_stencilBufferHelper.Draw(owner, cullMode, false);
            }

            m_isDirty = m_isDirty || m_stencilBufferHelper.IsDirty;

            if (currentModule.TagData.DataCheck == TemplateDataCheck.Valid)
            {
                m_tagsHelper.Draw(owner, false);
            }

            m_isDirty = m_isDirty || m_tagsHelper.IsDirty;

            if (currentModule.PragmaTag.IsValid)
            {
                //m_additionalDefines.Draw( owner );
                //m_additionalIncludes.Draw( owner );
                //m_additionalPragmas.Draw( owner );
                m_additionalDirectives.Draw(owner, false);
            }

            m_isDirty = m_isDirty ||
                        //m_additionalDefines.IsDirty ||
                        //m_additionalIncludes.IsDirty ||
                        //m_additionalPragmas.IsDirty ||
                        m_additionalDirectives.IsDirty;
        }
        void FetchTessellationData(TemplateMultiPass template, TemplateModulesData subShaderModule, int offsetIdx, string body)
        {
            // Tessellation VControl Tag
            try
            {
                int vcontrolcodeBegin = body.IndexOf(TemplatesManager.TemplateTessVControlTag);
                if (vcontrolcodeBegin > -1)
                {
                    m_tessVControlTag          = new TemplateTessVControlTag();
                    m_tessVControlTag.Id       = TemplatesManager.TemplateTessVControlTag;
                    m_tessVControlTag.StartIdx = offsetIdx + vcontrolcodeBegin;

                    m_templateProperties.AddId(body, m_tessVControlTag.Id);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            // Tessellation Control Data
            try
            {
                int controlCodeBegin = body.IndexOf(TemplatesManager.TemplateTessControlCodeArea);
                if (controlCodeBegin > -1)
                {
                    int beginIdx = controlCodeBegin + TemplatesManager.TemplateTessControlCodeArea.Length;
                    int endIdx   = body.IndexOf(TemplatesManager.TemplateEndOfLine, beginIdx);
                    int length   = endIdx - beginIdx;

                    string parameters = body.Substring(beginIdx, length);

                    string[] parametersArr = parameters.Split(IOUtils.FIELD_SEPARATOR);

                    string id            = body.Substring(controlCodeBegin, endIdx + TemplatesManager.TemplateEndOfLine.Length - controlCodeBegin);
                    string inParameters  = parametersArr[0];
                    string outParameters = (parametersArr.Length > 1) ? parametersArr[1] : string.Empty;

                    m_tessControlData = new TemplateTessControlData(offsetIdx + controlCodeBegin, id, inParameters, outParameters);

                    m_templateProperties.AddId(body, id);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            // Tessellation Domain Data
            try
            {
                int domainCodeBegin = body.IndexOf(TemplatesManager.TemplateTessDomainCodeArea);
                if (domainCodeBegin > -1)
                {
                    int beginIdx = domainCodeBegin + TemplatesManager.TemplateTessDomainCodeArea.Length;
                    int endIdx   = body.IndexOf(TemplatesManager.TemplateEndOfLine, beginIdx);
                    int length   = endIdx - beginIdx;

                    string parameters = body.Substring(beginIdx, length);

                    string[] parametersArr = parameters.Split(IOUtils.FIELD_SEPARATOR);

                    string id             = body.Substring(domainCodeBegin, endIdx + TemplatesManager.TemplateEndOfLine.Length - domainCodeBegin);
                    string inParameters   = (parametersArr.Length > 0) ? parametersArr[0] : string.Empty;
                    string outParameters  = (parametersArr.Length > 1) ? parametersArr[1] : string.Empty;
                    string baryParameters = (parametersArr.Length > 2) ? parametersArr[2] : string.Empty;

                    m_tessDomainData = new TemplateTessDomainData(offsetIdx + domainCodeBegin, id, inParameters, outParameters, baryParameters);

                    m_templateProperties.AddId(body, id);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
        public void Destroy()
        {
            m_passNameContainer = null;
#if CUSTOM_OPTIONS_AVAILABLE
            m_customOptionsContainer = null;
#endif
            if (m_templateProperties != null)
            {
                m_templateProperties.Destroy();
            }

            m_templateProperties = null;

            if (m_modules != null)
            {
                m_modules.Destroy();
            }

            m_modules = null;

            if (m_inputDataList != null)
            {
                m_inputDataList.Clear();
            }

            m_inputDataList = null;

            if (m_inputDataDict != null)
            {
                m_inputDataDict.Clear();
            }

            m_inputDataDict = null;

            m_vertexFunctionData   = null;
            m_fragmentFunctionData = null;

            if (m_vertexDataContainer != null)
            {
                m_vertexDataContainer.Destroy();
            }

            m_vertexDataContainer = null;

            m_tessVControlTag = null;

            m_tessControlData = null;

            m_tessDomainData = null;

            if (m_interpolatorDataContainer != null)
            {
                m_interpolatorDataContainer.Destroy();
            }

            if (m_localVarsList != null)
            {
                m_localVarsList.Clear();
                m_localVarsList = null;
            }

            m_interpolatorDataContainer = null;

            if (m_availableShaderGlobals != null)
            {
                m_availableShaderGlobals.Clear();
            }

            m_availableShaderGlobals = null;
        }
Exemplo n.º 13
0
        public void Draw(ParentNode owner, TemplateModulesData module)
        {
            switch (module.ShaderModel.DataCheck)
            {
            case TemplateDataCheck.Valid: m_shaderModelHelper.Draw(owner); break;

            case TemplateDataCheck.Unreadable: m_shaderModelHelper.ShowUnreadableDataMessage(); break;
            }
            m_isDirty = m_shaderModelHelper.IsDirty;

            switch (module.CullModeData.DataCheck)
            {
            case TemplateDataCheck.Valid: m_cullModeHelper.Draw(owner); break;

            case TemplateDataCheck.Unreadable: m_cullModeHelper.ShowUnreadableDataMessage(); break;
            }
            m_isDirty = m_cullModeHelper.IsDirty;

            switch (module.ColorMaskData.DataCheck)
            {
            case TemplateDataCheck.Valid: m_colorMaskHelper.Draw(owner); break;

            case TemplateDataCheck.Unreadable: m_colorMaskHelper.ShowUnreadableDataMessage(); break;
            }
            m_isDirty = m_isDirty || m_colorMaskHelper.IsDirty;

            switch (module.DepthData.DataCheck)
            {
            case TemplateDataCheck.Valid: m_depthOphelper.Draw(owner, false); break;

            case TemplateDataCheck.Unreadable: m_depthOphelper.ShowUnreadableDataMessage(); break;
            }
            m_isDirty = m_isDirty || m_depthOphelper.IsDirty;

            switch (module.BlendData.DataCheck)
            {
            case TemplateDataCheck.Valid: m_blendOpHelper.Draw(owner, false); break;

            case TemplateDataCheck.Unreadable: m_blendOpHelper.ShowUnreadableDataMessage(); break;
            }
            m_isDirty = m_isDirty || m_blendOpHelper.IsDirty;

            switch (module.StencilData.DataCheck)
            {
            case TemplateDataCheck.Valid:
            {
                CullMode cullMode = (module.CullModeData.DataCheck == TemplateDataCheck.Valid) ? m_cullModeHelper.CurrentCullMode : CullMode.Back;
                m_stencilBufferHelper.Draw(owner, cullMode, false);
            }
            break;

            case TemplateDataCheck.Unreadable:
            {
                m_stencilBufferHelper.ShowUnreadableDataMessage();
            }
            break;
            }
            m_isDirty = m_isDirty || m_stencilBufferHelper.IsDirty;

            switch (module.TagData.DataCheck)
            {
            case TemplateDataCheck.Valid: m_tagsHelper.Draw(owner, false); break;

            case TemplateDataCheck.Unreadable: m_tagsHelper.ShowUnreadableDataMessage(owner); break;
            }
            m_isDirty = m_isDirty || m_tagsHelper.IsDirty;

            if (module.PragmaTag.IsValid)
            {
                m_additionalDefines.Draw(owner);
                m_additionalIncludes.Draw(owner);
                m_additionalPragmas.Draw(owner);
            }

            m_isDirty = m_isDirty ||
                        m_additionalDefines.IsDirty ||
                        m_additionalIncludes.IsDirty ||
                        m_additionalPragmas.IsDirty;
        }
Exemplo n.º 14
0
        public void FetchDataFromTemplate(TemplateModulesData module)
        {
            m_allModulesMode = module.AllModulesMode;

            if (module.PragmaTag.IsValid)
            {
                m_hasValidData = true;
                //m_additionalPragmas.IsValid = true;
                //m_additionalPragmas.FillNativeItems( module.IncludePragmaContainer.PragmasList );

                //m_additionalIncludes.IsValid = true;
                //m_additionalIncludes.FillNativeItems( module.IncludePragmaContainer.IncludesList );

                //m_additionalDefines.IsValid = true;
                //m_additionalDefines.FillNativeItems( module.IncludePragmaContainer.DefinesList );

                m_additionalDirectives.FillNativeItems(module.IncludePragmaContainer.NativeDirectivesList);
                m_additionalDirectives.IsValid = true;
            }
            else
            {
                //m_additionalPragmas.IsValid = false;
                //m_additionalIncludes.IsValid = false;
                //m_additionalDefines.IsValid = false;
                m_additionalDirectives.IsValid = false;
            }

            m_blendOpHelper.ConfigureFromTemplateData(module.BlendData);
            if (module.BlendData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_blendOpHelper1.ConfigureFromTemplateData(module.BlendData1);
            if (module.BlendData1.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_blendOpHelper2.ConfigureFromTemplateData(module.BlendData2);
            if (module.BlendData2.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_blendOpHelper3.ConfigureFromTemplateData(module.BlendData3);
            if (module.BlendData3.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_alphaToMaskHelper.ConfigureFromTemplateData(module.AlphaToMaskData);
            if (module.AlphaToMaskData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_cullModeHelper.ConfigureFromTemplateData(module.CullModeData);
            if (module.CullModeData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_colorMaskHelper.ConfigureFromTemplateData(module.ColorMaskData);
            if (module.ColorMaskData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_colorMaskHelper1.ConfigureFromTemplateData(module.ColorMaskData1);
            if (module.ColorMaskData1.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_colorMaskHelper2.ConfigureFromTemplateData(module.ColorMaskData2);
            if (module.ColorMaskData2.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_colorMaskHelper3.ConfigureFromTemplateData(module.ColorMaskData3);
            if (module.ColorMaskData3.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_stencilBufferHelper.ConfigureFromTemplateData(module.StencilData);
            if (module.StencilData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_depthOphelper.ConfigureFromTemplateData(module.DepthData);
            if (module.DepthData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_tagsHelper.ConfigureFromTemplateData(module.TagData);
            if (module.TagData.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }

            m_shaderModelHelper.ConfigureFromTemplateData(module.ShaderModel);
            if (module.ShaderModel.DataCheck == TemplateDataCheck.Valid)
            {
                m_hasValidData = true;
            }


            if (module.RenderPlatformHelper.IsValid)
            {
                m_renderingPlatforms.SetupFromTemplate(module.RenderPlatformHelper);
                m_hasValidData = true;
            }
        }