Gorilla.Controller.Passes.CustomBlur

Overview

This unit provides a configurable blur post-process. It supports several blur algorithms and is typically chained in a horizontal/vertical ping-pong arrangement to blur the output of another render pass — for bloom, depth-of-field, soft shadows, or general screen-space smoothing.

Architecture

The blur pass uses RectToFBO rendering: it draws a fullscreen quad with a blur material that samples an input texture. Separable blur is achieved by running the pass twice — once Horizontal, once Vertical — feeding the first result into the second via SetInputPass().

Core Classes

TGorillaRenderPassBlur

Inherits from: TGorillaRenderPassController

Default pass id: 'Blur'

Published Properties

Property Type Default Description
BlurType TPassBlurType — Blur algorithm: RadialBlur, FastBlur, GaussianBlur.
BlurMode TPassBlurMode — Pass direction: Horizontal or Vertical.
BlurAmount Single — Strength / radius of the blur.
PingPongMode Boolean False Enables ping-pong texture swapping for iterative blurring.
Exposure Single — Exposure adjustment applied during tonemapping.

Key Public Methods

function GetOutputTexture() : TTexture; override;
function GetFinalOutputTexture() : TTexture;

Enumerations

TPassBlurType = (RadialBlur, FastBlur, GaussianBlur);
TPassBlurMode = (Horizontal, Vertical);

Note: FastBlur can produce artefacts on some NVIDIA GPUs. Prefer GaussianBlur (kernel size 35) when quality matters.

TBlurMaterial / TBlurMaterialSource

Internal material classes (TGorillaRenderPassMaterial / TGorillaRenderPassMaterialSource) that hold the actual blur shaders and expose BlurType, BlurMode, BlurAmount, InputTexture and Exposure. You normally configure the pass, not these classes directly.

Runtime Setup

uses
  Gorilla.Controller.Passes.CustomBlur;

var
  LBlurH, LBlurV: TGorillaRenderPassBlur;
begin
  // Horizontal blur reads from a source pass
  LBlurH := TGorillaRenderPassBlur.Create(nil);
  LBlurH.Viewport   := GorillaViewport1;
  LBlurH.Method     := TRenderPassMethod.RectToFBO;
  LBlurH.BlurType   := GaussianBlur;
  LBlurH.BlurMode   := Horizontal;
  LBlurH.BlurAmount := 4.0;
  LBlurH.SetInputPass(SourcePass);
  LBlurH.Enabled    := True;

  // Vertical blur reads the horizontal result
  LBlurV := TGorillaRenderPassBlur.Create(nil);
  LBlurV.Viewport   := GorillaViewport1;
  LBlurV.Method     := TRenderPassMethod.RectToFBO;
  LBlurV.BlurType   := GaussianBlur;
  LBlurV.BlurMode   := Vertical;
  LBlurV.BlurAmount := 4.0;
  LBlurV.SetInputPass(LBlurH);
  LBlurV.Enabled    := True;
end;

Technical Details

  • Render method: RectToFBO (fullscreen quad)
  • Algorithms: RadialBlur, FastBlur (separable, horizontal/vertical), GaussianBlur (separable, kernel size 35)
  • Use GetFinalOutputTexture() to obtain the result after all blur iterations have run.
  • For separable Gaussian/fast blur always pair a Horizontal and a Vertical pass; a single direction alone looks streaked.

See Also