Esempio n. 1
0
        public void Export(ShaderWriter writer)
        {
            writer.WriteIndent(2);
            writer.Write("{0} ", Type.ToString());

            if (Type == SerializedPassType.UsePass)
            {
                writer.Write("\"{0}\"\n", UseName);
            }
            else
            {
                writer.Write("{\n");

                if (Type == SerializedPassType.GrabPass)
                {
                    if (TextureName != string.Empty)
                    {
                        writer.WriteIndent(3);
                        writer.Write("\"{0}\"\n", TextureName);
                    }
                }
                else if (Type == SerializedPassType.Pass)
                {
                    State.Export(writer);

                    if ((ProgramMask & ShaderType.Vertex.ToProgramMask()) != 0)
                    {
                        ProgVertex.Export(writer, ShaderType.Vertex);
                    }
                    if ((ProgramMask & ShaderType.Fragment.ToProgramMask()) != 0)
                    {
                        ProgFragment.Export(writer, ShaderType.Fragment);
                    }
                    if ((ProgramMask & ShaderType.Geometry.ToProgramMask()) != 0)
                    {
                        ProgGeometry.Export(writer, ShaderType.Geometry);
                    }
                    if ((ProgramMask & ShaderType.Hull.ToProgramMask()) != 0)
                    {
                        ProgHull.Export(writer, ShaderType.Hull);
                    }
                    if ((ProgramMask & ShaderType.Domain.ToProgramMask()) != 0)
                    {
                        ProgDomain.Export(writer, ShaderType.Domain);
                    }

#warning HasInstancingVariant?
                }
                else
                {
                    throw new NotSupportedException($"Unsupported pass type {Type}");
                }

                writer.WriteIndent(2);
                writer.Write("}\n");
            }
        }
Esempio n. 2
0
        public void Export(TextWriter writer, Shader shader, Func <ShaderGpuProgramType, ShaderTextExporter> exporterInstantiator)
        {
            writer.WriteIntent(2);
            writer.Write("{0} ", Type.ToString());

            if (Type == SerializedPassType.UsePass)
            {
                writer.Write("\"{0}\"\n", UseName);
            }
            else
            {
                writer.Write("{\n");

                if (Type == SerializedPassType.GrabPass)
                {
                    if (TextureName != string.Empty)
                    {
                        writer.WriteIntent(3);
                        writer.Write("\"{0}\"\n", TextureName);
                    }
                }
                else if (Type == SerializedPassType.Pass)
                {
                    State.Export(writer);

                    ProgVertex.Export(writer, shader, ShaderType.Vertex, exporterInstantiator);
                    ProgFragment.Export(writer, shader, ShaderType.Fragment, exporterInstantiator);
                    ProgGeometry.Export(writer, shader, ShaderType.Geometry, exporterInstantiator);
                    ProgHull.Export(writer, shader, ShaderType.Hull, exporterInstantiator);
                    ProgDomain.Export(writer, shader, ShaderType.Domain, exporterInstantiator);

#warning ProgramMask?
#warning HasInstancingVariant?
                }
                else
                {
                    throw new NotSupportedException($"Unsupported pass type {Type}");
                }

                writer.WriteIntent(2);
                writer.Write("}\n");
            }
        }