Gorilla.Controller.Passes.SSAO
Overview
This unit implements Screen-Space Ambient Occlusion (SSAO) for the Gorilla3D deferred rendering pipeline. It computes per-pixel ambient occlusion by sampling a hemisphere kernel in screen space, using position and normal G-buffer data.
The unit defines two classes:
TGorillaRenderPassSSAO-- The standalone SSAO pass.TGorillaRenderPassEmbeddedSSAO-- A variant used internally by the deferred composite system.
Architecture
SSAO uses a 128-sample hemisphere kernel and a 4x4 noise texture for randomized sample rotation. The kernel and noise data are transferred to the GPU via a Uniform Buffer Object (UBO) named SSAOShaderData, providing efficient bulk data transfer.
The pass is a post-pass using RectToFBO rendering. It is marked as an internal render pass (IsInternalRenderPass = True), meaning it is typically managed by the deferred composite rather than used standalone.
Core Classes
TGorillaRenderPassSSAO
Inherits from: TGorillaRenderPassController
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
Position |
TGorillaRenderPassController |
nil | Input render pass providing the position G-buffer texture. |
Normals |
TGorillaRenderPassController |
nil | Input render pass providing the normals G-buffer texture. |
Radius |
Single |
1.0 | Radius of the sampling hemisphere in world units. Larger values detect occlusion over a wider area. |
Bias |
Single |
0.5 | Depth comparison bias to prevent self-occlusion artifacts. |
NoiseScale |
TPointF |
(1, 1) | Scale factor for the noise texture tiling. |
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
TGorillaRenderPassEmbeddedSSAO
Inherits from: TGorillaRenderPassSSAO
An embedded variant designed for use within the deferred composite pipeline. Functionally identical to TGorillaRenderPassSSAO but integrated into the deferred rendering workflow.
Runtime Setup
uses
Gorilla.Controller.Passes.SSAO;
var
LSSAOPass: TGorillaRenderPassSSAO;
begin
LSSAOPass := TGorillaRenderPassSSAO.Create(nil);
LSSAOPass.Viewport := GorillaViewport1;
LSSAOPass.Position := MyPositionPass;
LSSAOPass.Normals := MyNormalsPass;
LSSAOPass.Radius := 1.5;
LSSAOPass.Bias := 0.25;
LSSAOPass.NoiseScale := PointF(1, 1);
LSSAOPass.Enabled := True;
end;
Technical Details
- Kernel size: 128 samples distributed in a hemisphere
- Noise texture: 4x4 pixels, used to rotate the sampling kernel per-pixel
- UBO name:
SSAOShaderData - Texture format: Standard RGBA for output
- The occlusion value is computed by comparing sample depths against the position buffer, accumulating occlusion for samples that are closer than expected within the defined
Radius.