コード例 #1
0
        public TemplateModulesData(TemplateIdManager idManager, TemplatePropertyContainer propertyContainer, string uniquePrefix, int offsetIdx, string subBody, bool isSubShader)
        {
            if (string.IsNullOrEmpty(subBody))
            {
                return;
            }

            m_uniquePrefix = uniquePrefix;
            //PRAGMAS AND INCLUDES
            TemplateHelperFunctions.CreatePragmaIncludeList(subBody, m_includePragmaContainer);

            //COMMON TAGS
            ConfigureCommonTag(m_globalsTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_functionsTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_pragmaTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_passTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_inputsVertTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_inputsFragTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);

            //BlEND MODE
            {
                Match blendModeMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendWholeWordPattern);
                if (blendModeMatch.Success)
                {
                    int blendModeIdx = blendModeMatch.Index;

                    int    end         = subBody.IndexOf(TemplatesManager.TemplateNewLine, blendModeIdx);
                    string blendParams = subBody.Substring(blendModeIdx, end - blendModeIdx);
                    m_blendData.BlendModeId         = blendParams;
                    m_blendData.BlendModeStartIndex = offsetIdx + blendModeIdx;
                    idManager.RegisterId(m_blendData.BlendModeStartIndex, uniquePrefix + m_blendData.BlendModeId, m_blendData.BlendModeId);

                    TemplateHelperFunctions.CreateBlendMode(blendParams, ref m_blendData);
                    if (m_blendData.ValidBlendMode)
                    {
                        propertyContainer.AddId(subBody, blendParams, false);
                    }
                }
            }
            //BLEND OP
            {
                Match blendOpMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendOpWholeWordPattern);
                if (blendOpMatch.Success)
                {
                    int    blendOpIdx    = blendOpMatch.Index;
                    int    end           = subBody.IndexOf(TemplatesManager.TemplateNewLine, blendOpIdx);
                    string blendOpParams = subBody.Substring(blendOpIdx, end - blendOpIdx);
                    m_blendData.BlendOpId       = blendOpParams;
                    BlendData.BlendOpStartIndex = offsetIdx + blendOpIdx;
                    idManager.RegisterId(m_blendData.BlendOpStartIndex, uniquePrefix + m_blendData.BlendOpId, m_blendData.BlendOpId);
                    TemplateHelperFunctions.CreateBlendOp(blendOpParams, ref m_blendData);
                    if (m_blendData.ValidBlendOp)
                    {
                        propertyContainer.AddId(subBody, blendOpParams, false);
                    }
                }
            }

            //ALPHA TO MASK
            {
                Match alphaToMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.ALphaToMaskPattern);
                if (alphaToMaskMatch.Success)
                {
                    m_blendData.ValidAlphaToMask = true;
                    m_blendData.AlphaToMaskId    = alphaToMaskMatch.Groups[0].Value;
                    if (alphaToMaskMatch.Groups.Count > 1)
                    {
                        m_blendData.AlphaToMaskValue = alphaToMaskMatch.Groups[1].Value.Equals("On") ? true : false;
                    }
                    m_blendData.IndependentAlphaToMask = true;
                    idManager.RegisterId(offsetIdx + alphaToMaskMatch.Index, uniquePrefix + m_blendData.AlphaToMaskId, m_blendData.AlphaToMaskId);
                    propertyContainer.AddId(subBody, m_blendData.AlphaToMaskId, false);
                }

                m_blendData.DataCheck = (m_blendData.ValidBlendMode || m_blendData.ValidBlendOp || m_blendData.ValidAlphaToMask) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
            }

            //CULL MODE
            {
                Match cullMatch = Regex.Match(subBody, TemplateHelperFunctions.CullWholeWordPattern);
                if (cullMatch.Success)
                {
                    int    cullIdx    = cullMatch.Index;
                    int    end        = subBody.IndexOf(TemplatesManager.TemplateNewLine, cullIdx);
                    string cullParams = subBody.Substring(cullIdx, end - cullIdx);
                    m_cullModeData.CullModeId = cullParams;
                    m_cullModeData.StartIdx   = offsetIdx + cullIdx;
                    idManager.RegisterId(m_cullModeData.StartIdx, uniquePrefix + m_cullModeData.CullModeId, m_cullModeData.CullModeId);
                    TemplateHelperFunctions.CreateCullMode(cullParams, ref m_cullModeData);
                    if (m_cullModeData.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, cullParams, false, string.Empty);
                    }
                }
            }
            //COLOR MASK
            {
                Match colorMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.ColorMaskWholeWordPattern);
                if (colorMaskMatch.Success)
                {
                    int    colorMaskIdx    = colorMaskMatch.Index;
                    int    end             = subBody.IndexOf(TemplatesManager.TemplateNewLine, colorMaskIdx);
                    string colorMaskParams = subBody.Substring(colorMaskIdx, end - colorMaskIdx);
                    m_colorMaskData.ColorMaskId = colorMaskParams;
                    m_colorMaskData.StartIdx    = offsetIdx + colorMaskIdx;
                    idManager.RegisterId(m_colorMaskData.StartIdx, uniquePrefix + m_colorMaskData.ColorMaskId, m_colorMaskData.ColorMaskId);
                    TemplateHelperFunctions.CreateColorMask(colorMaskParams, ref m_colorMaskData);
                    if (m_colorMaskData.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, colorMaskParams, false);
                    }
                }
            }
            //STENCIL
            {
                Match stencilMatch = Regex.Match(subBody, TemplateHelperFunctions.StencilWholeWordPattern);
                if (stencilMatch.Success)
                {
                    int stencilIdx    = stencilMatch.Index;
                    int stencilEndIdx = subBody.IndexOf("}", stencilIdx);
                    if (stencilEndIdx > 0)
                    {
                        string stencilParams = subBody.Substring(stencilIdx, stencilEndIdx + 1 - stencilIdx);
                        m_stencilData.StencilBufferId = stencilParams;
                        m_stencilData.StartIdx        = offsetIdx + stencilIdx;
                        idManager.RegisterId(m_stencilData.StartIdx, uniquePrefix + m_stencilData.StencilBufferId, m_stencilData.StencilBufferId);
                        TemplateHelperFunctions.CreateStencilOps(stencilParams, ref m_stencilData);
                        if (m_stencilData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, stencilParams, true);
                        }
                    }
                }
                else
                {
                    int stencilTagIdx = subBody.IndexOf(TemplatesManager.TemplateStencilTag);
                    if (stencilTagIdx > -1)
                    {
                        m_stencilData.SetIndependentDefault();
                        m_stencilData.StencilBufferId = TemplatesManager.TemplateStencilTag;
                        m_stencilData.StartIdx        = offsetIdx + stencilTagIdx;
                        idManager.RegisterId(m_stencilData.StartIdx, uniquePrefix + m_stencilData.StencilBufferId, m_stencilData.StencilBufferId);
                        propertyContainer.AddId(subBody, m_stencilData.StencilBufferId, true);
                    }
                }
            }
            //ZWRITE
            {
                Match zWriteMatch = Regex.Match(subBody, TemplateHelperFunctions.ZWriteWholeWordPattern);
                if (zWriteMatch.Success)
                {
                    int zWriteOpIdx  = zWriteMatch.Index;
                    int zWriteEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zWriteOpIdx);
                    if (zWriteEndIdx > 0)
                    {
                        m_depthData.ZWriteModeId     = subBody.Substring(zWriteOpIdx, zWriteEndIdx + 1 - zWriteOpIdx);
                        m_depthData.ZWriteStartIndex = offsetIdx + zWriteOpIdx;
                        idManager.RegisterId(m_depthData.ZWriteStartIndex, uniquePrefix + m_depthData.ZWriteModeId, m_depthData.ZWriteModeId);
                        TemplateHelperFunctions.CreateZWriteMode(m_depthData.ZWriteModeId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.ZWriteModeId, true);
                        }
                    }
                }
            }

            //ZTEST
            {
                Match zTestMatch = Regex.Match(subBody, TemplateHelperFunctions.ZTestWholeWordPattern);
                if (zTestMatch.Success)
                {
                    int zTestOpIdx  = zTestMatch.Index;
                    int zTestEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zTestOpIdx);
                    if (zTestEndIdx > 0)
                    {
                        m_depthData.ZTestModeId     = subBody.Substring(zTestOpIdx, zTestEndIdx + 1 - zTestOpIdx);
                        m_depthData.ZTestStartIndex = offsetIdx + zTestOpIdx;
                        idManager.RegisterId(m_depthData.ZTestStartIndex, uniquePrefix + m_depthData.ZTestModeId, m_depthData.ZTestModeId);
                        TemplateHelperFunctions.CreateZTestMode(m_depthData.ZTestModeId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.ZTestModeId, true);
                        }
                    }
                }
            }

            //ZOFFSET
            {
                Match zOffsetMatch = Regex.Match(subBody, TemplateHelperFunctions.ZOffsetWholeWordPattern);
                if (zOffsetMatch.Success)
                {
                    int zOffsetIdx    = zOffsetMatch.Index;
                    int zOffsetEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zOffsetIdx);
                    if (zOffsetEndIdx > 0)
                    {
                        m_depthData.OffsetId         = subBody.Substring(zOffsetIdx, zOffsetEndIdx + 1 - zOffsetIdx);
                        m_depthData.OffsetStartIndex = offsetIdx + zOffsetIdx;
                        idManager.RegisterId(m_depthData.OffsetStartIndex, uniquePrefix + m_depthData.OffsetId, m_depthData.OffsetId);
                        TemplateHelperFunctions.CreateZOffsetMode(m_depthData.OffsetId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.OffsetId, true);
                        }
                    }
                }
            }
            //TAGS
            {
                Match tagsMatch = Regex.Match(subBody, TemplateHelperFunctions.TagsWholeWordPattern);
                if (tagsMatch.Success)
                {
                    int tagsIdx    = tagsMatch.Index;
                    int tagsEndIdx = subBody.IndexOf("}", tagsIdx);
                    if (tagsEndIdx > -1)
                    {
                        m_tagData.Reset();
                        m_tagData.TagsId   = subBody.Substring(tagsIdx, tagsEndIdx + 1 - tagsIdx);
                        m_tagData.StartIdx = offsetIdx + tagsIdx;
                        idManager.RegisterId(m_tagData.StartIdx, uniquePrefix + m_tagData.TagsId, m_tagData.TagsId);
                        m_srpType = TemplateHelperFunctions.CreateTags(ref m_tagData, isSubShader);

                        propertyContainer.AddId(subBody, m_tagData.TagsId, false);
                        m_tagData.DataCheck = TemplateDataCheck.Valid;
                    }
                    else
                    {
                        m_tagData.DataCheck = TemplateDataCheck.Invalid;
                    }
                }
                else
                {
                    m_tagData.DataCheck = TemplateDataCheck.Invalid;
                }
            }

            //SHADER MODEL
            {
                Match match = Regex.Match(subBody, TemplateHelperFunctions.ShaderModelPattern);
                if (match != null && match.Groups.Count > 1)
                {
                    if (TemplateHelperFunctions.AvailableInterpolators.ContainsKey(match.Groups[1].Value))
                    {
                        m_shaderModel.Id                 = match.Groups[0].Value;
                        m_shaderModel.StartIdx           = offsetIdx + match.Index;
                        m_shaderModel.Value              = match.Groups[1].Value;
                        m_shaderModel.InterpolatorAmount = TemplateHelperFunctions.AvailableInterpolators[match.Groups[1].Value];
                        m_shaderModel.DataCheck          = TemplateDataCheck.Valid;
                        idManager.RegisterId(m_shaderModel.StartIdx, uniquePrefix + m_shaderModel.Id, m_shaderModel.Id);
                    }
                    else
                    {
                        m_shaderModel.DataCheck = TemplateDataCheck.Invalid;
                    }
                }
            }

            // ALL MODULES
            int allModulesIndex = subBody.IndexOf(TemplatesManager.TemplateAllModulesTag);

            if (allModulesIndex > 0)
            {
                //ONLY REGISTER MISSING TAGS
                ConfigureCommonTag(m_allModulesTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
                m_allModulesMode = true;

                m_blendData.SetAllModulesDefault();

                if (!m_cullModeData.IsValid)
                {
                    m_cullModeData.SetAllModulesDefault();
                }

                if (!m_colorMaskData.IsValid)
                {
                    m_colorMaskData.SetAllModulesDefault();
                }

                if (!m_stencilData.IsValid)
                {
                    m_stencilData.SetAllModulesDefault();
                }

                if (!m_depthData.IsValid)
                {
                    m_depthData.SetAllModulesDefault();
                }

                if (!m_shaderModel.IsValid)
                {
                    m_shaderModel.SetAllModulesDefault();
                }
            }
        }
コード例 #2
0
        public TemplateModulesData(TemplateOptionsContainer optionsContainer, TemplateIdManager idManager, TemplatePropertyContainer propertyContainer, string uniquePrefix, int offsetIdx, string subBody, bool isSubShader)
        {
            if (string.IsNullOrEmpty(subBody))
            {
                return;
            }

            m_uniquePrefix = uniquePrefix;

            //RENDERING PLATFORMS
            m_renderPlatformHelper = new TemplateRenderPlatformHelper();
            TemplateHelperFunctions.FillRenderingPlatform(m_renderPlatformHelper, subBody);
            if (m_renderPlatformHelper.IsValid)
            {
                m_renderPlatformHelper.Index = offsetIdx + m_renderPlatformHelper.Index;
                idManager.RegisterId(m_renderPlatformHelper.Index, uniquePrefix + m_renderPlatformHelper.ID, m_renderPlatformHelper.ID);
            }

            //PRAGMAS AND INCLUDES
            TemplateHelperFunctions.CreatePragmaIncludeList(subBody, m_includePragmaContainer);

            //COMMON TAGS
            ConfigureCommonTag(m_globalsTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_srpBatcherTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_functionsTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_pragmaTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_pragmaBeforeTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            if (!TemplateHelperFunctions.GetPassUniqueId(m_passTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody, ref m_passUniqueName))
            {
                ConfigureCommonTag(m_passTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            }
            ConfigureCommonTag(m_inputsVertTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
            ConfigureCommonTag(m_inputsFragTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);

            // If Options are enabled then remove them so they won't influence Regex matches
            if (optionsContainer.Enabled && optionsContainer.EndIndex > 0)
            {
                offsetIdx += optionsContainer.EndIndex;
                subBody    = subBody.Substring(optionsContainer.EndIndex);
            }
            //BlEND MODE
            {
                Match blendModeMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendModePattern1);
                if (blendModeMatch.Success)
                {
                    int    blendModeIdx = blendModeMatch.Index;
                    int    end          = blendModeMatch.Length + blendModeIdx;
                    string blendParams  = subBody.Substring(blendModeIdx, end - blendModeIdx);
                    m_blendData1.BlendModeId         = blendParams;
                    m_blendData1.BlendModeStartIndex = offsetIdx + blendModeIdx;
                    idManager.RegisterId(m_blendData1.BlendModeStartIndex, uniquePrefix + m_blendData1.BlendModeId, m_blendData1.BlendModeId);

                    TemplateHelperFunctions.CreateBlendMode(blendParams, ref m_blendData1, TemplateHelperFunctions.BlendModePattern1);
                    if (m_blendData1.ValidBlendMode)
                    {
                        propertyContainer.AddId(subBody, blendParams, false);
                    }
                }
            }
            {
                Match blendModeMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendModePattern2);
                if (blendModeMatch.Success)
                {
                    int    blendModeIdx = blendModeMatch.Index;
                    int    end          = blendModeMatch.Length + blendModeIdx;
                    string blendParams  = subBody.Substring(blendModeIdx, end - blendModeIdx);
                    m_blendData2.BlendModeId         = blendParams;
                    m_blendData2.BlendModeStartIndex = offsetIdx + blendModeIdx;
                    idManager.RegisterId(m_blendData2.BlendModeStartIndex, uniquePrefix + m_blendData2.BlendModeId, m_blendData2.BlendModeId);

                    TemplateHelperFunctions.CreateBlendMode(blendParams, ref m_blendData2, TemplateHelperFunctions.BlendModePattern2);
                    if (m_blendData2.ValidBlendMode)
                    {
                        propertyContainer.AddId(subBody, blendParams, false);
                    }
                }
            }
            {
                Match blendModeMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendModePattern3);
                if (blendModeMatch.Success)
                {
                    int    blendModeIdx = blendModeMatch.Index;
                    int    end          = blendModeMatch.Length + blendModeIdx;
                    string blendParams  = subBody.Substring(blendModeIdx, end - blendModeIdx);
                    m_blendData3.BlendModeId         = blendParams;
                    m_blendData3.BlendModeStartIndex = offsetIdx + blendModeIdx;
                    idManager.RegisterId(m_blendData3.BlendModeStartIndex, uniquePrefix + m_blendData3.BlendModeId, m_blendData3.BlendModeId);

                    TemplateHelperFunctions.CreateBlendMode(blendParams, ref m_blendData3, TemplateHelperFunctions.BlendModePattern3);
                    if (m_blendData3.ValidBlendMode)
                    {
                        propertyContainer.AddId(subBody, blendParams, false);
                    }
                }
            }
            {
                string pattern        = TemplateHelperFunctions.BlendModePattern;
                Match  blendModeMatch = Regex.Match(subBody, pattern);
                if (!blendModeMatch.Success && !m_blendData1.ValidBlendMode && !m_blendData2.ValidBlendMode && !m_blendData3.ValidBlendMode)
                {
                    pattern        = TemplateHelperFunctions.BlendModePatternFirst;
                    blendModeMatch = Regex.Match(subBody, pattern);
                }
                if (blendModeMatch.Success)
                {
                    int    blendModeIdx = blendModeMatch.Index;
                    int    end          = blendModeMatch.Length + blendModeIdx;
                    string blendParams  = subBody.Substring(blendModeIdx, end - blendModeIdx);
                    m_blendData.BlendModeId         = blendParams;
                    m_blendData.BlendModeStartIndex = offsetIdx + blendModeIdx;
                    idManager.RegisterId(m_blendData.BlendModeStartIndex, uniquePrefix + m_blendData.BlendModeId, m_blendData.BlendModeId);

                    TemplateHelperFunctions.CreateBlendMode(blendParams, ref m_blendData, pattern);
                    if (m_blendData.ValidBlendMode)
                    {
                        propertyContainer.AddId(subBody, blendParams, false);
                    }
                }
            }
            //BLEND OP
            {
                Match blendOpMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendOpPattern1);
                if (blendOpMatch.Success)
                {
                    int    blendOpIdx    = blendOpMatch.Index;
                    int    end           = blendOpMatch.Length + blendOpIdx;
                    string blendOpParams = subBody.Substring(blendOpIdx, end - blendOpIdx);
                    m_blendData1.BlendOpId         = blendOpParams;
                    m_blendData1.BlendOpStartIndex = offsetIdx + blendOpIdx;
                    idManager.RegisterId(m_blendData1.BlendOpStartIndex, uniquePrefix + m_blendData1.BlendOpId, m_blendData1.BlendOpId);
                    TemplateHelperFunctions.CreateBlendOp(blendOpParams, ref m_blendData1, TemplateHelperFunctions.BlendOpPattern1);
                    if (m_blendData1.ValidBlendOp)
                    {
                        propertyContainer.AddId(subBody, blendOpParams, false);
                    }
                }

                m_blendData1.DataCheck = (m_blendData1.ValidBlendMode || m_blendData1.ValidBlendOp) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
            }
            {
                Match blendOpMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendOpPattern2);
                if (blendOpMatch.Success)
                {
                    int    blendOpIdx    = blendOpMatch.Index;
                    int    end           = blendOpMatch.Length + blendOpIdx;
                    string blendOpParams = subBody.Substring(blendOpIdx, end - blendOpIdx);
                    m_blendData2.BlendOpId         = blendOpParams;
                    m_blendData2.BlendOpStartIndex = offsetIdx + blendOpIdx;
                    idManager.RegisterId(m_blendData2.BlendOpStartIndex, uniquePrefix + m_blendData2.BlendOpId, m_blendData2.BlendOpId);
                    TemplateHelperFunctions.CreateBlendOp(blendOpParams, ref m_blendData2, TemplateHelperFunctions.BlendOpPattern2);
                    if (m_blendData2.ValidBlendOp)
                    {
                        propertyContainer.AddId(subBody, blendOpParams, false);
                    }
                }

                m_blendData2.DataCheck = (m_blendData2.ValidBlendMode || m_blendData2.ValidBlendOp) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
            }
            {
                Match blendOpMatch = Regex.Match(subBody, TemplateHelperFunctions.BlendOpPattern3);
                if (blendOpMatch.Success)
                {
                    int    blendOpIdx    = blendOpMatch.Index;
                    int    end           = blendOpMatch.Length + blendOpIdx;
                    string blendOpParams = subBody.Substring(blendOpIdx, end - blendOpIdx);
                    m_blendData3.BlendOpId         = blendOpParams;
                    m_blendData3.BlendOpStartIndex = offsetIdx + blendOpIdx;
                    idManager.RegisterId(m_blendData3.BlendOpStartIndex, uniquePrefix + m_blendData3.BlendOpId, m_blendData3.BlendOpId);
                    TemplateHelperFunctions.CreateBlendOp(blendOpParams, ref m_blendData3, TemplateHelperFunctions.BlendOpPattern3);
                    if (m_blendData3.ValidBlendOp)
                    {
                        propertyContainer.AddId(subBody, blendOpParams, false);
                    }
                }

                m_blendData3.DataCheck = (m_blendData3.ValidBlendMode || m_blendData3.ValidBlendOp) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
            }
            {
                string pattern      = TemplateHelperFunctions.BlendOpPattern;
                Match  blendOpMatch = Regex.Match(subBody, pattern);
                if (!blendOpMatch.Success && !m_blendData1.ValidBlendOp && !m_blendData2.ValidBlendOp && !m_blendData3.ValidBlendOp)
                {
                    pattern      = TemplateHelperFunctions.BlendOpPatternFirst;
                    blendOpMatch = Regex.Match(subBody, pattern);
                }

                if (blendOpMatch.Success)
                {
                    int    blendOpIdx    = blendOpMatch.Index;
                    int    end           = blendOpMatch.Length + blendOpIdx;
                    string blendOpParams = subBody.Substring(blendOpIdx, end - blendOpIdx);
                    m_blendData.BlendOpId         = blendOpParams;
                    m_blendData.BlendOpStartIndex = offsetIdx + blendOpIdx;
                    idManager.RegisterId(m_blendData.BlendOpStartIndex, uniquePrefix + m_blendData.BlendOpId, m_blendData.BlendOpId);
                    TemplateHelperFunctions.CreateBlendOp(blendOpParams, ref m_blendData, pattern);
                    if (m_blendData.ValidBlendOp)
                    {
                        propertyContainer.AddId(subBody, blendOpParams, false);
                    }
                }

                m_blendData.DataCheck = (m_blendData.ValidBlendMode || m_blendData.ValidBlendOp) ? TemplateDataCheck.Valid : TemplateDataCheck.Invalid;
            }

            //ALPHA TO MASK
            {
                Match alphaToMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.AlphaToMaskPattern);
                if (alphaToMaskMatch.Success)
                {
                    int    alphaIdx    = alphaToMaskMatch.Index;
                    int    end         = subBody.IndexOf(TemplatesManager.TemplateNewLine, alphaIdx);
                    string alphaParams = subBody.Substring(alphaIdx, end - alphaIdx);
                    m_alphaToMaskData.AlphaToMaskId = alphaParams;
                    m_alphaToMaskData.StartIdx      = offsetIdx + alphaIdx;
                    idManager.RegisterId(m_alphaToMaskData.StartIdx, uniquePrefix + m_alphaToMaskData.AlphaToMaskId, m_alphaToMaskData.AlphaToMaskId);
                    TemplateHelperFunctions.CreateAlphaToMask(alphaParams, ref m_alphaToMaskData);
                    if (m_alphaToMaskData.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, alphaParams, false, string.Empty);
                    }
                }
            }

            //CULL MODE
            {
                Match cullMatch = Regex.Match(subBody, TemplateHelperFunctions.CullWholeWordPattern);
                if (cullMatch.Success)
                {
                    int    cullIdx    = cullMatch.Index;
                    int    end        = subBody.IndexOf(TemplatesManager.TemplateNewLine, cullIdx);
                    string cullParams = subBody.Substring(cullIdx, end - cullIdx);
                    m_cullModeData.CullModeId = cullParams;
                    m_cullModeData.StartIdx   = offsetIdx + cullIdx;
                    idManager.RegisterId(m_cullModeData.StartIdx, uniquePrefix + m_cullModeData.CullModeId, m_cullModeData.CullModeId);
                    TemplateHelperFunctions.CreateCullMode(cullParams, ref m_cullModeData);
                    if (m_cullModeData.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, cullParams, false, string.Empty);
                    }
                }
            }
            //COLOR MASK
            {
                Match colorMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.ColorMask1Pattern);
                if (colorMaskMatch.Success)
                {
                    int    colorMaskIdx    = colorMaskMatch.Index;
                    int    end             = colorMaskMatch.Length + colorMaskIdx;     // subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
                    string colorMaskParams = subBody.Substring(colorMaskIdx, end - colorMaskIdx);
                    m_colorMaskData1.ColorMaskId = colorMaskParams;
                    m_colorMaskData1.StartIdx    = offsetIdx + colorMaskIdx;
                    idManager.RegisterId(m_colorMaskData1.StartIdx, uniquePrefix + m_colorMaskData1.ColorMaskId, m_colorMaskData1.ColorMaskId);
                    TemplateHelperFunctions.CreateColorMask(colorMaskParams, ref m_colorMaskData1, TemplateHelperFunctions.ColorMask1Pattern);
                    if (m_colorMaskData1.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, colorMaskParams, false);
                    }
                }
            }
            {
                Match colorMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.ColorMask2Pattern);
                if (colorMaskMatch.Success)
                {
                    int    colorMaskIdx    = colorMaskMatch.Index;
                    int    end             = colorMaskMatch.Length + colorMaskIdx;     // subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
                    string colorMaskParams = subBody.Substring(colorMaskIdx, end - colorMaskIdx);
                    m_colorMaskData2.ColorMaskId = colorMaskParams;
                    m_colorMaskData2.StartIdx    = offsetIdx + colorMaskIdx;
                    idManager.RegisterId(m_colorMaskData2.StartIdx, uniquePrefix + m_colorMaskData2.ColorMaskId, m_colorMaskData2.ColorMaskId);
                    TemplateHelperFunctions.CreateColorMask(colorMaskParams, ref m_colorMaskData2, TemplateHelperFunctions.ColorMask2Pattern);
                    if (m_colorMaskData2.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, colorMaskParams, false);
                    }
                }
            }
            {
                Match colorMaskMatch = Regex.Match(subBody, TemplateHelperFunctions.ColorMask3Pattern);
                if (colorMaskMatch.Success)
                {
                    int    colorMaskIdx    = colorMaskMatch.Index;
                    int    end             = colorMaskMatch.Length + colorMaskIdx;     // subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
                    string colorMaskParams = subBody.Substring(colorMaskIdx, end - colorMaskIdx);
                    m_colorMaskData3.ColorMaskId = colorMaskParams;
                    m_colorMaskData3.StartIdx    = offsetIdx + colorMaskIdx;
                    idManager.RegisterId(m_colorMaskData3.StartIdx, uniquePrefix + m_colorMaskData3.ColorMaskId, m_colorMaskData3.ColorMaskId);
                    TemplateHelperFunctions.CreateColorMask(colorMaskParams, ref m_colorMaskData3, TemplateHelperFunctions.ColorMask3Pattern);
                    if (m_colorMaskData3.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, colorMaskParams, false);
                    }
                }
            }
            {
                string pattern        = TemplateHelperFunctions.ColorMaskPattern;
                Match  colorMaskMatch = Regex.Match(subBody, pattern);
                if (!colorMaskMatch.Success && m_colorMaskData1.DataCheck == TemplateDataCheck.Invalid && m_colorMaskData2.DataCheck == TemplateDataCheck.Invalid && m_colorMaskData3.DataCheck == TemplateDataCheck.Invalid)
                {
                    pattern        = TemplateHelperFunctions.ColorMaskPatternFirst;
                    colorMaskMatch = Regex.Match(subBody, pattern);
                }

                if (colorMaskMatch.Success)
                {
                    int    colorMaskIdx    = colorMaskMatch.Index;
                    int    end             = colorMaskMatch.Length + colorMaskIdx;      //subBody.IndexOf( TemplatesManager.TemplateNewLine, colorMaskIdx );
                    string colorMaskParams = subBody.Substring(colorMaskIdx, end - colorMaskIdx);
                    m_colorMaskData.ColorMaskId = colorMaskParams;
                    m_colorMaskData.StartIdx    = offsetIdx + colorMaskIdx;
                    idManager.RegisterId(m_colorMaskData.StartIdx, uniquePrefix + m_colorMaskData.ColorMaskId, m_colorMaskData.ColorMaskId);
                    TemplateHelperFunctions.CreateColorMask(colorMaskParams, ref m_colorMaskData, pattern);
                    if (m_colorMaskData.DataCheck == TemplateDataCheck.Valid)
                    {
                        propertyContainer.AddId(subBody, colorMaskParams, false);
                    }
                }
            }
            //STENCIL
            {
                Match stencilMatch = Regex.Match(subBody, TemplateHelperFunctions.StencilWholeWordPattern);
                if (stencilMatch.Success)
                {
                    int stencilIdx    = stencilMatch.Index;
                    int stencilEndIdx = subBody.IndexOf("}", stencilIdx);
                    if (stencilEndIdx > 0)
                    {
                        string stencilParams = subBody.Substring(stencilIdx, stencilEndIdx + 1 - stencilIdx);
                        m_stencilData.StencilBufferId = stencilParams;
                        m_stencilData.StartIdx        = offsetIdx + stencilIdx;
                        idManager.RegisterId(m_stencilData.StartIdx, uniquePrefix + m_stencilData.StencilBufferId, m_stencilData.StencilBufferId);
                        TemplateHelperFunctions.CreateStencilOps(stencilParams, ref m_stencilData);
                        if (m_stencilData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, stencilParams, true);
                        }
                    }
                }
                else
                {
                    int stencilTagIdx = subBody.IndexOf(TemplatesManager.TemplateStencilTag);
                    if (stencilTagIdx > -1)
                    {
                        m_stencilData.SetIndependentDefault();
                        m_stencilData.StencilBufferId = TemplatesManager.TemplateStencilTag;
                        m_stencilData.StartIdx        = offsetIdx + stencilTagIdx;
                        idManager.RegisterId(m_stencilData.StartIdx, uniquePrefix + m_stencilData.StencilBufferId, m_stencilData.StencilBufferId);
                        propertyContainer.AddId(subBody, m_stencilData.StencilBufferId, true);
                    }
                }
            }
            //ZWRITE
            {
                Match zWriteMatch = Regex.Match(subBody, TemplateHelperFunctions.ZWriteWholeWordPattern);
                if (zWriteMatch.Success)
                {
                    int zWriteOpIdx  = zWriteMatch.Index;
                    int zWriteEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zWriteOpIdx);
                    if (zWriteEndIdx > 0)
                    {
                        m_depthData.ZWriteModeId     = subBody.Substring(zWriteOpIdx, zWriteEndIdx + 1 - zWriteOpIdx);
                        m_depthData.ZWriteStartIndex = offsetIdx + zWriteOpIdx;
                        idManager.RegisterId(m_depthData.ZWriteStartIndex, uniquePrefix + m_depthData.ZWriteModeId, m_depthData.ZWriteModeId);
                        TemplateHelperFunctions.CreateZWriteMode(m_depthData.ZWriteModeId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.ZWriteModeId, true);
                        }
                    }
                }
            }

            //ZTEST
            {
                Match zTestMatch = Regex.Match(subBody, TemplateHelperFunctions.ZTestWholeWordPattern);
                if (zTestMatch.Success)
                {
                    int zTestOpIdx  = zTestMatch.Index;
                    int zTestEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zTestOpIdx);
                    if (zTestEndIdx > 0)
                    {
                        m_depthData.ZTestModeId     = subBody.Substring(zTestOpIdx, zTestEndIdx + 1 - zTestOpIdx);
                        m_depthData.ZTestStartIndex = offsetIdx + zTestOpIdx;
                        idManager.RegisterId(m_depthData.ZTestStartIndex, uniquePrefix + m_depthData.ZTestModeId, m_depthData.ZTestModeId);
                        TemplateHelperFunctions.CreateZTestMode(m_depthData.ZTestModeId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.ZTestModeId, true);
                        }
                    }
                }
            }

            //ZOFFSET
            {
                Match zOffsetMatch = Regex.Match(subBody, TemplateHelperFunctions.ZOffsetWholeWordPattern);
                if (zOffsetMatch.Success)
                {
                    int zOffsetIdx    = zOffsetMatch.Index;
                    int zOffsetEndIdx = subBody.IndexOf(TemplatesManager.TemplateNewLine, zOffsetIdx);
                    if (zOffsetEndIdx > 0)
                    {
                        m_depthData.OffsetId         = subBody.Substring(zOffsetIdx, zOffsetEndIdx + 1 - zOffsetIdx);
                        m_depthData.OffsetStartIndex = offsetIdx + zOffsetIdx;
                        idManager.RegisterId(m_depthData.OffsetStartIndex, uniquePrefix + m_depthData.OffsetId, m_depthData.OffsetId);
                        TemplateHelperFunctions.CreateZOffsetMode(m_depthData.OffsetId, ref m_depthData);
                        if (m_depthData.DataCheck == TemplateDataCheck.Valid)
                        {
                            propertyContainer.AddId(subBody, m_depthData.OffsetId, true);
                        }
                    }
                }
                m_depthData.SetDataCheck();
            }
            //TAGS
            {
                Match tagsMatch = Regex.Match(subBody, TemplateHelperFunctions.TagsWholeWordPattern);
                if (tagsMatch.Success)
                {
                    int tagsIdx    = tagsMatch.Index;
                    int tagsEndIdx = subBody.IndexOf("}", tagsIdx);
                    if (tagsEndIdx > -1)
                    {
                        m_tagData.Reset();
                        m_tagData.TagsId   = subBody.Substring(tagsIdx, tagsEndIdx + 1 - tagsIdx);
                        m_tagData.StartIdx = offsetIdx + tagsIdx;
                        idManager.RegisterId(m_tagData.StartIdx, uniquePrefix + m_tagData.TagsId, m_tagData.TagsId);
                        m_srpType = TemplateHelperFunctions.CreateTags(ref m_tagData, isSubShader);

                        propertyContainer.AddId(subBody, m_tagData.TagsId, false);
                        m_tagData.DataCheck = TemplateDataCheck.Valid;
                    }
                    else
                    {
                        m_tagData.DataCheck = TemplateDataCheck.Invalid;
                    }
                }
                else
                {
                    m_tagData.DataCheck = TemplateDataCheck.Invalid;
                }
            }

            //SHADER MODEL
            {
                Match match = Regex.Match(subBody, TemplateHelperFunctions.ShaderModelPattern);
                if (match != null && match.Groups.Count > 1)
                {
                    if (TemplateHelperFunctions.AvailableInterpolators.ContainsKey(match.Groups[1].Value))
                    {
                        m_shaderModel.Id                 = match.Groups[0].Value;
                        m_shaderModel.StartIdx           = offsetIdx + match.Index;
                        m_shaderModel.Value              = match.Groups[1].Value;
                        m_shaderModel.InterpolatorAmount = TemplateHelperFunctions.AvailableInterpolators[match.Groups[1].Value];
                        m_shaderModel.DataCheck          = TemplateDataCheck.Valid;
                        idManager.RegisterId(m_shaderModel.StartIdx, uniquePrefix + m_shaderModel.Id, m_shaderModel.Id);
                    }
                    else
                    {
                        m_shaderModel.DataCheck = TemplateDataCheck.Invalid;
                    }
                }
            }

            // ALL MODULES
            int allModulesIndex = subBody.IndexOf(TemplatesManager.TemplateAllModulesTag);

            if (allModulesIndex > 0)
            {
                //ONLY REGISTER MISSING TAGS
                ConfigureCommonTag(m_allModulesTag, propertyContainer, idManager, uniquePrefix, offsetIdx, subBody);
                m_allModulesMode = true;

                m_blendData.SetAllModulesDefault();

                if (!m_alphaToMaskData.IsValid)
                {
                    m_alphaToMaskData.SetAllModulesDefault();
                }

                if (!m_cullModeData.IsValid)
                {
                    m_cullModeData.SetAllModulesDefault();
                }

                if (!m_colorMaskData.IsValid)
                {
                    m_colorMaskData.SetAllModulesDefault();
                }

                if (!m_stencilData.IsValid)
                {
                    m_stencilData.SetAllModulesDefault();
                }

                if (!m_depthData.IsValid)
                {
                    m_depthData.SetAllModulesDefault();
                }

                if (!m_shaderModel.IsValid)
                {
                    m_shaderModel.SetAllModulesDefault();
                }
            }
        }