예제 #1
0
파일: Q19Game.cs 프로젝트: SvDvorak/Q19
 protected void DrawGame(GameTime gt)
 {
     if (!DebugDrawing)
     {
         Lighting.Draw(SpriteBatch, 1, 1);
     }
 }
예제 #2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            LightOverlay.Draw(gameTime, new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth / 2.0f, GraphicsDevice.PresentationParameters.BackBufferHeight / 2.0f), zoom: Zoom);

            foreach (Chunk c in Miscellaneous.GetChunksInFrame(WorldSystem, Camera))
            {
                c.Draw(gameTime, Camera);
            }

            LightOverlay.SetBackgroundColor(Miscellaneous.GetColorOfDayNightCycle(WorldTime));
            if (!Constants.IgnoreDayNightEffects)
            {
                LightOverlay.Splice(gameTime);
            }

            Constants.GraphicsDevice.SetRenderTarget(null);

            SpriteBatch.Begin();
            SpriteBatch.Draw(Constants.MainRenderTarget, Vector2.Zero, Color.White);
            SpriteBatch.End();



            DebugScreen.UpdateFPS(gameTime);
            if (ShowDebugInfo)
            {
                DebugScreen.Draw(gameTime, Camera);
            }

            base.Draw(gameTime);
        }
예제 #3
0
        public void Render(List <ViewEntity> entities, float time, ITransformation camera)
        {
            UpdateInstancing(entities);

            var arrTrans = new Dictionary <Enums.EntityType, Matrix4x4[]>();

            foreach (var transform in _transforms)
            {
                arrTrans.Add(transform.Key, transform.Value.ToArray());
            }

            _renderInstanceGroup.UpdateGeometry(arrTrans);

            _deferred.Draw(_renderState, camera, _instanceCounts, _textures, _normalMaps, _heightMaps, _intensities, _disableBackFaceCulling, time);

            _directShadowMap.Draw(_renderState, camera, _instanceCounts, _deferred.Depth, _lights[0].Direction, _disableBackFaceCulling, _deferred.Position, _deferred.Normal);
            _blurredShadowMap.Draw(_directShadowMap.Output);

            _environmentMap.CreateMap(entities[2], _renderState, 0, arrTrans, _instanceCounts, _textures, _normalMaps, _heightMaps, _intensities, _disableBackFaceCulling, _lights, camera, time);
            _environmentMap.Draw(_renderState, _deferred.Depth);
            _addEnvMap.Draw(_deferred.Color, _environmentMap.Output, 0.5f);

            _lighting.Draw(camera, _addEnvMap.Output, _deferred.Normal, _deferred.Position, _blurredShadowMap.Output, _deferred.IntensityMap, _lights);

            //_addProjectileColor.Draw(_deferred.ProjectileDepth, _deferred.Depth, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output);

            _sphereCut.Draw(camera, _lighting.Output, _deferred.Depth);

            _skybox.Draw(camera);
            _addSkybox.Draw(_skybox.Output, _sphereCut.Output);

            if (Bloom)
            {
                _bloom.Draw(_addSkybox.Output);
                _ssaoWithBlur.Draw(_deferred.Depth, _bloom.Output);
            }
            else
            {
                _ssaoWithBlur.Draw(_deferred.Depth, _addSkybox.Output);
            }


            TextureDrawer.Draw(_ssaoWithBlur.Output);
        }
예제 #4
0
        public void Draw(SpriteBatch batch)
        {
            Game.GraphicsDevice.Clear(Lighting.DarknessColor);
            Vector2 ceiledOffset = GameObject.VectorCeil(ViewOffset);

            Background.Draw(batch, ceiledOffset);
            for (int i = 0; i < GameObjectList.Count; i++)
            {
                GameObject obj = GameObjectList[i];
                obj.Draw(batch, ceiledOffset);
            }
            for (int i = 0; i < GameTileList.Count; i++)
            {
                GameTile tile = GameTileList[i];
                tile.Draw(batch, ceiledOffset);
            }
            Lighting.Draw(batch, ceiledOffset);
            Lighting.LightingDifficulty = transitionProgress + 1;
            batch.Draw(whiteChunk, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), null, Color.Black * ((float)transitionProgress / maxTransitionProgress), 0f, Vector2.Zero, SpriteEffects.None, 1f);
        }
예제 #5
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (!_reloaded)
            {
                Game.Lighting.Refresh();
                _reloaded = true;
            }

            // Draw background
            Game.GraphicsDevice.SetRenderTarget(BackgroundTexture);
            DrawComponentLayer(spriteBatch, -1);

            // Draw foreground
            Game.GraphicsDevice.SetRenderTarget(ForegroundTexture);

            // Prepare lighting
            Game.Lighting.Debug = DebugView.Enabled;
            Lighting.BeginDraw(Camera.ViewMatrix);
            Game.GraphicsDevice.Clear(Color.Transparent);

            // Ground rendering
            DrawComponentLayer(spriteBatch, 0);

            // Draw weather
            // TODO: better layer numbering
            DrawComponentLayer(spriteBatch, 10);

            // Draw entities and particles
            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Camera != null ? Camera.ViewMatrix : Matrix.Identity);
            Entities.ForEach(e => e.Draw(spriteBatch));
            Particles.ForEach(p => p.Draw(spriteBatch));
            spriteBatch.End();

            // Ground rendering
            DrawComponentLayer(spriteBatch, 1);
            Lighting.Draw();

            // Draw to screen
            Game.GraphicsDevice.SetRenderTarget(null);
            Game.GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
            spriteBatch.Draw(BackgroundTexture, Vector2.Zero, null, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            spriteBatch.Draw(ForegroundTexture, Vector2.Zero, null, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 1f);
            spriteBatch.End();

            // Render debug physics view
            if (DebugView.Enabled)
            {
                spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, Camera != null ? Camera.ViewMatrix : Matrix.Identity);
                foreach (Entity ent in Entities)
                {
                    var body = ent.GetComponent <BodyComponent>();
                    if (body != null)
                    {
                        spriteBatch.DrawRectangle(body.BoundingBox, new Color(255, 0, 0, 80), 0);
                    }
                }
                spriteBatch.End();
                Matrix proj = Matrix.CreateOrthographic(Game.Resolution.X / 64f, -Game.Resolution.Y / 64f, 0, 1);
                Matrix view = (Camera != null ? Matrix.CreateTranslation(-Camera.Position.X / 64f, -Camera.Position.Y / 64f, 0) : Matrix.Identity) *
                              Matrix.CreateRotationZ(Camera.Rotation) *
                              Matrix.CreateScale(Camera.Zoom);
                lock (Physics)
                    DebugView.RenderDebugData(proj, view);

                StringBuilder text = new StringBuilder();
                var           mpos = Camera.ToWorldSpace(Game.Input.GetPointerInput(0).Position);
                text.AppendFormat("Mouse position: {0}, {1}", (int)mpos.X, (int)mpos.Y);
                var font = ContentLoader.Fonts["menu"];
                spriteBatch.Begin();
                spriteBatch.DrawString(font, text, new Vector2(Game.Resolution.X, 0), Color.White, 0, new Vector2(font.MeasureString(text).X, 0), 0.3f, SpriteEffects.None, 1f);
                spriteBatch.End();
            }
        }