Gorilla.Controller.Passes.CustomDepth
Overview
This unit renders scene depth into a single-channel floating-point texture. The resulting depth map is used for shadow mapping, depth-based post effects, soft particles, and any technique that needs per-pixel scene depth.
Architecture
The custom depth pass is a pre-pass using RenderListToFBO with ListRendering (transparency sorting is skipped because it is irrelevant for depth). It renders all objects with a dedicated depth material that writes the selected Z-value into an R16F red-channel texture.
Core Classes
TGorillaRenderPassCustomDepth
Inherits from: TGorillaRenderPassController
Default pass id: 'CustomDepth'
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
DepthMethod |
TDepthMethod |
dmDefault |
Selects which Z-value is stored: dmDefault (window-space gl_FragCoord.z), dmMVPPosZ (clip-space Z), dmModelViewPosZ (eye-space Z). |
Public Properties
| Property | Type | Default | Description |
|---|---|---|---|
MapSize |
TPoint |
viewport size | Resolution of the depth map texture. |
BiasMatrix |
TMatrix3D |
— | Read-only bias matrix for sampling the depth texture in [0..1] space. |
DefaultDepth |
Single |
1 | Depth clear value. |
DefaultColor |
TAlphaColor |
Black | Color clear value. |
Key Public Methods
function GetViewMatrix(const AContext : TContext3D) : TMatrix3D; override;
function GetProjectionMatrix(const AContext : TContext3D) : TMatrix3D; override;
procedure SetupMatrices(const AContext : TContext3D);
function GetOutputTexture() : TTexture; override;
function GetTextureMatrix(AContext : TContext3D;
const AUseBias : Boolean = true) : TMatrix3D; override;
TDepthMethod Enumeration
TDepthMethod = (dmDefault, dmMVPPosZ, dmModelViewPosZ);
Runtime Setup
uses
Gorilla.Controller.Passes.CustomDepth;
var
LDepth: TGorillaRenderPassCustomDepth;
begin
LDepth := TGorillaRenderPassCustomDepth.Create(nil);
LDepth.Viewport := GorillaViewport1;
LDepth.DepthMethod := dmDefault;
// Custom resolution (e.g. a 2048² shadow/depth map)
LDepth.OverwriteViewportSize := True;
LDepth.ViewportWidth := 2048;
LDepth.ViewportHeight := 2048;
LDepth.Enabled := True;
end;
Technical Details
- Pass type: Pre-pass (
TRenderPassType.Pre) - Render method:
RenderListToFBO - Render procedure:
ListRendering(no transparency separation — faster) - Output texture:
R16F, data typedtHalfFloat,Linearfiltering,WrapS/WrapT=ClampToBorderwith a white border color(1, 1, 1, 1)so out-of-range samples read as "far". - The pass ignores render targets, composite control, emissive blur, global illumination, SSS, SSAO and shadows for a lean depth-only render.