/// <summary> /// Called when the DrawableGameComponent needs to be drawn. Override this method with component-specific drawing code. Reference page contains links to related conceptual articles. /// </summary> /// <param name="gameTime">Time passed since the last call to Draw.</param> public override void Draw(GameTime gameTime) { // Set the GBuffer SetGBuffer(); // Clear the GBuffer ClearGBuffer(); // Render sky if enabled if (SkyRenderer.Enabled) { // To create a Static SunLight, uncomment this line //SkyRenderer.Parameters.LightDirection = new Vector4(LightManager.Light.Direction, 1); skyRenderer.Draw(gameTime, camera); } // Render the scene scene.DrawScene(gameTime); // Resolve the GBuffer ResolveGBuffer(); // Draw Depth for Shadow Mapping DrawDepth(gameTime); // Render Shadows var shadowOcclusion = shadowRenderer.Draw(scene, depthTexture, LightManager.Light, camera); // Draw Lights lightManager.DrawLights(GraphicsDevice, colorRT, normalRT, depthRT, lightRT, camera, scene); // Combine the Final scene CombineFinal(shadowOcclusion); // Render SSAO if enabled if (SSAORenderer.Enabled) { ssaoRenderer.Draw(GraphicsDevice, normalRT, depthRT, sceneRT, scene, camera, null); } // Post Processing Render postProcessingManager.Draw(null, camera); // Render output spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, null, null); spriteBatch.Draw((Texture2D)colorRT, new Rectangle(0, 0, 128, 128), Color.White); spriteBatch.Draw((Texture2D)depthRT, new Rectangle(128, 0, 128, 128), Color.White); spriteBatch.End(); base.Draw(gameTime); }