public string GetSubshader(UnlitMasterNode masterNode, GenerationMode mode)
        {
            var subShader = new ShaderGenerator();

            subShader.AddShaderChunk("SubShader", true);
            subShader.AddShaderChunk("{", true);
            subShader.Indent();
            subShader.AddShaderChunk("Tags{ \"RenderType\" = \"Opaque\" \"RenderPipeline\" = \"LightweightPipeline\"}", true);

            var materialOptions = MasterNode.GetMaterialOptionsFromAlphaMode(masterNode.alphaMode);
            var tagsVisitor     = new ShaderGenerator();

            materialOptions.GetTags(tagsVisitor);
            subShader.AddShaderChunk(tagsVisitor.GetShaderString(0), true);

            subShader.AddShaderChunk(
                GetShaderPassFromTemplate(
                    "lightweightUnlitPass.template",
                    masterNode,
                    m_UnlitPass,
                    mode,
                    materialOptions),
                true);

            subShader.Deindent();
            subShader.AddShaderChunk("}", true);

            return(subShader.GetShaderString(0));
        }
Exemple #2
0
        public IEnumerable <string> GetSubshader(PBRMasterNode masterNode, GenerationMode mode)
        {
            var subShader = new ShaderGenerator();

            subShader.AddShaderChunk("SubShader", true);
            subShader.AddShaderChunk("{", true);
            subShader.Indent();
            subShader.AddShaderChunk("Tags{ \"RenderPipeline\" = \"LightweightPipeline\"}", true);

            var materialOptions = MasterNode.GetMaterialOptionsFromAlphaMode(masterNode.alphaMode);
            var tagsVisitor     = new ShaderGenerator();

            materialOptions.GetTags(tagsVisitor);
            subShader.AddShaderChunk(tagsVisitor.GetShaderString(0), true);

            subShader.AddShaderChunk(
                GetShaderPassFromTemplate(
                    "lightweightPBRForwardPass.template",
                    masterNode,
                    masterNode.model == PBRMasterNode.Model.Metallic ? m_ForwardPassMetallic : m_ForwardPassSpecular,
                    mode,
                    materialOptions),
                true);

            var extraPassesTemplateLocation = ShaderGenerator.GetTemplatePath("lightweightPBRExtraPasses.template");

            if (File.Exists(extraPassesTemplateLocation))
            {
                subShader.AddShaderChunk(File.ReadAllText(extraPassesTemplateLocation), true);
            }

            subShader.Deindent();
            subShader.AddShaderChunk("}", true);

            return(new[] { subShader.GetShaderString(0) });
        }