예제 #1
0
        /// <summary>
        /// Method to do the deferred lighting draw call
        /// </summary>
        /// <param name="camera"></param>
        public void DrawDeferred(DeferredLightingCamera camera)
        {
            GraphicsDevice.Clear(camera.ClearColor);

            if (deferredSceneRenderEffect == null)
            {
                deferredSceneRenderEffect = Game.Content.Load <Effect>("Shaders/DeferredRender/DeferredSceneRender");
            }

            deferredSceneRenderEffect.Parameters["colorMap"].SetValue(camera.RenderTarget);
            deferredSceneRenderEffect.Parameters["lightMap"].SetValue(lightMap);
            //deferredSceneRenderEffect.Parameters["sgrMap"].SetValue(camera.SpecularGlowReflectionMap);

            GraphicsDevice.BlendState        = BlendState.Opaque;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;
            GraphicsDevice.SamplerStates[0]  = SamplerState.LinearWrap;

            deferredSceneRenderEffect.CurrentTechnique.Passes[0].Apply();

            if (sceneQuad == null)
            {
                sceneQuad = new ScreenQuad(Game);
                sceneQuad.Initialize();
            }

            sceneQuad.Draw(-Vector2.One, Vector2.One);
        }
예제 #2
0
        public virtual void Draw(GameTime gameTime)
        {
            if (Enabled)
            {
                if (sq == null)
                {
                    sq = new ScreenQuad(Game);
                    sq.Initialize();
                }
                if (!UsesVertexShader)
                {
                    spriteBatch.Begin(SortMode, Blend, Sampler, DepthStencilState.None, RasterizerState.CullCounterClockwise);
                }
                else
                {
                    Game.GraphicsDevice.SamplerStates[0] = Sampler;
                }

                effect.CurrentTechnique.Passes[0].Apply();

                if (UsesVertexShader)
                {
                    sq.Draw(-Vector2.One, Vector2.One);
                }
                else
                {
                    spriteBatch.Draw(BackBuffer, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), Color.White);
                    spriteBatch.End();
                }
            }
        }