Exemplo n.º 1
0
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur = new RenderImage("testGaussianBlur", 1280, 768);
            blur = new RenderImage("testGaussianBlur1", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceManager);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(new Size((int)preblur.Width, (int)preblur.Height));

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                preblur.Clear();       //Clear
                _resourceManager.GetSprite("AAAA").Draw(); //Draw NoSpritelogo
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                _gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0,0, 1280, 768); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
Exemplo n.º 2
0
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur = new RenderImage("testGaussianBlur", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceManager);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(new Vector2f(preblur.Width, preblur.Height));

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                //preblur.Clear();       //Clear
                sprite = _resourceManager.GetSprite("flashlight_mask");
                sprite.Position = new Vector2f();
                sprite.Draw();
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                //_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0,0, preblur.Width, preblur.Height,Color.White, BlitterSizeMode.Crop ); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
Exemplo n.º 3
0
        public void CreateStarScroller_ShouldCreateStars()
        {
            base.InitializeCluwneLib(1280, 720, false, 60);
            Stars = new StarScroller();
            renderimage = new RenderImage("StarScroller", 1920, 1080);

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(SFML.Graphics.Color.Black);
                CluwneLib.Screen.DispatchEvents();

                renderimage.BeginDrawing(); // set temp as CRT (Current Render Target)
                renderimage.Clear();       //Clear
                base.GetResourceManager.GetSprite("AAAA").Draw(); //Draw NoSpritelogo

                renderimage.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                renderimage.Blit(0, 0, 1280, 768); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
        public override void ProcessImage(RenderImage image)
        {
            var OstafLikesTheCock = new RenderImage("CockLoverOstaf", image.Height, image.Height);

            OstafLikesTheCock.BeginDrawing();
                image.Blit(0, 0, image.Height, image.Height, SFML.Graphics.Color.White, BlitterSizeMode.Crop);
            OstafLikesTheCock.EndDrawing();

            image.BeginDrawing();
                _shader.setAsCurrentShader();
                _shader.SetParameter("SceneTexture", OstafLikesTheCock);
                _shader.setDuration((Math.Abs(_duration)));
                OstafLikesTheCock.Blit(0, 0, image.Height, image.Height, SFML.Graphics.Color.White, BlitterSizeMode.Crop);
            image.EndDrawing();

            _shader.ResetCurrentShader();
            OstafLikesTheCock.Dispose();
        }
Exemplo n.º 5
0
        public void PerformGaussianBlur(RenderImage sourceImage)
        {
            // Blur the source horizontally
            SetUpIntermediateTarget(sourceImage.Width, sourceImage.Height);
            _intermediateTarget.BeginDrawing();
            _intermediateTarget.Clear(Color.Black);
                GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].SetParameter("colorMapTexture", GLSLShader.CurrentTexture);
                GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].SetParameter("weights_offsets", WeightsOffsetsX);
                GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].setAsCurrentShader(); //.Techniques["GaussianBlurHorizontal"];
                sourceImage.Blit(0, 0, sourceImage.Width, sourceImage.Height);
            _intermediateTarget.EndDrawing();
            GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].ResetCurrentShader();

            //// blur the blur vertically
            sourceImage.BeginDrawing();
                GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].SetParameter("colorMapTexture", GLSLShader.CurrentTexture);
                GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].SetParameter("weights_offsets", WeightsOffsetsY);
                GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].setAsCurrentShader() ; //.Techniques["GaussianBlurVertical"];
                _intermediateTarget.Blit(0, 0, _intermediateTarget.Width, _intermediateTarget.Height);
            sourceImage.EndDrawing();
            GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].ResetCurrentShader();
        }
Exemplo n.º 6
0
        public void PerformGaussianBlur(RenderImage sourceImage)
        {
            // Blur the source horizontally
            _intermediateTarget = new RenderImage("intermediateTarget",sourceImage.Width, sourceImage.Height);
            _intermediateTarget.Key = targetName;

            _intermediateTarget.BeginDrawing(); //stores screen, makes current

            GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].SetParameter("colorMapTexture", GLSLShader.CurrentTexture);
            GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].SetParameter("weights_offsets", WeightsOffsetsX);

            GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].setAsCurrentShader(); //.Techniques["GaussianBlurHorizontal"];

            sourceImage.Blit(0, 0, sourceImage.Width, sourceImage.Height);
            _intermediateTarget.EndDrawing();
            GaussianBlurTechnique["GaussianBlur" + Radius + "Horizontal"].ResetCurrentShader();

            //// blur the blur vertically
            sourceImage.BeginDrawing();

            GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].SetParameter("colorMapTexture", GLSLShader.CurrentTexture);
            GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].SetParameter("weights_offsets", WeightsOffsetsY);

            GaussianBlurTechnique["GaussianBlur" + Radius + "Vertical"].setAsCurrentShader() ; //.Techniques["GaussianBlurVertical"];

            _intermediateTarget.Blit(0, 0, _intermediateTarget.Width, _intermediateTarget.Height);
            sourceImage.EndDrawing();

            CluwneLib.CurrentShader = null;

            _intermediateTarget.Dispose();
        }
Exemplo n.º 7
0
        private void ExecuteTechnique(RenderImage source, RenderImage destinationTarget, string techniqueName, RenderImage shadowMap)
        {
            Vector2f renderTargetSize;
            renderTargetSize = new Vector2f(baseSize, baseSize);

            destinationTarget.BeginDrawing();
            destinationTarget.Clear(Color.White);

            resolveShadowsEffectTechnique[techniqueName].setAsCurrentShader() ;

            resolveShadowsEffectTechnique[techniqueName].SetParameter("renderTargetSize", renderTargetSize);
            if (source != null)
                resolveShadowsEffectTechnique[techniqueName].SetParameter("inputSampler", source);
            if (shadowMap != null)
                resolveShadowsEffectTechnique[techniqueName].SetParameter("shadowMapSampler", shadowMap);

            // Blit and use normal sampler instead of doing that weird InputTexture bullshit
            // Use destination width/height otherwise you can see some cropping result erroneously.
            source.Blit(0, 0, destinationTarget.Width, destinationTarget.Height, BlitterSizeMode.Scale);

            destinationTarget.EndDrawing();
        }
Exemplo n.º 8
0
 private void DebugTex(RenderImage src, RenderImage dst)
 {
     CluwneLib.ResetShader();
     dst.BeginDrawing();
     src.Blit(0, 0, dst.Width, dst.Height, BlitterSizeMode.Scale);
     dst.EndDrawing();
 }
Exemplo n.º 9
0
        private void ApplyHorizontalReduction(RenderImage source, RenderImage destination)
        {
            int step = reductionChainCount - 1;
            RenderImage src = source;
            RenderImage HorizontalReduction= reductionRT[step];
            reductionEffectTechnique["HorizontalReduction"].setAsCurrentShader();
            // Disabled GLTexture stuff for now just to get the pipeline working.
            // The only side effect is that floating point precision will be low,
            // making light borders and shit have jaggy edges.
            //GLTexture GLHorizontalReduction = new GLTexture("desto", (int)source.Width, (int)source.Height, ImageBufferFormats.BufferGR1616F);
            //Debug.DebugRendertarget(source);
            while (step >= 0)
            {
                HorizontalReduction = reductionRT[step]; // next step

                HorizontalReduction.BeginDrawing();
                HorizontalReduction.Clear(Color.White);

                //reductionEffectTechnique["HorizontalReduction"].SetParameter("secondTexture", src);
                reductionEffectTechnique["HorizontalReduction"].SetParameter("TextureDimensions",1.0f/src.Width);

                // Sourcetexture not needed... just blit!
                src.Blit(0, 0, HorizontalReduction.Width, HorizontalReduction.Height, BlitterSizeMode.Scale); // draw SRC to HR
                                                                                                              //fix
                                                                                                              //GLHorizontalReduction.Blit(src.Texture, CluwneLib.CurrentShader);

                HorizontalReduction.EndDrawing();
                src = HorizontalReduction; // hr becomes new src
                //Debug.DebugRendertarget(HorizontalReduction);
                step--;
            }

            CluwneLib.ResetShader();
            //copy to destination
            destination.BeginDrawing();
            destination.Clear(Color.White);

            HorizontalReduction.Blit(0, 0, destination.Height, destination.Width);
                //GLHorizontalReduction.Blit(HorizontalReduction.Texture, CluwneLib.CurrentShader);
            destination.EndDrawing();
            //Debug.DebugRendertarget(destination);
            CluwneLib.ResetRenderTarget();
        }