void Filter(IPostProcessorContext context) { Instrument.Begin(InstrumentFilter); if (blur != null) { blur.Filter(shadowSceneMap); } //---------------------------------------------------------------- // エフェクト shadowColorParameter.SetValue(shadowColor); shadowSceneMapParameter.SetValue(shadowSceneMap); //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, sssmEffect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
void Filter(IPostProcessorContext context) { Instrument.Begin(InstrumentFilter); //================================================================ // シーンにブラーを適用 blur.Filter(context.Source, bluredSceneMap); //================================================================ // シーンとブラー済みシーンを深度マップに基いて合成 //---------------------------------------------------------------- // エフェクト var distance = internalCamera.Projection.FarPlaneDistance - internalCamera.Projection.NearPlaneDistance; dofEffect.NearPlaneDistance = internalCamera.Projection.NearPlaneDistance; dofEffect.FarPlaneDistance = internalCamera.Projection.FarPlaneDistance / distance; dofEffect.FocusDistance = internalCamera.FocusDistance; dofEffect.FocusRange = internalCamera.FocusRange; dofEffect.DepthMap = depthMap; dofEffect.BluredSceneMap = bluredSceneMap; //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, dofEffect.Effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
// シャドウ マップを描画。 public void Draw(ref Vector3 lightDirection) { GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; // 各ライト カメラで描画。 for (int i = 0; i < splitCameras.Length; i++) { var camera = splitCameras[i]; var renderTarget = splitRenderTargets[i]; var shadowCasters = splitShadowCasters[i]; //------------------------------------------------------------ // ライトのビュー×射影行列の更新 splitLightCameras[i].Update(camera, ref lightDirection); //------------------------------------------------------------ // エフェクト shadowMapEffect.LightViewProjection = splitLightCameras[i].LightViewProjection; //------------------------------------------------------------ // 描画 GraphicsDevice.SetRenderTarget(renderTarget); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); while (0 < shadowCasters.Count) { var shadowCaster = shadowCasters.Dequeue(); shadowCaster.Draw(shadowMapEffect); } if (shadowMapEffect.ShadowMapTechnique == Techniques.Vsm && blur != null) { blur.Filter(renderTarget); } GraphicsDevice.SetRenderTarget(null); TextureDisplay.Add(renderTarget); } }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); //---------------------------------------------------------------- // ブルーム エクストラクト マップ bloomExtractEffect.Threshold = Threshold; GraphicsDevice.SetRenderTarget(bloomExtractMap); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, bloomExtractEffect.Effect); SpriteBatch.Draw(context.Source, bloomExtractMap.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); //---------------------------------------------------------------- // ブルーム エクストラクト マップへブラーを適用 blur.Filter(bloomExtractMap); //---------------------------------------------------------------- // ブルーム bloomEffect.BloomIntensity = BloomIntensity; bloomEffect.BaseIntensity = BaseIntensity; bloomEffect.BloomSaturation = BloomSaturation; bloomEffect.BaseSaturation = BaseSaturation; bloomEffect.BloomExtractMap = bloomExtractMap; GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, bloomEffect.Effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }