Task IQueryPostProcessor <TCommand, VoidUnit> .ProcessAsync( TCommand command, IPostProcessorContext <VoidUnit> context, CancellationToken cancellationToken) { return(ProcessAsync(command, cancellationToken)); }
void Filter(IPostProcessorContext context) { Instrument.Begin(InstrumentFilter); //---------------------------------------------------------------- // エフェクト edgeEffect.EdgeWidth = EdgeWidth; edgeEffect.EdgeIntensity = EdgeIntensity; edgeEffect.NormalThreshold = NormalThreshold; edgeEffect.DepthThreshold = DepthThreshold; edgeEffect.NormalSensitivity = NormalSensitivity; edgeEffect.DepthSensitivity = DepthSensitivity; edgeEffect.EdgeColor = EdgeColor; edgeEffect.NormalDepthMap = normalDepthMap; //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, edgeEffect.Effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
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(); }
Task IQueryPostProcessor <TCommand, VoidUnit> .ProcessAsync( TCommand command, IPostProcessorContext <VoidUnit> context, CancellationToken cancellationToken) { Process(command, cancellationToken); return(TaskBridge.CompletedTask); }
Task IQueryPostProcessor <TQuery, TResult> .ProcessAsync( TQuery query, IPostProcessorContext <TResult> context, CancellationToken cancellationToken) { Process(query, context, cancellationToken); return(TaskBridge.CompletedTask); }
public Task ProcessAsync( Calculate request, IPostProcessorContext <int> context, CancellationToken cancellationToken) { context.Result = Value; return(TaskBridge.CompletedTask); }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); DrawNormalDepth(context); Filter(context); TextureDisplay.Add(normalDepthMap); Instrument.End(); }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); DrawShadowScene(context); Filter(context); TextureDisplay.Add(shadowSceneMap); Instrument.End(); }
void DrawNormalDepth(IPostProcessorContext context) { Instrument.Begin(InstrumentDrawNormalDepth); var viewerCamera = context.ActiveCamera; //---------------------------------------------------------------- // 内部カメラの準備 internalCamera.View.Position = viewerCamera.View.Position; internalCamera.View.Direction = viewerCamera.View.Direction; internalCamera.View.Up = viewerCamera.View.Up; internalCamera.Projection.Fov = viewerCamera.Projection.Fov; internalCamera.Projection.AspectRatio = viewerCamera.Projection.AspectRatio; internalCamera.Projection.NearPlaneDistance = viewerCamera.Projection.NearPlaneDistance; internalCamera.Projection.FarPlaneDistance = FarPlaneDistance; internalCamera.Update(); internalCamera.Frustum.GetCorners(frustumCorners); frustumSphere = BoundingSphere.CreateFromPoints(frustumCorners); //---------------------------------------------------------------- // エフェクト normalDepthMapEffect.View = internalCamera.View.Matrix; normalDepthMapEffect.Projection = internalCamera.Projection.Matrix; //---------------------------------------------------------------- // 描画 GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SetRenderTarget(normalDepthMap); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); // 不透明オブジェクトのみ対象。 for (int i = 0; i < context.OpaqueObjects.Count; i++) { var opaque = context.OpaqueObjects[i]; // 専用カメラの視錐台に含まれるもののみを描画。 if (IsVisibleObject(opaque)) { opaque.Draw(normalDepthMapEffect); } } GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.Draw(fillTexture, context.Destination.Bounds, Color); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); monochromeEffect.Cb = cbCr.X; monochromeEffect.Cr = cbCr.Y; GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, monochromeEffect.Effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
public override void Process(IPostProcessorContext context) { Instrument.Begin(InstrumentProcess); var height = context.Destination.Height; density.SetValue(height * MathHelper.PiOver2); brightness.SetValue(Brightness); GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
void Filter(IPostProcessorContext context) { Instrument.Begin(InstrumentFilter); //---------------------------------------------------------------- // エフェクト ssaoEffect.SsaoMap = ssaoMap; //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(context.Destination); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, ssaoEffect.Effect); SpriteBatch.Draw(context.Source, context.Destination.Bounds, Color.White); SpriteBatch.End(); GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
void DrawShadowScene(IPostProcessorContext context) { Instrument.Begin(InstrumentDrawShadowScene); var camera = context.ActiveCamera; var shadowMap = context.ShadowMap; //---------------------------------------------------------------- // エフェクト shadowSceneEffect.View = camera.View.Matrix; shadowSceneEffect.Projection = camera.Projection.Matrix; shadowSceneEffect.SplitDistances = shadowMap.SplitDistances; shadowSceneEffect.SplitLightViewProjections = shadowMap.SplitLightViewProjections; shadowSceneEffect.SplitShadowMaps = shadowMap.SplitShadowMaps; //---------------------------------------------------------------- // 描画 GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SetRenderTarget(shadowSceneMap); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); for (int i = 0; i < context.OpaqueObjects.Count; i++) { var opaque = context.OpaqueObjects[i]; opaque.Draw(shadowSceneEffect); } for (int i = 0; i < context.TranslucentObjects.Count; i++) { var translucent = context.TranslucentObjects[i]; translucent.Draw(shadowSceneEffect); } GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
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(); }
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 DrawNormalDepth(IPostProcessorContext context) { Instrument.Begin(InstrumentDrawNormalDepth); var viewerCamera = context.ActiveCamera; //---------------------------------------------------------------- // 内部カメラの準備 internalCamera.View.Position = viewerCamera.View.Position; internalCamera.View.Direction = viewerCamera.View.Direction; internalCamera.View.Up = viewerCamera.View.Up; internalCamera.Projection.Fov = viewerCamera.Projection.Fov; internalCamera.Projection.AspectRatio = viewerCamera.Projection.AspectRatio; internalCamera.Projection.NearPlaneDistance = viewerCamera.Projection.NearPlaneDistance; internalCamera.Projection.FarPlaneDistance = FarPlaneDistance; internalCamera.Update(); internalCamera.Frustum.GetCorners(frustumCorners); frustumSphere = BoundingSphere.CreateFromPoints(frustumCorners); //---------------------------------------------------------------- // エフェクト normalDepthMapEffect.View = internalCamera.View.Matrix; normalDepthMapEffect.Projection = internalCamera.Projection.Matrix; //---------------------------------------------------------------- // 描画 GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SetRenderTarget(normalDepthMap); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); // 不透明オブジェクトのみ対象。 for (int i = 0; i < context.OpaqueObjects.Count; i++) { var opaque = context.OpaqueObjects[i]; // 専用カメラの視錐台に含まれるもののみを描画。 if (IsVisibleObject(opaque)) opaque.Draw(normalDepthMapEffect); } GraphicsDevice.SetRenderTarget(null); Instrument.End(); }
public abstract void Process(IPostProcessorContext context);
void DrawSsaoMap(IPostProcessorContext context) { Instrument.Begin(InstrumentDrawSsaoMap); var viewerCamera = context.ActiveCamera; //================================================================ // // 法線深度マップを描画 // //---------------------------------------------------------------- // 内部カメラの準備 internalCamera.View.Position = viewerCamera.View.Position; internalCamera.View.Direction = viewerCamera.View.Direction; internalCamera.View.Up = viewerCamera.View.Up; internalCamera.Projection.Fov = viewerCamera.Projection.Fov; internalCamera.Projection.AspectRatio = viewerCamera.Projection.AspectRatio; internalCamera.Projection.NearPlaneDistance = viewerCamera.Projection.NearPlaneDistance; // TODO // 状況に応じて FarPlaneDistance を変化させられるように。 //internalCamera.Projection.FarPlaneDistance = viewerCamera.Projection.FarPlaneDistance; internalCamera.Projection.FarPlaneDistance = 32; internalCamera.Update(); internalCamera.Frustum.GetCorners(frustumCorners); frustumSphere = BoundingSphere.CreateFromPoints(frustumCorners); //---------------------------------------------------------------- // エフェクト normalDepthMapEffect.View = internalCamera.View.Matrix; normalDepthMapEffect.Projection = internalCamera.Projection.Matrix; //---------------------------------------------------------------- // 描画 GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SetRenderTarget(normalDepthMap); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); // 不透明オブジェクトのみ対象。 for (int i = 0; i < context.OpaqueObjects.Count; i++) { var opaque = context.OpaqueObjects[i]; if (!(opaque is ShadowCaster)) continue; // 専用カメラの視錐台に含まれるもののみを描画。 if (IsVisibleObject(opaque)) opaque.Draw(normalDepthMapEffect); } GraphicsDevice.SetRenderTarget(null); //================================================================ // // SSAO マップを描画 // //---------------------------------------------------------------- // エフェクト var randomOffsetVector = viewerCamera.View.Position + viewerCamera.View.Direction; ssaoMapEffect.TotalStrength = TotalStrength; ssaoMapEffect.Strength = Strength; ssaoMapEffect.Falloff = Falloff; ssaoMapEffect.Radius = Radius; ssaoMapEffect.RandomOffset = randomOffsetVector.LengthSquared(); //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(ssaoMap); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, null, null, ssaoMapEffect.Effect); spriteBatch.Draw(normalDepthMap, ssaoMap.Bounds, Color.White); spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); //================================================================ // // SSAO マップへブラーを適用 // // TODO for (int i = 0; i < 3; i++) blur.Filter(ssaoMap, normalDepthMap); Instrument.End(); }
/// <summary> /// Executes an action after <typeparamref name="TQuery"/> was handled. /// </summary> /// <param name="query">The query to <see cref="IMediator"/>.</param> /// <param name="context"> /// The context that contains the result of <paramref name="query"/>. /// </param> /// <param name="cancellationToken"> /// A cancellation token that should be used to cancel the work. /// </param> protected abstract void Process( TQuery query, IPostProcessorContext <TResult> context, CancellationToken cancellationToken );
void DrawSsaoMap(IPostProcessorContext context) { Instrument.Begin(InstrumentDrawSsaoMap); var viewerCamera = context.ActiveCamera; //================================================================ // // 法線深度マップを描画 // //---------------------------------------------------------------- // 内部カメラの準備 internalCamera.View.Position = viewerCamera.View.Position; internalCamera.View.Direction = viewerCamera.View.Direction; internalCamera.View.Up = viewerCamera.View.Up; internalCamera.Projection.Fov = viewerCamera.Projection.Fov; internalCamera.Projection.AspectRatio = viewerCamera.Projection.AspectRatio; internalCamera.Projection.NearPlaneDistance = viewerCamera.Projection.NearPlaneDistance; // TODO // 状況に応じて FarPlaneDistance を変化させられるように。 //internalCamera.Projection.FarPlaneDistance = viewerCamera.Projection.FarPlaneDistance; internalCamera.Projection.FarPlaneDistance = 32; internalCamera.Update(); internalCamera.Frustum.GetCorners(frustumCorners); frustumSphere = BoundingSphere.CreateFromPoints(frustumCorners); //---------------------------------------------------------------- // エフェクト normalDepthMapEffect.View = internalCamera.View.Matrix; normalDepthMapEffect.Projection = internalCamera.Projection.Matrix; //---------------------------------------------------------------- // 描画 GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SetRenderTarget(normalDepthMap); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0); // 不透明オブジェクトのみ対象。 for (int i = 0; i < context.OpaqueObjects.Count; i++) { var opaque = context.OpaqueObjects[i]; if (!(opaque is ShadowCaster)) { continue; } // 専用カメラの視錐台に含まれるもののみを描画。 if (IsVisibleObject(opaque)) { opaque.Draw(normalDepthMapEffect); } } GraphicsDevice.SetRenderTarget(null); //================================================================ // // SSAO マップを描画 // //---------------------------------------------------------------- // エフェクト var randomOffsetVector = viewerCamera.View.Position + viewerCamera.View.Direction; ssaoMapEffect.TotalStrength = TotalStrength; ssaoMapEffect.Strength = Strength; ssaoMapEffect.Falloff = Falloff; ssaoMapEffect.Radius = Radius; ssaoMapEffect.RandomOffset = randomOffsetVector.LengthSquared(); //---------------------------------------------------------------- // 描画 GraphicsDevice.SetRenderTarget(ssaoMap); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, null, null, ssaoMapEffect.Effect); spriteBatch.Draw(normalDepthMap, ssaoMap.Bounds, Color.White); spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); //================================================================ // // SSAO マップへブラーを適用 // // TODO for (int i = 0; i < 3; i++) { blur.Filter(ssaoMap, normalDepthMap); } Instrument.End(); }