Esempio n. 1
0
            private void drawBlurredFrameBuffer(int kernelRadius, float sigma, float blurRotation)
            {
                FrameBuffer current = SharedData.CurrentEffectBuffer;
                FrameBuffer target  = SharedData.GetNextEffectBuffer();

                GLWrapper.SetBlend(BlendingParameters.None);

                using (BindFrameBuffer(target))
                {
                    blurShader.GetUniform <int>(@"g_Radius").UpdateValue(ref kernelRadius);
                    blurShader.GetUniform <float>(@"g_Sigma").UpdateValue(ref sigma);

                    Vector2 size = current.Size;
                    blurShader.GetUniform <Vector2>(@"g_TexSize").UpdateValue(ref size);

                    float   radians = -MathUtils.DegreesToRadians(blurRotation);
                    Vector2 blur    = new Vector2(MathF.Cos(radians), MathF.Sin(radians));
                    blurShader.GetUniform <Vector2>(@"g_BlurDirection").UpdateValue(ref blur);

                    blurShader.Bind();
                    DrawFrameBuffer(current, new RectangleF(0, 0, current.Texture.Width, current.Texture.Height), ColourInfo.SingleColour(Color4.White));
                    blurShader.Unbind();
                }
            }