Пример #1
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();

            }
        }
Пример #2
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();

            }
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
0
        public void PerformGaussianBlur(RenderImage sourceImage)
        {
            // Perform horizontal Gaussian blur.
            _intermediateTarget = new RenderImage(sourceImage.Width, sourceImage.Height);
            _intermediateTarget.setName = targetName;
            _intermediateTarget.Clear(Color.Black);

            CluwneLib.CurrentRenderTarget = _intermediateTarget;
            CluwneLib.CurrentShader = _shader; //TODO .Techniques["GaussianBlurHorizontal"];

           // _shader.setParameter("weights_offsets").SetValue(WeightsOffsetsX);
           // _shader.setParameters["colorMapTexture"].SetValue(sourceImage.Image);

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

            // Perform vertical Gaussian blur.
          CluwneLib.CurrentRenderTarget = sourceImage;
          CluwneLib.CurrentShader = _shader; //.Techniques["GaussianBlurVertical"];

            //   _shader.Parameters["colorMapTexture"].SetValue(_intermediateTarget.Image);
            //_shader.Parameters["weights_offsets"].SetValue(WeightsOffsetsY);

            //_intermediateTargetSprite.Draw();
            _intermediateTarget.Blit(0, 0, sourceImage.Width, sourceImage.Height);

            CluwneLib.CurrentShader = null;
            CluwneLib.CurrentRenderTarget = null;
            _intermediateTarget.Dispose();
        }