Ejemplo n.º 1
0
        void AppendPass(ShaderPassType pass, RenderPipeline rp)
        {
            using (Scope("Pass")) {
                // Name & LightMode
                bool isLegacyMainRenderPass = rp == RenderPipeline.Legacy && pass == ShaderPassType.Render;
                if (isLegacyMainRenderPass == false)
                {
                    (string passName, string lightMode) = pass.NameAndLightMode(rp);
                    AppendLine($"Name \"{passName}\"");
                    AppendLine("Tags { " + (ShaderTag)("LightMode", lightMode) + " }");
                }

                using (Scope("Stencil")) {
                    AppendLine("Comp [_StencilComp]");
                    AppendLine("Pass [_StencilOpPass]");
                    AppendLine("Ref [_StencilID]");
                    AppendLine("ReadMask [_StencilReadMask]");
                    AppendLine("WriteMask [_StencilWriteMask]");
                }

                // culling/blend mode
                if (pass == ShaderPassType.Render)
                {
                    AppendLines(blendMode.GetPassRenderStates());
                }
                else
                {
                    AppendLine("Cull Off");                       // todo: might be incorrect for DepthOnly
                }
                // hlsl program
                AppendHlslProgram(pass, rp);
            }
        }
Ejemplo n.º 2
0
        public ShaderBuilder(string name, ShapesBlendMode blendMode)
        {
            this.blendMode  = blendMode;
            this.shaderName = name;

            using (Scope($"Shader \"Shapes/{name} {blendMode.ToString()}\"")) {
                using (Scope("SubShader")) {
                    using (Scope("Tags"))                        // sub shader tags
                        AppendLines(blendMode.GetSubshaderTags());

                    using (Scope("Pass")) {                        // render pass
                        AppendLines(blendMode.GetPassRenderStates());
                        AppendCGPROGRAM(ShaderPassType.Render);
                    }

                    using (Scope("Pass")) {                        // picking pass
                        AppendLine("Name \"Picking\"");
                        AppendLine("Tags { \"LightMode\" = \"Picking\" }");
                        AppendLine("Cull Off");
                        AppendCGPROGRAM(ShaderPassType.Picking);
                    }

                    using (Scope("Pass")) {                        // selection pass
                        AppendLine("Name \"Selection\"");
                        AppendLine("Tags { \"LightMode\" = \"SceneSelectionPass\" }");
                        AppendLine("Cull Off");
                        AppendCGPROGRAM(ShaderPassType.Selection);
                    }
                }
            }
        }