Exemple #1
0
 public void AddCommand(Shader shader, ShaderAction setup, Action <RenderState> cleanup, WorldMatrixHandle world, RenderUserData user, VertexBuffer buffer, PrimitiveTypes primitive, int start, int count, bool transparent, int layer, float z = 0)
 {
     if (transparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Source      = shader,
             ShaderSetup = setup,
             World       = world,
             UserData    = user,
             Cleanup     = cleanup,
             Buffer      = buffer,
             Start       = start,
             Count       = count,
             Primitive   = primitive,
             CmdType     = RenderCmdType.Shader,
             BaseVertex  = -1,
             SortLayer   = transparent ? layer : SortLayers.OPAQUE,
             Z           = z
         };
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
 public void AddCommand(Shader shader, ShaderAction setup, Action <RenderContext> cleanup, WorldMatrixHandle world, RenderUserData user, VertexBuffer buffer, PrimitiveTypes primitive, int start, int count, bool transparent, int layer, float z = 0, int renIndex = 0)
 {
     if (transparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Key         = RenderCommand.MakeKey(RenderType.Transparent, 0, layer, z, renIndex),
             Source      = shader,
             ShaderSetup = setup,
             World       = world,
             UserData    = user,
             Cleanup     = cleanup,
             Buffer      = buffer,
             Start       = start,
             Count       = count,
             Primitive   = primitive,
             CmdType     = RenderCmdType.Shader,
             BaseVertex  = -1,
         };
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemple #3
0
        public void RenderCustom(RenderState rs, Shader shdr, ShaderAction customAction, ref RenderCommand cmd)
        {
            FlushCommands(rs);
            //Setup shader default state
            rs.Cull      = false;
            rs.BlendMode = BlendMode.Normal;
            var splt = new SplitInt()
            {
                I = shdr.UserTag
            };

            if (shdr.UserTag == 0)
            {
                splt.A       = (short)shdr.GetLocation("View");
                splt.B       = (short)shdr.GetLocation("ViewProjection");
                shdr.UserTag = splt.I;
            }
            var view = camera.View;

            shdr.SetMatrix(splt.A, ref view);
            var vp = camera.ViewProjection;

            shdr.SetMatrix(splt.B, ref vp);
            //User-defined
            customAction(shdr, rs, ref cmd);
            //Draw
            vboBasic.Draw(PrimitiveTypes.TriangleList, 0, lastIndexBasic, 2);
            //Set stuff
            rs.Cull         = true;
            lastDatHash     = -1;
            lastIndexBasic += 6;
        }
 public void AddCommand(Billboards billboards, Shader shader, ShaderAction setup, RenderUserData userData, int indexStart, int layer, float z)
 {
     Transparents[transparentCommand++] = new RenderCommand()
     {
         CmdType     = RenderCmdType.BillboardCustom,
         Source      = billboards,
         ShaderSetup = setup,
         UserData    = userData,
         Index       = indexStart,
         Cleanup     = shader,
         SortLayer   = layer,
         Z           = z
     };
 }
 public void AddCommand(Shader shader, ShaderAction setup, Action <RenderState> cleanup, Matrix4 world, Lighting lt, RenderUserData user, VertexBuffer buffer, PrimitiveTypes primitive, int baseVertex, int start, int count, bool transparent, int layer, float z = 0)
 {
     if (transparent)
     {
         Transparents[transparentCommand++] = new RenderCommand()
         {
             Source      = shader,
             ShaderSetup = setup,
             World       = world,
             UserData    = user,
             Cleanup     = cleanup,
             Buffer      = buffer,
             Lights      = lt,
             Start       = start,
             Count       = count,
             Primitive   = primitive,
             CmdType     = RenderCmdType.Shader,
             SortLayer   = transparent ? layer : SortLayers.OPAQUE,
             Z           = z
         };
     }
     else
     {
         Commands[currentCommand++] = new RenderCommand()
         {
             Source      = shader,
             ShaderSetup = setup,
             World       = world,
             UserData    = user,
             Cleanup     = cleanup,
             Buffer      = buffer,
             Lights      = lt,
             Start       = start,
             Count       = count,
             Primitive   = primitive,
             CmdType     = RenderCmdType.Shader,
             SortLayer   = transparent ? layer : SortLayers.OPAQUE,
             Z           = z
         };
     }
 }
Exemple #6
0
        public void DrawCustomShader(
            Shader shader,
            ShaderAction setup,
            RenderUserData userData,
            Vector3 Position,
            Vector2 size,
            Color4 color,
            Vector2 topleft,
            Vector2 topright,
            Vector2 bottomleft,
            Vector2 bottomright,
            float angle,
            int layer,
            float z = float.NegativeInfinity
            )
        {
            currentTexture = null;
            int vc = vertexCount;

            CreateBillboard(
                Position,
                size,
                color,
                angle,
                topleft,
                topright,
                bottomleft,
                bottomright
                );
            buffer.AddCommand(
                this,
                shader,
                setup,
                userData,
                vc,
                layer,
                float.IsNegativeInfinity(z) ? RenderHelpers.GetZ(Matrix4.Identity, camera.Position, Position) : z
                );
        }