//--------------------// #region Apply /// <summary> /// Applies the shader to the content in the render delegate. /// </summary> /// <param name="render">The render delegate (is called once for every shader pass).</param> /// <param name="material">The material to be used by this shader; <c>null</c> for device texture.</param> /// <param name="camera">The camera for transformation information.</param> /// <param name="lights">An array of all lights this shader should consider; should be <c>null</c>.</param> public override void Apply(Action render, XMaterial material, Camera camera, params LightSource[] lights) { #region Sanity checks if (render == null) { throw new ArgumentNullException(nameof(render)); } if (camera == null) { throw new ArgumentNullException(nameof(camera)); } if (lights == null) { throw new ArgumentNullException(nameof(lights)); } #endregion // Always reset the textures since they might change their memory address at a device reset Effect.SetTexture(_normalTextureHandle, _normalTexture); if (_refractionView != null) { Effect.SetTexture(_refractionMapHandle, _refractionView.GetRenderTarget()); } if (_waterTexture == null) { Effect.SetTexture(_reflectionMapHandle, _reflectionView.GetRenderTarget()); } else { Effect.SetTexture(_reflectionMapHandle, _waterTexture); } base.Apply(render, material, camera, lights); }
/// <summary> /// Runs the actual shader passes /// </summary> /// <param name="render">The render delegate (is called once for every shader pass)</param> /// <param name="sceneSize">The size of the scene on the screen - leave empty for fullscreen</param> /// <param name="sceneMap">Should be <c>null</c> because a glow map is used instead</param> protected override void RunPasses(Action render, Size sceneSize, RenderTarget sceneMap) { // Pass the glow map instead of the scene map to the blurring filter base.RunPasses(render, sceneSize, _glowView.GetRenderTarget()); }