Exemple #1
0
        // Called when the game should draw itself
        protected override void Draw(GameTime gameTime)
        {
            // Capture the render
            renderCapture.Begin();

            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Draw all of the models
            foreach (CModel model in models)
            {
                if (camera.BoundingVolumeIsInView(model.BoundingSphere))
                {
                    model.Draw(camera.View, camera.Projection, ((FreeCamera)camera).Position);
                }
            }

            // End capturing
            renderCapture.End();

            GraphicsDevice.Clear(Color.Black);

            // Perform postprocessing with teh render of the scene
            postprocessor.Input = renderCapture.GetTexture();
            postprocessor.Draw();

            base.Draw(gameTime);
        }
Exemple #2
0
        // Called when the game should draw itself
        protected override void Draw(GameTime gameTime)
        {
            // Start rendering to depth map
            depthCapture.Begin();

            // Clear to white (max depth)
            GraphicsDevice.Clear(Color.White);

            foreach (CModel model in models)
            {
                if (camera.BoundingVolumeIsInView(model.BoundingSphere))
                {
                    model.CacheEffects();                     // Cache effect
                    model.SetModelEffect(depthEffect, false); // Set depth effect
                    model.Draw(camera.View, camera.Projection, ((FreeCamera)camera).Position);
                    model.RestoreEffects();                   // Restore effects
                }
            }

            // Finish rendering to depth map
            depthCapture.End();

            // Begin rendering the main render
            renderCapture.Begin();

            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Draw all models
            foreach (CModel model in models)
            {
                if (camera.BoundingVolumeIsInView(model.BoundingSphere))
                {
                    model.Draw(camera.View, camera.Projection, ((FreeCamera)camera).Position);
                }
            }

            // Finish the main render
            renderCapture.End();

            // Prepare to blur results of main render
            postprocessor.Input = renderCapture.GetTexture();
            // Output blur to our RenderCapture
            ((GaussianBlur)postprocessor).ResultCapture = blurCapture;
            // Perform blur
            postprocessor.Draw();

            // Set the three images to the DOF class
            dof.DepthMap  = depthCapture.GetTexture();
            dof.Unblurred = renderCapture.GetTexture();
            dof.Input     = ((GaussianBlur)postprocessor).ResultCapture.GetTexture();

            // Combine the images into the final result
            dof.Draw();

            base.Draw(gameTime);
        }
Exemple #3
0
        // Called when the game should draw itself
        protected override void Draw(GameTime gameTime)
        {
            renderCapture.Begin();

            GraphicsDevice.Clear(Color.CornflowerBlue);

            foreach (CModel model in models)
            {
                if (camera.BoundingVolumeIsInView(model.BoundingSphere))
                {
                    model.Draw(camera.View, camera.Projection, ((FreeCamera)camera).Position);
                }
            }

            renderCapture.End();

            GraphicsDevice.Clear(Color.Black);

            postprocessor.Input = renderCapture.GetTexture();
            postprocessor.Draw();

            base.Draw(gameTime);
        }