private static void RenderShadowOcclusion(GraphicsDevice graphicsDevice, RenderTarget2D depthTexture) { // Set the device to render to our shadow occlusion texture, and to use // the original DepthStencilSurface graphicsDevice.SetRenderTarget(_shadowOcclusion); Matrix cameraTransform; Camera.MainCamera.GetWorldMatrix(out cameraTransform); // Setup the Effect _shadowEffect.CurrentTechnique = shadowOcclusionTechniques[sm_filterType.GetValue <int>()]; _shadowEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(Camera.MainCamera.ViewProjectionMatrix)); _shadowEffect.Parameters["g_matInvView"].SetValue(cameraTransform); _shadowEffect.Parameters["g_matLightViewProj"].SetValue(_lightCamera.ViewProjectionMatrix); _shadowEffect.Parameters["g_vFrustumCornersVS"].SetValue(_farFrustumCornersVS); _shadowEffect.Parameters["ShadowMap"].SetValue(_shadowMap); _shadowEffect.Parameters["DepthTexture"].SetValue(depthTexture); _shadowEffect.Parameters["g_vOcclusionTextureSize"].SetValue(new Vector2(_shadowOcclusion.Width, _shadowOcclusion.Height)); _shadowEffect.Parameters["g_vShadowMapSize"].SetValue(new Vector2(2048, 2048)); // Begin effect _shadowEffect.CurrentTechnique.Passes[0].Apply(); // Draw the full screen quad DeferredRenderer.RenderFullScreenQuad(graphicsDevice); }
public static void RenderDirectionalLight(GraphicsDevice device, RenderTarget2D normalRT, RenderTarget2D depthRT, RenderTarget2D shadowRT) { _dirAmbEffect.Parameters["HalfPixel"].SetValue(_halfPixel); _dirAmbEffect.Parameters["NormalMap"].SetValue(normalRT); //_dirAmbEffect.Parameters["DepthMap"].SetValue(depthRT); _dirAmbEffect.Parameters["ShadowMap"].SetValue(shadowRT); _dirAmbEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(Camera.MainCamera.ViewProjectionMatrix)); _dirAmbEffect.Parameters["g_directional"].SetValue(r_sunIntensity.GetValue <float>()); _dirAmbEffect.CurrentTechnique.Passes[0].Apply(); DeferredRenderer.RenderFullScreenQuad(device); }