public void RenderDirectionalLight(IDirectionalLight directionalLight) { if (deferredDirectionalLightEffect == null) { deferredDirectionalLightEffect = AssetManager.GetAsset <Effect>("Shaders/Deferred/DeferredDirectionalLight"); } // Call lighting methods. // Load Light Params deferredDirectionalLightEffect.Parameters["halfPixel"].SetValue(halfPixel); deferredDirectionalLightEffect.Parameters["lightDirection"].SetValue(directionalLight.Direction); deferredDirectionalLightEffect.Parameters["Color"].SetValue(directionalLight.Color.ToVector3()); deferredDirectionalLightEffect.Parameters["normalMap"].SetValue(normalMap); deferredDirectionalLightEffect.Parameters["depthMap"].SetValue(depthMap); deferredDirectionalLightEffect.Parameters["power"].SetValue(directionalLight.Intensity); deferredDirectionalLightEffect.Parameters["sgrMap"].SetValue(SGRMap); deferredDirectionalLightEffect.Parameters["shadowMod"].SetValue((float)directionalLight.ShadowMod); deferredDirectionalLightEffect.Parameters["cameraPosition"].SetValue(Camera.Position); if (!ScreenSpaceShadows) { deferredDirectionalLightEffect.Parameters["CastShadow"].SetValue(directionalLight.CastShadow); if (directionalLight.CastShadow) { deferredDirectionalLightEffect.Parameters["shadowMap"].SetValue(directionalLight.ShadowMap); //SaveJpg(directionalLight.ShadowMap, "shadows.jpg"); } } deferredDirectionalLightEffect.Parameters["viewProjectionInv"].SetValue(Matrix.Invert(Camera.View * Camera.Projection)); deferredDirectionalLightEffect.Parameters["lightViewProjection"].SetValue(directionalLight.View * directionalLight.Projection); deferredDirectionalLightEffect.Techniques[0].Passes[0].Apply(); sceneQuad.Draw(-Vector2.One, Vector2.One); }
public void RenderDirectionalLight(IDirectionalLight directionalLight) { if (deferredDirectionalLightEffect == null) deferredDirectionalLightEffect = AssetManager.GetAsset<Effect>("Shaders/Deferred/DeferredDirectionalLight"); // Call lighting methods. // Load Light Params deferredDirectionalLightEffect.Parameters["halfPixel"].SetValue(halfPixel); deferredDirectionalLightEffect.Parameters["lightDirection"].SetValue(directionalLight.Direction); deferredDirectionalLightEffect.Parameters["Color"].SetValue(directionalLight.Color.ToVector3()); deferredDirectionalLightEffect.Parameters["normalMap"].SetValue(normalMap); deferredDirectionalLightEffect.Parameters["depthMap"].SetValue(depthMap); deferredDirectionalLightEffect.Parameters["power"].SetValue(directionalLight.Intensity); deferredDirectionalLightEffect.Parameters["sgrMap"].SetValue(SGRMap); deferredDirectionalLightEffect.Parameters["shadowMod"].SetValue((float)directionalLight.ShadowMod); deferredDirectionalLightEffect.Parameters["cameraPosition"].SetValue(Camera.Position); if (!ScreenSpaceShadows) { deferredDirectionalLightEffect.Parameters["CastShadow"].SetValue(directionalLight.CastShadow); if (directionalLight.CastShadow) { deferredDirectionalLightEffect.Parameters["shadowMap"].SetValue(directionalLight.ShadowMap); //SaveJpg(directionalLight.ShadowMap, "shadows.jpg"); } } deferredDirectionalLightEffect.Parameters["viewProjectionInv"].SetValue(Matrix.Invert(Camera.View * Camera.Projection)); deferredDirectionalLightEffect.Parameters["lightViewProjection"].SetValue(directionalLight.View * directionalLight.Projection); deferredDirectionalLightEffect.Techniques[0].Passes[0].Apply(); sceneQuad.Draw(-Vector2.One, Vector2.One); }