public override void Do(PostProcessingRenderObject ro)
        {
            ro.ViewportSize = (Size)((Vector2)ro.ViewportSize * ro.BlurTextureScaling);
            if (ro.BlurBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.BlurBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.BlurBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.BlurMaterial.Radius          = ro.BlurRadius;
            ro.BlurMaterial.BlurShaderId    = ro.BlurShader;
            ro.BlurMaterial.Step            = ro.ProcessedUV1 * ro.BlurTextureScaling / ro.CurrentBufferSize;
            ro.BlurMaterial.Dir             = Vector2.Down;
            ro.BlurMaterial.AlphaCorrection = ro.BlurAlphaCorrection;
            ro.RenderToTexture(ro.FirstTemporaryBuffer.Texture, ro.ProcessedTexture, ro.BlurMaterial, Color4.White, ro.TextureClearingColor);
            ro.CurrentBufferSize = (Vector2)ro.BlurBuffer.Size;
            ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
            ro.BlurMaterial.Dir  = Vector2.Right;
            ro.RenderToTexture(ro.BlurBuffer.Texture, ro.FirstTemporaryBuffer.Texture, ro.BlurMaterial, Color4.White, ro.TextureClearingColor);

            ro.BlurBuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.BlurBuffer.Texture;
        }
 public bool EqualRenderParameters(PostProcessingRenderObject ro) =>
 !IsDirty &&
 lumaTreshold == ro.FXAALumaTreshold &&
 mulReduce == ro.FXAAMulReduce &&
 minReduce == ro.FXAAMinReduce &&
 maxSpan == ro.FXAAMaxSpan &&
 textureClearingColor == ro.TextureClearingColor;
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     strength             = ro.SharpenStrength;
     limit                = ro.SharpenLimit;
     textureClearingColor = ro.TextureClearingColor;
 }
        public override void Do(PostProcessingRenderObject ro)
        {
            ro.ProcessedViewport = Viewport.Default;
            ro.TextureSize       = ro.Size;
            ro.CurrentBufferSize = (Vector2)ro.SourceTextureBuffer.Size;
            ro.ViewportSize      = (Size)(ro.TextureSize * ro.SourceTextureScaling);
            ro.ProcessedTexture  = ro.SourceTextureBuffer.Texture;
            ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
            if (!ro.SourceTextureBuffer.IsDirty)
            {
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.SourceTextureBuffer.Texture.SetAsRenderTarget();
            try {
                Renderer.Viewport = new Viewport(0, 0, ro.ViewportSize.Width, ro.ViewportSize.Height);
                Renderer.Clear(ro.TextureClearingColor);
                Renderer.Transform2 = ro.LocalToWorldTransform.CalcInversed();
                ro.Objects.Render();
            } finally {
                ro.SourceTextureBuffer.Texture.RestoreRenderTarget();
                ro.FinalizeOffscreenRendering();
            }
            ro.SourceTextureBuffer.IsDirty = false;
            ro.MarkBuffersAsDirty          = true;
        }
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.BloomBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.BloomBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.BloomBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            var bufferSize        = (Vector2)ro.BloomBuffer.Size;
            var bloomViewportSize = (Size)(bufferSize * ro.BloomTextureScaling);

            ro.BloomMaterial.BrightThreshold         = ro.BloomBrightThreshold;
            ro.BloomMaterial.InversedGammaCorrection = new Vector3(
                Mathf.Abs(ro.BloomGammaCorrection.X) > Mathf.ZeroTolerance ? 1f / ro.BloomGammaCorrection.X : 0f,
                Mathf.Abs(ro.BloomGammaCorrection.Y) > Mathf.ZeroTolerance ? 1f / ro.BloomGammaCorrection.Y : 0f,
                Mathf.Abs(ro.BloomGammaCorrection.Z) > Mathf.ZeroTolerance ? 1f / ro.BloomGammaCorrection.Z : 0f
                );
            ro.RenderToTexture(ro.FirstTemporaryBuffer.Texture, ro.ProcessedTexture, ro.BloomMaterial, Color4.White, ro.TextureClearingColor, bloomViewportSize);
            var bloomUV1 = (Vector2)bloomViewportSize / bufferSize;

            ro.BlurMaterial.Radius          = ro.BloomStrength;
            ro.BlurMaterial.BlurShaderId    = ro.BloomShaderId;
            ro.BlurMaterial.Step            = ro.ProcessedUV1 * ro.BloomTextureScaling / ro.CurrentBufferSize;
            ro.BlurMaterial.Dir             = Vector2.Down;
            ro.BlurMaterial.AlphaCorrection = 1f;
            ro.RenderToTexture(ro.SecondTemporaryBuffer.Texture, ro.FirstTemporaryBuffer.Texture, ro.BlurMaterial, Color4.White, ro.TextureClearingColor, bloomViewportSize, bloomUV1);
            ro.BlurMaterial.Dir = Vector2.Right;

            if (ro.DebugViewMode != PostProcessingPresenter.DebugViewMode.Bloom)
            {
                ro.RenderToTexture(ro.FirstTemporaryBuffer.Texture, ro.SecondTemporaryBuffer.Texture, ro.BlurMaterial, Color4.White, ro.TextureClearingColor, bloomViewportSize, bloomUV1);

                if (ro.ProcessedViewport.Width != ro.ViewportSize.Width || ro.ProcessedViewport.Height != ro.ViewportSize.Height)
                {
                    Renderer.Viewport = ro.ProcessedViewport = new Viewport(0, 0, ro.ViewportSize.Width, ro.ViewportSize.Height);
                }
                ro.BloomBuffer.Texture.SetAsRenderTarget();
                try {
                    var material = ro.AlphaDiffuseMaterial;
                    Renderer.Clear(Color4.Zero);
                    Renderer.DrawSprite(ro.ProcessedTexture, null, material, Color4.White, Vector2.Zero, ro.Size, Vector2.Zero, ro.ProcessedUV1, Vector2.Zero, Vector2.Zero);
                    Renderer.DrawSprite(ro.FirstTemporaryBuffer.Texture, null, ro.AddDiffuseMaterial, ro.BloomColor, Vector2.Zero, ro.Size, Vector2.Zero, bloomUV1, Vector2.Zero, Vector2.Zero);
                } finally {
                    ro.BloomBuffer.Texture.RestoreRenderTarget();
                }
                ro.BloomBuffer.SetRenderParameters(ro);
            }
            else
            {
                ro.RenderToTexture(ro.BloomBuffer.Texture, ro.SecondTemporaryBuffer.Texture, ro.BlurMaterial, ro.BloomColor, ro.TextureClearingColor, customUV1: bloomUV1);
                ro.BloomBuffer.MarkAsDirty();
            }
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.BloomBuffer.Texture;
            ro.CurrentBufferSize  = (Vector2)ro.BloomBuffer.Size;
            ro.ProcessedUV1       = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
        }
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     radius               = ro.BlurRadius;
     textureScaling       = ro.BlurTextureScaling;
     alphaCorrection      = ro.BlurAlphaCorrection;
     textureClearingColor = ro.TextureClearingColor;
 }
 public bool EqualRenderParameters(PostProcessingRenderObject ro) =>
 !IsDirty &&
 strength == ro.BloomStrength &&
 brightThreshold == ro.BloomBrightThreshold &&
 gammaCorrection == ro.BloomGammaCorrection &&
 textureScaling == ro.BloomTextureScaling &&
 color == ro.BloomColor &&
 textureClearingColor == ro.TextureClearingColor;
示例#8
0
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     brightThreshold      = ro.NoiseBrightThreshold;
     darkThreshold        = ro.NoiseDarkThreshold;
     softLight            = ro.NoiseSoftLight;
     textureClearingColor = ro.TextureClearingColor;
 }
 public bool EqualRenderParameters(PostProcessingRenderObject ro) =>
 !IsDirty &&
 barrelPincushion == ro.DistortionBarrelPincushion &&
 chromaticAberration == ro.DistortionChromaticAberration &&
 red == ro.DistortionRed &&
 green == ro.DistortionGreen &&
 blue == ro.DistortionBlue &&
 textureClearingColor == ro.TextureClearingColor;
示例#10
0
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     hsl                  = WrappedHSL(ro.HSL);
     brightness           = ro.Brightness;
     contrast             = ro.Contrast;
     textureClearingColor = ro.TextureClearingColor;
 }
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     lumaTreshold         = ro.FXAALumaTreshold;
     mulReduce            = ro.FXAAMulReduce;
     minReduce            = ro.FXAAMinReduce;
     maxSpan              = ro.FXAAMaxSpan;
     textureClearingColor = ro.TextureClearingColor;
 }
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty              = false;
     strength             = ro.BloomStrength;
     brightThreshold      = ro.BloomBrightThreshold;
     gammaCorrection      = ro.BloomGammaCorrection;
     textureScaling       = ro.BloomTextureScaling;
     color                = ro.BloomColor;
     textureClearingColor = ro.TextureClearingColor;
 }
 public void SetRenderParameters(PostProcessingRenderObject ro)
 {
     IsDirty             = false;
     barrelPincushion    = ro.DistortionBarrelPincushion;
     chromaticAberration = ro.DistortionChromaticAberration;
     red   = ro.DistortionRed;
     green = ro.DistortionGreen;
     blue  = ro.DistortionBlue;
     textureClearingColor = ro.TextureClearingColor;
 }
        public override void Do(PostProcessingRenderObject ro)
        {
            ro.FinalizeOffscreenRendering();

            ro.VignetteMaterial.Radius   = ro.VignetteRadius;
            ro.VignetteMaterial.Softness = ro.VignetteSoftness;
            ro.VignetteMaterial.UV1      = Vector2.One / (ro.ProcessedUV1 * ro.VignetteScale);
            ro.VignetteMaterial.UVOffset = ro.VignettePivot / ro.VignetteScale;
            ro.VignetteMaterial.Color    = ro.VignetteColor;
            ro.RenderTexture(ro.TransparentTexture, ro.VignetteMaterial);
        }
示例#15
0
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.NoiseBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.NoiseBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.NoiseBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            if (ro.ProcessedViewport.Width != ro.ViewportSize.Width || ro.ProcessedViewport.Height != ro.ViewportSize.Height)
            {
                Renderer.Viewport = ro.ProcessedViewport = new Viewport(0, 0, ro.ViewportSize.Width, ro.ViewportSize.Height);
            }
            ro.NoiseBuffer.Texture.SetAsRenderTarget();
            try {
                Renderer.Clear(ro.TextureClearingColor);
                var noiseUV0 = ro.NoiseOffset;
                var noiseUV1 = ro.Size / ((Vector2)ro.NoiseTexture.ImageSize * ro.NoiseScale) + ro.NoiseOffset;
                ro.NoiseMaterial.BrightThreshold = ro.NoiseBrightThreshold;
                ro.NoiseMaterial.DarkThreshold   = ro.NoiseDarkThreshold;
                ro.NoiseMaterial.SoftLight       = ro.NoiseSoftLight;
                Renderer.DrawSprite(
                    ro.ProcessedTexture,
                    ro.NoiseTexture,
                    ro.NoiseMaterial,
                    Color4.White,
                    Vector2.Zero,
                    ro.TextureSize,
                    Vector2.Zero,
                    ro.ProcessedUV1,
                    noiseUV0,
                    noiseUV1
                    );
            } finally {
                ro.NoiseBuffer.Texture.RestoreRenderTarget();
            }

            ro.NoiseBuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.NoiseBuffer.Texture;
            ro.CurrentBufferSize  = (Vector2)ro.NoiseBuffer.Size;
            ro.ProcessedUV1       = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
        }
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.SharpenBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.SharpenBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.SharpenBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.SharpenMaterial.Strength = ro.SharpenStrength;
            ro.SharpenMaterial.Limit    = ro.SharpenLimit;
            ro.SharpenMaterial.Step     = ro.SharpenStep * (ro.ProcessedUV1 / ro.CurrentBufferSize);
            ro.RenderToTexture(ro.SharpenBuffer.Texture, ro.ProcessedTexture, ro.SharpenMaterial, Color4.White, ro.TextureClearingColor);
            ro.CurrentBufferSize = (Vector2)ro.SharpenBuffer.Size;
            ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;

            ro.SharpenBuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.SharpenBuffer.Texture;
        }
示例#17
0
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.ColorCorrectionBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.ColorCorrectionBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.ColorCorrectionBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.ColorCorrectionMaterial.HSL        = WrappedHSL(ro.HSL);
            ro.ColorCorrectionMaterial.Brightness = ro.Brightness;
            ro.ColorCorrectionMaterial.Contrast   = ro.Contrast;
            ro.RenderToTexture(ro.ColorCorrectionBuffer.Texture, ro.ProcessedTexture, ro.ColorCorrectionMaterial, Color4.White, ro.TextureClearingColor);

            ro.ColorCorrectionBuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.ColorCorrectionBuffer.Texture;
            ro.CurrentBufferSize  = (Vector2)ro.ColorCorrectionBuffer.Size;
            ro.ProcessedUV1       = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
        }
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.FXAABuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.FXAABuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.FXAABuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.FXAAMaterial.TexelStep    = ro.ProcessedUV1 / ro.CurrentBufferSize;
            ro.FXAAMaterial.LumaTreshold = ro.FXAALumaTreshold;
            ro.FXAAMaterial.MulReduce    = ro.FXAAMulReduce;
            ro.FXAAMaterial.MinReduce    = ro.FXAAMinReduce;
            ro.FXAAMaterial.MaxSpan      = ro.FXAAMaxSpan;
            ro.RenderToTexture(ro.FXAABuffer.Texture, ro.ProcessedTexture, ro.FXAAMaterial, Color4.White, ro.TextureClearingColor);
            ro.CurrentBufferSize = (Vector2)ro.FXAABuffer.Size;
            ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;

            ro.FXAABuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.FXAABuffer.Texture;
        }
        public override void Do(PostProcessingRenderObject ro)
        {
            if (ro.DistortionBuffer.EqualRenderParameters(ro))
            {
                ro.ProcessedTexture  = ro.DistortionBuffer.Texture;
                ro.CurrentBufferSize = (Vector2)ro.DistortionBuffer.Size;
                ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;
                return;
            }

            ro.PrepareOffscreenRendering(ro.Size);
            ro.DistortionMaterial.BarrelPincushion    = ro.DistortionBarrelPincushion;
            ro.DistortionMaterial.ChromaticAberration = ro.DistortionChromaticAberration;
            ro.DistortionMaterial.Red   = ro.DistortionRed;
            ro.DistortionMaterial.Green = ro.DistortionGreen;
            ro.DistortionMaterial.Blue  = ro.DistortionBlue;
            ro.RenderToTexture(ro.DistortionBuffer.Texture, ro.ProcessedTexture, ro.DistortionMaterial, Color4.White, ro.TextureClearingColor);
            ro.CurrentBufferSize = (Vector2)ro.DistortionBuffer.Size;
            ro.ProcessedUV1      = (Vector2)ro.ViewportSize / ro.CurrentBufferSize;

            ro.DistortionBuffer.SetRenderParameters(ro);
            ro.MarkBuffersAsDirty = true;
            ro.ProcessedTexture   = ro.DistortionBuffer.Texture;
        }
 public override PostProcessingAction.Buffer GetTextureBuffer(PostProcessingRenderObject ro) => ro.BloomBuffer;
 public override bool EnabledCheck(PostProcessingRenderObject ro) => ro.BloomEnabled;
 public override bool EnabledCheck(PostProcessingRenderObject ro) => true;
 public bool EqualRenderParameters(PostProcessingRenderObject ro) =>
 !IsDirty &&
 strength == ro.SharpenStrength &&
 limit == ro.SharpenLimit &&
 textureClearingColor == ro.TextureClearingColor;
 public override void Do(PostProcessingRenderObject ro)
 {
     ro.RenderTexture(ro.SourceTextureBuffer.Texture, customUV1: ro.Size / (Vector2)ro.SourceTextureBuffer.Size);
     ro.Color = ro.OverallImpactColor;
 }
示例#25
0
 public abstract bool EnabledCheck(PostProcessingRenderObject ro);
 public bool EqualRenderParameters(PostProcessingRenderObject ro) =>
 !IsDirty &&
 radius == ro.BlurRadius &&
 textureScaling == ro.BlurTextureScaling &&
 alphaCorrection == ro.BlurAlphaCorrection &&
 textureClearingColor == ro.TextureClearingColor;
示例#27
0
 public abstract void Do(PostProcessingRenderObject ro);
 public override bool EnabledCheck(PostProcessingRenderObject ro) => ro.OverallImpactEnabled && ro.IsNotDebugViewMode;
示例#29
0
 public virtual Buffer GetTextureBuffer(PostProcessingRenderObject ro) => null;
 public override bool EnabledCheck(PostProcessingRenderObject ro) => ro.DistortionEnabled;