Esempio n. 1
0
        public ShaderBuilder(string name, ShapesBlendMode blendMode, RenderPipeline rp)
        {
            this.blendMode  = blendMode;
            this.shaderName = name;

            using (Scope($"Shader \"Shapes/{name} {blendMode.ToString()}\"")) {
                using (Scope("Properties")) {
                    AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest (\"Z Test\", int) = 4");
                    AppendLine("_ZOffsetFactor (\"Z Offset Factor\", Float ) = 0");
                    AppendLine("_ZOffsetUnits (\"Z Offset Units\", int ) = 0");

                    AppendLine("[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp (\"Stencil Comparison\", int) = 8");
                    AppendLine("[Enum(UnityEngine.Rendering.StencilOp)] _StencilOpPass (\"Stencil Operation Pass\", int) = 0");
                    AppendLine("_StencilID (\"Stencil ID\", int) = 0");
                    AppendLine("_StencilReadMask (\"Stencil Read Mask\", int) = 255");
                    AppendLine("_StencilWriteMask (\"Stencil Write Mask\", int) = 255");
                }

                using (Scope("SubShader")) {
                    using (Scope("Tags")) {                        // subshader tags
                        AppendLines(rp.GetSubshaderTags());
                        AppendLines(blendMode.GetSubshaderTags());
                    }

                    AppendPass(ShaderPassType.Render, rp);
                    if (rp != RenderPipeline.Legacy)
                    {
                        AppendPass(ShaderPassType.DepthOnly, rp);
                    }
                    AppendPass(ShaderPassType.Picking, rp);
                    AppendPass(ShaderPassType.Selection, rp);
                }
            }
        }