示例#1
0
        public void Filter(GraphicsContext graphics)
        {
            // Y軸方向へのガウス
            // uniform
            shaderGaussianX.SetUniformValue(shaderGaussianX.FindUniform("ReciprocalTexWidth"),
                                            1.0f / texScene.Width);
            shaderGaussianX.SetUniformValue(shaderGaussianX.FindUniform("Weight"), 0, gaussianWeightTable);
            Vector2 offset = new Vector2(16.0f / texScene.Width, 0.0f);

            shaderGaussianX.SetUniformValue(shaderGaussianX.FindUniform("Offset"), ref offset);

            // render
            FrameBuffer oldBuffer = graphics.GetFrameBuffer();

            if (this.Target != null)
            {
                graphics.SetFrameBuffer(this.Target);
            }

            texRenderer.BindGraphicsContext(graphics);
            texRenderer.Begin(shaderGaussianX);
            texRenderer.Render(texScene);
            texRenderer.End();

            if (this.Target != null)
            {
                graphics.SetFrameBuffer(oldBuffer);
            }
        }
        /// フィルタ処理の実行
        public void Filter(GraphicsContext graphics)
        {
            texRenderer.BindGraphicsContext(graphics);
            FrameBuffer oldBuffer = graphics.GetFrameBuffer();

            bool isSwap = false;
            int  width  = oldBuffer.Width;
            int  height = oldBuffer.Height;

            if (this.Target != null)
            {
                graphics.SetFrameBuffer(this.Target);
                width  = this.Target.Width;
                height = this.Target.Height;
                isSwap = true;
            }
            graphics.SetViewport(0, 0, width, height);

            texRenderer.Begin(shaderDOF);
            graphics.SetTexture(2, texDepth);
            texRenderer.Render(texScene,
                               texBlur,
                               0, 0, 0, 0, width, height);
            texRenderer.End();
            if (isSwap)
            {
                graphics.SetFrameBuffer(oldBuffer);
            }
        }
示例#3
0
        public void Filter(GraphicsContext graphics)
        {
            // Y軸方向へのガウス
            // uniform
            int idReciprocalTexHeight = shaderGaussianY.FindUniform("ReciprocalTexHeight");

            if (idReciprocalTexHeight >= 0)
            {
                shaderGaussianY.SetUniformValue(idReciprocalTexHeight, 1.0f / texScene.Height);
            }
            int idWeight = shaderGaussianY.FindUniform("Weight");

            if (idWeight >= 0)
            {
                shaderGaussianY.SetUniformValue(idWeight, 0, gaussianWeightTable);
            }
            int idOffset = shaderGaussianY.FindUniform("Offset");

            if (idOffset >= 0)
            {
                Vector2 offset = new Vector2(0.0f, 16.0f / texScene.Height);
                shaderGaussianY.SetUniformValue(idOffset, ref offset);
            }

            // render
            FrameBuffer oldBuffer = graphics.GetFrameBuffer();

            if (this.Target != null)
            {
                graphics.SetFrameBuffer(this.Target);
            }

            texRenderer.BindGraphicsContext(graphics);
            texRenderer.Begin(shaderGaussianY);
            texRenderer.Render(texScene);
            texRenderer.End();

            if (this.Target != null)
            {
                graphics.SetFrameBuffer(oldBuffer);
            }
        }