Example #1
0
 public override string GenerateShaderData(bool isSubShader)
 {
     //return CullModeFormatStr + m_cullMode.ToString();
     return(CullModeFormatStr + m_inlineCullMode.GetValueOrProperty(m_cullMode.ToString()));
 }
Example #2
0
 public override string GenerateShaderData()
 {
     return(CullModeFormatStr + m_cullMode.ToString());
 }
 public override string GenerateShaderData()
 {
     return("Cull " + m_cullMode.ToString());
 }
Example #4
0
            public string Generate(SRPHelper.RenderPipeline rp, RenderingMode rm, EnabledFeatures enabledFeatures, int passID, int passCount)
            {
                var code = LoadText(Instance.textAssetPass);

                code = code.Replace("{VLB_GEN_CULLING}", m_CullMode.ToString());
                code = code.Replace("{VLB_GEN_PRAGMA_INSTANCING}", rm == RenderingMode.GPUInstancing ? "#pragma multi_compile_instancing" : "");
                code = code.Replace("{VLB_GEN_PRAGMA_FOG}", IsFogSupported(rp) ? "#pragma multi_compile_fog" : "");

                string multiCompileVariants = "";

                AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.AlphaAsBlack);
                if (enabledFeatures.noise3D)
                {
                    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.Noise3D);
                }
                if (enabledFeatures.depthBlend)
                {
                    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.DepthBlend);
                }
                switch (enabledFeatures.colorGradient)
                {
                case FeatureEnabledColorGradient.HighOnly:      AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.ColorGradientMatrixHigh); break;

                case FeatureEnabledColorGradient.HighAndLow:    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.ColorGradientMatrixHigh, ShaderKeywords.ColorGradientMatrixLow); break;
                }
                if (enabledFeatures.dynamicOcclusion)
                {
                    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.OcclusionClippingPlane, ShaderKeywords.OcclusionDepthTexture);
                }
                if (enabledFeatures.meshSkewing)
                {
                    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.MeshSkewing);
                }
                if (enabledFeatures.shaderAccuracyHigh)
                {
                    AppendMultiCompile(ref multiCompileVariants, true, ShaderKeywords.ShaderAccuracyHigh);
                }
                code = code.Replace("{VLB_GEN_PRAGMA_MULTI_COMPILE_VARIANTS}", multiCompileVariants);

                var lang = GetShaderLangage(rp);

                code = code.Replace("{VLB_GEN_PROGRAM_PRE}", GetShaderLangagePre(lang));
                code = code.Replace("{VLB_GEN_PROGRAM_POST}", GetShaderLangagePost(lang));

                var passPre = "";

                if (passCount > 1)
                {
                    code = code.Replace("{VLB_GEN_INPUT_VS}", string.Format("{0}", passID));
                    code = code.Replace("{VLB_GEN_INPUT_FS}", string.Format("{0}", passID));
                }
                else
                {
                    code     = code.Replace("{VLB_GEN_INPUT_VS}", string.Format("{0}", "v.texcoord.y"));
                    code     = code.Replace("{VLB_GEN_INPUT_FS}", string.Format("{0}", "i.cameraPosObjectSpace_outsideBeam.w"));
                    passPre += "                #define VLB_PASS_OUTSIDEBEAM_FROM_VS_TO_FS 1" + System.Environment.NewLine;
                }

                if (rp != SRPHelper.RenderPipeline.BuiltIn)
                {
                    passPre += "                #define VLB_SRP_API 1" + System.Environment.NewLine;

                    if (rm == RenderingMode.SRPBatcher)
                    {
                        passPre += "                #define VLB_SRP_BATCHER 1" + System.Environment.NewLine;

                        if (rp == SRPHelper.RenderPipeline.URP)
                        {
                            // force enable constant buffers to fix SRP Batcher support on Android
                            passPre += "                #pragma enable_cbuffer" + System.Environment.NewLine;
                        }
                    }
                }

                if (enabledFeatures.dithering)
                {
                    passPre += "                #define VLB_DITHERING 1" + System.Environment.NewLine;
                }

                passPre += LoadText(Instance.GetTextAssetIncludes(rp));

                code = code.Replace("{VLB_GEN_PRE}", passPre);

                return(code);
            }