示例#1
0
        private Surface GetSurface(IntSize screenSize, EffectLayer layer)
        {
            var surface = SurfacePool.Request(screenSize / layer.Downscale, Multisample);

            surface.Interpolation = InterpolationMode.Linear;
            surface.Repeat        = RepeatMode.Clamp;
            return(surface);
        }
        protected override void Apply(GraphicsContext gfx, Surface surface)
        {
            // Will compose images without blending
            gfx.Blending = Blending.Opaque;
            gfx.Shader   = _blurShader;

            // Request a temporary surface (we need to multipass)
            var temp = SurfacePool.Request(surface.Size);

            {
                // Horizontal pass (surface to temp)
                gfx.Surface        = temp;
                _blurShader.Vector = Vector.Right * Strength;
                gfx.DrawImage(surface, Vector.Zero);

                // Vertical pass (temp to surface)
                gfx.Surface        = surface;
                _blurShader.Vector = Vector.Down * Strength;
                gfx.DrawImage(temp, Vector.Zero);
            }
            SurfacePool.Recycle(temp);
        }