public override void Draw(GameTime gameTime)
        {
            var rs  = Game.GraphicsDevice;
            var cam = Game.GetService <Camera>();
            var ls  = Game.GetService <LayerService>();

            constBuffer.Data.ViewProj     = cam.ViewMatrix * cam.ProjMatrix;
            constBuffer.Data.Zoom         = new Vector4(ls.MapLayer.Zoom);
            constBuffer.Data.Offset       = new Vector4(ls.MapLayer.Offset, 0.0f, 0.0f);
            constBuffer.Data.ViewPosition = new Vector4(cam.CameraMatrix.TranslationVector, 0.0f);
            constBuffer.UpdateCBuffer();


            string signature;

            drawShader.SetVertexShader((int)BuildingsFlags.BUILDINGS_DRAW, out signature);

            drawShader.SetGeometryShader((int)BuildingsFlags.BUILDINGS_DRAW);
            drawShader.SetPixelShader((int)BuildingsFlags.BUILDINGS_DRAW);
            constBuffer.SetCBufferVS(0);
            constBuffer.SetCBufferGS(0);
            constBuffer.SetCBufferPS(0);

            rs.SetupVertexInput(vertexBuffer, null, signature);

            rs.SetBlendState(BlendState.Opaque);
            rs.SetDepthStencilState(DepthStencilState.Default);
            rs.SetRasterizerState(RasterizerState.CullCCW);


            rs.Draw(Primitive.PointList, vertexBuffer.Capacity, 0);
        }
        void UpdateColors(Color[] cols)
        {
            int count = cols.Length > 15 ? 15  : cols.Length;

            for (int i = 1; i < count + 1; i++)
            {
                var v = cols[i - 1].ToVector4();

                dotsBuf.Data.Colors[i * 4 + 0] = v.X;
                dotsBuf.Data.Colors[i * 4 + 1] = v.Y;
                dotsBuf.Data.Colors[i * 4 + 2] = v.Z;
                dotsBuf.Data.Colors[i * 4 + 3] = v.W;
            }

            dotsBuf.UpdateCBuffer();
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gameTime"></param>
        void DrawInternal(GameTime gameTime)
        {
            var dev = Game.GraphicsDevice;

            viewMatrix = DMatrix.LookAtRH(cameraPosition, DVector3.Zero, DVector3.UnitY);

            DMatrix vvvM = viewMatrix;

            viewMatrix.TranslationVector = DVector3.Zero;

            var camPos = cameraPosition;

            if (Game.InputDevice.IsKeyDown(Keys.LeftShift))
            {
                DVector3 cameraUp    = cameraPosition / cameraPosition.Length();
                DVector3 lookAtPoint = cameraUp * Config.earthRadius;

                double length = Config.CameraDistance - Config.earthRadius;

                var quat = DQuaternion.RotationAxis(DVector3.UnitY, FreeCamYaw) * DQuaternion.RotationAxis(DVector3.UnitX, FreeCamPitch);

                var qRot = DMatrix.RotationQuaternion(quat);
                var mat  = DMatrix.Identity;

                var xAxis = DVector3.TransformNormal(DVector3.UnitX, DMatrix.RotationAxis(DVector3.UnitY, Yaw));
                xAxis.Normalize();

                mat.Up      = cameraUp;
                mat.Right   = xAxis;
                mat.Forward = DVector3.Cross(xAxis, cameraUp);
                mat.Forward.Normalize();

                var matrix = qRot * mat;

                var c = DVector3.Transform(new DVector3(0, 0, length), matrix);

                var camPoint = new DVector3(c.X, c.Y, c.Z) + lookAtPoint;

                camPos = camPoint;

                viewMatrix = DMatrix.LookAtRH(camPoint, lookAtPoint, cameraUp);
                vvvM       = viewMatrix;
                viewMatrix.TranslationVector = DVector3.Zero;
            }

            viewMatrixFloat = DMatrix.ToFloatMatrix(viewMatrix);
            projMatrixFloat = DMatrix.ToFloatMatrix(projMatrix);

            var viewDir = cameraPosition / cameraPosition.Length();

            constBuffer.Data.ViewProj      = viewMatrixFloat * projMatrixFloat;
            constBuffer.Data.ViewPositionX = camPos.X;
            constBuffer.Data.ViewPositionY = camPos.Y;
            constBuffer.Data.ViewPositionZ = camPos.Z;
            constBuffer.Data.Temp          = new Vector4(0.0f, (float)Config.earthRadius, 0, 0);
            constBuffer.Data.ViewDir       = new Vector4((float)viewDir.X, (float)viewDir.Y, (float)viewDir.Z, 0);
            constBuffer.UpdateCBuffer();

            Game.GraphicsDevice.VertexShaderConstants[0] = constBuffer;

            Game.GraphicsDevice.PixelShaderSamplers[0]  = SamplerState.LinearClamp;
            Game.GraphicsDevice.PixelShaderResources[1] = frame;

            if (gridVertexBuffer != null)
            {
                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_TEXTURED | (Config.ShowFrames ? GlobeFlags.SHOW_FRAMES : GlobeFlags.NONE),
                    Primitive.TriangleList,
                    BlendState.AlphaBlend,
                    RasterizerState.CullCW,
                    DepthStencilState.Readonly);

                Game.GraphicsDevice.PixelShaderResources[0] = gridTex;

                Game.GraphicsDevice.SetupVertexInput(gridVertexBuffer, gridIndexBuffer);
                dev.DrawIndexed(/*Primitive.TriangleList,*/ gridIndexBuffer.Capacity, 0, 0);
            }

            var rastState = Game.InputDevice.IsKeyDown(Keys.Tab) ? RasterizerState.Wireframe : RasterizerState.CullCW;

            Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_TEXTURED | (Config.ShowFrames ? GlobeFlags.SHOW_FRAMES : GlobeFlags.NONE),
                Primitive.TriangleList,
                BlendState.AlphaBlend,
                rastState,
                DepthStencilState.Default);

            foreach (var globeTile in tilesToRender)
            {
                var tex = Game.GetService <LayerService>().MapLayer.CurrentMapSource.GetTile(globeTile.Value.X, globeTile.Value.Y, globeTile.Value.Z).Tile;
                dev.PixelShaderResources[0] = tex;

                dev.SetupVertexInput(globeTile.Value.VertexBuf, globeTile.Value.IndexBuf);
                dev.DrawIndexed(globeTile.Value.IndexBuf.Capacity, 0, 0);
            }


            dotsBuf.Data.View = viewMatrixFloat;
            dotsBuf.Data.Proj = projMatrixFloat;
            dotsBuf.UpdateCBuffer();

            //// Draw simple railroads
            //if (simpleRailroadsVB != null && Config.ShowRailroads) {
            //	Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
            //		GlobeFlags.DRAW_VERTEX_LINES | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_SEGMENTED_LINES,
            //		Primitive.LineList,
            //		BlendState.AlphaBlend,
            //		RasterizerState.CullNone,
            //		DepthStencilState.None);
            //
            //	constBuffer.Data.Temp = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
            //	constBuffer.UpdateCBuffer();
            //
            //	Game.GraphicsDevice.VertexShaderConstants[1]	= dotsBuf;
            //	Game.GraphicsDevice.GeometryShaderConstants[1]	= dotsBuf;
            //	Game.GraphicsDevice.GeometryShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.VertexShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.PixelShaderConstants[0]		= constBuffer;
            //
            //	Game.GraphicsDevice.PixelShaderResources[0] = railRoadsTex;
            //	Game.GraphicsDevice.PixelShaderSamplers[0]	= SamplerState.LinearWrap;
            //
            //	dev.SetupVertexInput(simpleRailroadsVB, null);
            //	dev.Draw(simpleRailroadsVB.Capacity, 0);
            //}


            //// Draw buildings
            //if (contourBuildingsVB != null && Config.ShowBuildingsContours) {
            //
            //	Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
            //		GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_COLOR,
            //		Primitive.LineList,
            //		BlendState.AlphaBlend,
            //		RasterizerState.CullNone,
            //		DepthStencilState.None);
            //
            //
            //	constBuffer.Data.Temp = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
            //	constBuffer.UpdateCBuffer();
            //
            //	Game.GraphicsDevice.VertexShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.PixelShaderConstants[0]		= constBuffer;
            //
            //	dev.SetupVertexInput(contourBuildingsVB, null);
            //	dev.Draw(contourBuildingsVB.Capacity, 0);
            //}

            // Draw Lines
            if (linesBatch.Count != 0 && Config.ShowRoads)
            {
                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_COLOR,
                    Primitive.LineList,
                    BlendState.AlphaBlend,
                    RasterizerState.CullNone,
                    DepthStencilState.None);


                constBuffer.Data.Temp = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
                constBuffer.UpdateCBuffer();

                Game.GraphicsDevice.VertexShaderConstants[0] = constBuffer;
                Game.GraphicsDevice.PixelShaderConstants[0]  = constBuffer;

                foreach (var vb in linesBatch)
                {
                    dev.SetupVertexInput(vb, null);
                    dev.Draw(vb.Capacity, 0);
                }
            }



            // Draw simple railroads
            if (linesPolyBatch.Count != 0 && Config.ShowRoads)
            {
                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_VERTEX_LINES | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_LINES,
                    Primitive.LineList,
                    BlendState.AlphaBlend,
                    RasterizerState.CullNone,
                    DepthStencilState.None);

                constBuffer.Data.Temp = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
                constBuffer.UpdateCBuffer();

                Game.GraphicsDevice.VertexShaderConstants[1]   = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[1] = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[0] = constBuffer;
                Game.GraphicsDevice.VertexShaderConstants[0]   = constBuffer;
                Game.GraphicsDevice.PixelShaderConstants[0]    = constBuffer;


                foreach (var vb in linesPolyBatch)
                {
                    dev.SetupVertexInput(vb, null);
                    dev.Draw(vb.Capacity, 0);
                }
            }



            if (Config.ShowPOI)
            {
                dotsBuf.Data.TexWHST = new Vector4(geoObjects.Width, geoObjects.Height, 164.0f, 0.05f);
                dotsBuf.UpdateCBuffer();

                Game.GraphicsDevice.VertexShaderConstants[1]   = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[1] = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[0] = constBuffer;

                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_VERTEX_LINES | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_DOTS | GlobeFlags.DOTS_WORLDSPACE,
                    Primitive.PointList,
                    BlendState.AlphaBlend,
                    RasterizerState.CullNone,
                    DepthStencilState.None);

                Game.GraphicsDevice.PixelShaderResources[0] = geoObjects;
                Game.GraphicsDevice.PixelShaderSamplers[0]  = SamplerState.LinearClamp;

                dev.SetupVertexInput(dotsVB, null);
                dev.Draw(dotsVB.Capacity - geoObjectStart, geoObjectStart);
            }



            // Draw people
            if (Config.ShowPeople)
            {
                dotsBuf.Data.TexWHST = new Vector4(socioClasses.Width, socioClasses.Height, 64.0f, 0.025f);
                dotsBuf.UpdateCBuffer();

                Game.GraphicsDevice.VertexShaderConstants[1]   = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[1] = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[0] = constBuffer;

                Game.GraphicsDevice.PixelShaderResources[0] = socioClasses;
                Game.GraphicsDevice.PixelShaderSamplers[0]  = SamplerState.LinearClamp;

                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_VERTEX_LINES | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_DOTS | GlobeFlags.DOTS_WORLDSPACE,
                    Primitive.PointList,
                    BlendState.AlphaBlend,
                    RasterizerState.CullNone,
                    DepthStencilState.None);

                dev.SetupVertexInput(dotsVB, null);
                dev.Draw(geoObjectStart - 1, 0);
            }



            //// Draw heatmap
            //if (Config.ShowHeatMap && heatVB != null) {
            //	constBuffer.Data.Temp = new Vector4((float)Config.MaxHeatMapLevel, Config.HeatMapTransparency, HeatMapDim, 0);
            //	constBuffer.UpdateCBuffer();
            //
            //	Game.GraphicsDevice.VertexShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.PixelShaderConstants[0]		= constBuffer;
            //
            //	Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
            //		GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_HEAT,
            //		Primitive.TriangleList,
            //		BlendState.AlphaBlend,
            //		RasterizerState.CullNone,
            //		DepthStencilState.None);
            //
            //
            //	Game.GraphicsDevice.PixelShaderSamplers[0] = SamplerState.LinearClamp;
            //	Game.GraphicsDevice.PixelShaderSamplers[1] = SamplerState.AnisotropicClamp;
            //
            //	Game.GraphicsDevice.PixelShaderResources[0] = heatMap;
            //	Game.GraphicsDevice.PixelShaderResources[1] = heatMapPalette;
            //
            //	Game.GraphicsDevice.SetupVertexInput(heatVB, heatIB);
            //	Game.GraphicsDevice.DrawIndexed(heatIB.Capacity, 0, 0);
            //}

            //// Draw infection map
            //if (Config.ShowInfectHeatMap && heatVB != null) {
            //	constBuffer.Data.Temp = new Vector4((float)Config.MaxInfectLevel, 0.0f, HeatMapDim, 0);
            //	constBuffer.UpdateCBuffer();
            //
            //	Game.GraphicsDevice.VertexShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.PixelShaderConstants[0]		= constBuffer;
            //
            //	Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
            //		GlobeFlags.DRAW_POLY | GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_HEAT,
            //		Primitive.TriangleList,
            //		BlendState.AlphaBlend,
            //		RasterizerState.CullNone,
            //		DepthStencilState.None);
            //
            //	Game.GraphicsDevice.PixelShaderSamplers[0] = SamplerState.LinearClamp;
            //	Game.GraphicsDevice.PixelShaderSamplers[1] = SamplerState.AnisotropicClamp;
            //
            //	Game.GraphicsDevice.PixelShaderResources[0] = infectMap;
            //	Game.GraphicsDevice.PixelShaderResources[1] = heatMapPalette;
            //
            //	Game.GraphicsDevice.SetupVertexInput(heatVB, heatIB);
            //	Game.GraphicsDevice.DrawIndexed(/*Primitive.TriangleList,*/ heatIB.Capacity, 0, 0);
            //}


            ////Draw atmosphere
            //if (Config.ShowAtmosphere && atmosVB != null) {
            //	constBuffer.Data.Temp = new Vector4(atmosTime, Config.ArrowsScale, 0.0f, 0);
            //	constBuffer.UpdateCBuffer();
            //
            //	Game.GraphicsDevice.VertexShaderConstants[0]	= constBuffer;
            //	Game.GraphicsDevice.PixelShaderConstants[0]		= constBuffer;
            //
            //
            //	Game.GraphicsDevice.PixelShaderResources[0] = atmosTexture;
            //	Game.GraphicsDevice.PixelShaderResources[1] = heatMapPalette;
            //	Game.GraphicsDevice.PixelShaderResources[2] = atmosNextTexture;
            //	Game.GraphicsDevice.PixelShaderResources[3] = arrowTex;
            //
            //
            //	Game.GraphicsDevice.PixelShaderSamplers[0] = SamplerState.LinearClamp;
            //	Game.GraphicsDevice.PixelShaderSamplers[1] = SamplerState.AnisotropicClamp;
            //
            //	Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
            //		GlobeFlags.DRAW_VERTEX_POLY | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_ATMOSPHERE,
            //		Primitive.TriangleList,
            //		BlendState.AlphaBlend,
            //		RasterizerState.CullNone,
            //		DepthStencilState.None);
            //
            //	Game.GraphicsDevice.SetupVertexInput(atmosVB, atmosIB);
            //	Game.GraphicsDevice.DrawIndexed(atmosIB.Capacity, 0, 0);
            //}


            //Draw airlines
            if (airLinesVB != null && Config.ShowAirLines)
            {
                constBuffer.Data.Temp = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
                constBuffer.UpdateCBuffer();

                Game.GraphicsDevice.VertexShaderConstants[1]   = dotsBuf;
                Game.GraphicsDevice.GeometryShaderConstants[0] = constBuffer;
                Game.GraphicsDevice.GeometryShaderConstants[1] = dotsBuf;

                Game.GraphicsDevice.PipelineState = myMiniFactory.ProducePipelineState(
                    GlobeFlags.DRAW_VERTEX_LINES | GlobeFlags.USE_GEOCOORDS | GlobeFlags.VERTEX_SHADER | GlobeFlags.DRAW_ARCS,
                    Primitive.LineList,
                    BlendState.Additive,
                    RasterizerState.CullNone,
                    DepthStencilState.Readonly);

                dev.SetupVertexInput(airLinesVB, null);
                dev.Draw(/*Primitive.LineList,*/ airLinesVB.Capacity, 0);
            }

            DrawDebugLines();

            //Game.GetService<DebugStrings>().Add("Cam pos     : " + Game.GetService<Camera>().CameraMatrix.TranslationVector, Color.Red);
            //Game.GetService<DebugStrings>().Add("Radius      : " + Config.earthRadius, Color.Red);
            //Game.GetService<DebugStrings>().Add("Level       : " + CurrentLevel, Color.Green);
            //Game.GetService<DebugStrings>().Add("CamDistance : " + Config.CameraDistance, Color.Green);
            //Game.GetService<DebugStrings>().Add("Pitch : " + Pitch, Color.Green);
            //Game.GetService<DebugStrings>().Add("Width : " + Game.GraphicsDevice.Viewport.Width, Color.Green);
            Game.GetService <DebugStrings>().Add("Height : " + (Config.CameraDistance - Config.earthRadius) * 1000.0, Color.Green);
        }
Beispiel #4
0
        public void Draw3(GameTime gameTime)
        {
            var rs  = Game.GraphicsDevice;
            var cam = Game.GetService <Camera>();
            //var dr	= rs.DebugRender;
            //dr.DrawBasis(Matrix.Translation(1.0f, 1.0f, 1.0f), 100.0f);


            //int w = rs.Viewport.Width;
            //int h = rs.Viewport.Height;
            //dr.DrawBox(new BoundingBox(new Vector3(0, 0, 0), new Vector3(w, 1000, h)), Color.Green);
            //dr.DrawPoint(new Vector3(w / 2, 0, h / 2), 2.0f, Color.Red);

            var numTiles = 1 << (int)Level;
            int x        = (int)(numTiles * CenterPositionMercator.X);
            int y        = (int)(numTiles * CenterPositionMercator.Y);


            vertexCount = 0;

            var srvs = new List <Texture2D>();

            for (int row = -TilesCountOnLowLevel; row <= TilesCountOnLowLevel; row++)
            {
                for (int col = -TilesCountOnLowLevel; col <= TilesCountOnLowLevel; col++)
                {
                    if (x + col < 0 || x + col > numTiles - 1 || y + row < 0 || y + row > numTiles - 1)
                    {
                        continue;
                    }

                    AddQuad(x + col, y + row, numTiles);
                    srvs.Add(CurrentMapSource.GetTile(x + col, y + row, (int)Level).Tile);
                }
            }

            vertexBuffer.SetData(vertices, 0, vertexCount);

            constBuffer.Data.ViewProj  = cam.GetViewMatrix(StereoEye.Mono) * cam.GetProjectionMatrix(StereoEye.Mono);
            constBuffer.Data.Zoom      = new Vector4(Zoom);
            constBuffer.Data.Offset    = new Vector4(Offset, 0.0f, 0.0f);
            constBuffer.Data.Padding   = new Vector4();
            constBuffer.Data.TesAmount = new Vector4(TesselationFactor);
            constBuffer.UpdateCBuffer();


            string signature;

            shader.SetVertexShader((int)MapFlags.MAP_DRAW);
            shader.SetHullShader((int)MapFlags.MAP_DRAW);
            shader.SetDomainShader((int)MapFlags.MAP_DRAW);
            shader.SetPixelShader((int)MapFlags.MAP_DRAW);
            constBuffer.SetCBufferVS(0);
            constBuffer.SetCBufferHS(0);
            constBuffer.SetCBufferDS(0);
            constBuffer.SetCBufferPS(0);


            rs.SetPSSamplerState(0, SamplerState.LinearClamp);
            rs.SetDSSamplerState(0, SamplerState.LinearClamp);


            rs.SetupVertexInput(vertexBuffer, null);

            rs.SetBlendState(BlendState.Opaque);
            rs.SetDepthStencilState(DepthStencilState.Default);

            rs.SetRasterizerState(Game.InputDevice.IsKeyDown(Keys.NumPad1) ? RasterizerState.Wireframe : RasterizerState.CullCW);


            for (int i = 0; i < srvs.Count; i++)
            {
                srvs[i].SetPS(0);
                quads[i].SRV0.SetDS(1); quads[i].SRV1.SetDS(2); quads[i].SRV2.SetDS(3); quads[i].SRV3.SetDS(4);
                quads[i].SRV0.SetPS(1); quads[i].SRV1.SetPS(2); quads[i].SRV2.SetPS(3); quads[i].SRV3.SetPS(4);

                rs.Draw(4, 4 * i);


                //rs.DeviceContext.DomainShader.SetShaderResources(1, new ShaderResourceView[] { null, null, null, null });
                //rs.DeviceContext.PixelShader.SetShaderResources(1, new ShaderResourceView[] { null, null, null, null });
            }

            quads.Clear();
            srvs.Clear();

            //rs.DeviceContext.VertexShader.SetConstantBuffer(0, null);
            //rs.DeviceContext.HullShader.SetConstantBuffer(0, null);
            //rs.DeviceContext.DomainShader.SetConstantBuffer(0, null);
            //rs.DeviceContext.PixelShader.SetConstantBuffer(0, null);
            //
            //rs.DeviceContext.PixelShader.SetSampler(0, null);
            //rs.DeviceContext.DomainShader.SetSampler(0, null);
            //rs.DeviceContext.PixelShader.SetShaderResource(0, null);
            //
            //rs.DeviceContext.VertexShader.Set(null);
            //rs.DeviceContext.HullShader.Set(null);
            //rs.DeviceContext.DomainShader.Set(null);
            //rs.DeviceContext.PixelShader.Set(null);
        }