Exemple #1
0
        public static string CreateShader <T> (string version, Expression <Func <Shader <T> > > shader)
        {
            var parser = new GlslParser();

            parser.DeclareVaryings(typeof(T), GlslAst.VaryingKind.Out);
            parser.ParseShader(shader);
            return(parser.BuildShaderCode());
        }
Exemple #2
0
        public static string CreateGeometryShader <T> (string version, int vertexCount,
                                                       int invocations, PrimitiveType inputPrimitive, PrimitiveType outputPrimitive,
                                                       Expression <Func <Shader <T[]> > > shader)
        {
            var parser = new GlslParser();

            if (invocations > 0)
            {
                parser.DeclOut("layout (invocations = {0}) in;", invocations);
            }
            parser.DeclOut("layout ({0}) in;", inputPrimitive.MapInputGSPrimitive());
            parser.DeclOut("layout ({0}, max_vertices = {1}) out;",
                           outputPrimitive.MapOutputGSPrimitive(), vertexCount);
            parser.DeclareVaryings(typeof(T), GlslAst.VaryingKind.Out);
            parser.ParseGeometryShader(shader);
            return(parser.BuildShaderCode());
        }