Gorilla.Renderer Unit Reference

Overview

The Gorilla.Renderer unit provides the rendering pipeline infrastructure for Gorilla3D. It includes base renderer classes and specialized renderers for different rendering techniques including forward rendering with WBOIT (Weighted Blended Order Independent Transparency) and legacy rendering.

Classes

TRenderer

Base renderer class for all renderer types.

Inheritance: TObject → TRenderer

Public Properties

Property Type Access Description
Id String Read Unique identifier for the renderer instance.
Flags TRendererFlags Read Renderer flags controlling pipeline behavior.
Multisample TMSAASamples Read/Write Get or set MSAA (multi-sample anti-aliasing) level.
SharedContext TContext3D Read Shared 3D rendering context.
CompositeTexture TGorillaTextureBitmap Read Final composite output texture.
CompositeTextureMSAA TGorillaTexture Read Multi-sampled version of composite texture.
RenderTargets TRenderTargets Read/Write Active render targets for this renderer.
Owner TComponent Read/Write Owner component (TGorillaViewport or TGorillaRenderPassController).
Size TPoint Read/Write Renderer output size in pixels.
Scale Single Read/Write Rendering scale factor.
Color TAlphaColorF Read/Write Clear color for the renderer.
AttachedRenderer TRenderer Read/Write Reference to attached sub-renderer.
DefaultFrameBuf TFrameBufferObject Read Default framebuffer object for rendering.
TranslucentBuf TFrameBufferObject Read Framebuffer for translucent rendering (WBOIT).
OnCreateCompositeTexture TOnRendererCreateCompositeTexture Read/Write Event for custom composite texture creation.

Public Methods

constructor Create(AId: String; AOwner: TComponent;
  const AMultisamples: TMSAASamples = TMSAASamples.None;
  AFlags: TRendererFlags = [];
  ACompositeTextureEvent: TOnRendererCreateCompositeTexture = nil); virtual;
destructor Destroy(); override;

Create and destroy the renderer.

procedure Resize(const ASize: TPoint; const AScale: Single);

Resize the renderer output.

procedure Apply(); virtual;
procedure Reset(); virtual;

Apply or reset renderer settings.

procedure BeginMainRenderPass(ACamera: TMatrix3D; AAngleOfView: Single); virtual;
procedure EndMainRenderPass(); virtual;

Begin and end the main rendering pass.

function BeginOpaqueRendering(): Boolean; virtual;
procedure EndOpaqueRendering(); virtual;

Begin and end opaque object rendering phase.

function BeginTranslucentRendering(): Boolean; virtual;
procedure EndTranslucentRendering(); virtual;

Begin and end translucent object rendering phase.


TLegacyRenderer

Simple renderer with single framebuffer for basic rendering needs.

Inheritance: TRenderer → TLegacyRenderer

This renderer provides a straightforward single-pass rendering pipeline without advanced features. Use when:

  • Maximum FMX material compatibility is needed
  • Custom native OpenGL rendering is primary
  • Advanced Gorilla3D features are not required

TCompositeRenderer

Base class for forward and deferred renderers with WBOIT 3-phase rendering.

Inheritance: TRenderer → TCompositeRenderer

Public Properties

Render Target Textures
Property Type Description
AlbedoTexture TTexture Albedo color output (opaque objects only).
TranslucentAlbedoTexture TTexture Albedo color output (translucent objects only).
AlphaTexture TTexture Alpha channel output.
PositionTexture TTexture Fragment position output (world space vec3).
NormalsTexture TTexture Fragment normal vectors output (world space vec3).
EmissiveTexture TTexture Emissive color output.
Embedded Render Pass Controllers
Property Type Description
EmissiveBlurCtrl TObject Emissive blur render pass controller.
GlobalIllumCtrl TObject Global illumination render pass controller.
ScreenSpaceShadowsCtrl TObject Screen space shadows render pass controller.
SSAOCtrl TObject Screen space ambient occlusion controller.
DeferredCompositeCtrl TObject Deferred composite render pass controller.
Rendering Settings
Property Type Range Description
TranslucentDistance Single - Distance value for transparency weighting. Affects how translucent objects blend based on depth.
Saturation TPoint3D - Saturation values: X=Opaque, Y=Translucent, Z=Composite. Zero disables saturation for that stage.
EmissiveBlur Integer 0-∞ Emissive blur intensity. 0=disabled. Higher values = stronger glow but lower performance.
OutputLayer TRendererOutputLayer - Which render layer to output for debugging (all layers, albedo only, normals only, etc.).
Global Illumination Settings
Property Type Range Description
GlobalIllumDetail Integer 0-7 Global illumination detail level. 0=off, 1-7=increasing quality.
GlobalIllumSoftness Single 0.0-5.0 Softness of GI shadows and reflections.
ShadowStrength Single 0.0-10.0 Darkness of GI shadows.
ReflectionStrength Single 0.0-10.0 Intensity of GI reflections.
FXAA Integer 0-8 Fast approximate anti-aliasing steps. 0=off, 8=maximum quality.
Screen Space Effects (if enabled in build)
Property Type Description
SSS_Enabled Boolean Enable screen space shadows.
SSS_NumSamples Integer Number of samples for SSS (affects performance heavily).
SSS_SampleStep Single Step size for SSS sampling.
SSS_ShadowStrength Single Darkness of screen space shadows.
SSAO_Enabled Boolean Enable screen space ambient occlusion.
SSAO_Radius Single Sampling radius for SSAO.
SSAO_Bias Single Bias to prevent self-shadowing artifacts.
SSAO_NoiseScale TPointF Noise texture scale for SSAO.

Public Methods

constructor Create(AId: String; AOwner: TComponent;
  const AMultisamples: TMSAASamples = TMSAASamples.None;
  AFlags: TRendererFlags = [];
  ACompositeTextureEvent: TOnRendererCreateCompositeTexture = nil); override;
destructor Destroy(); override;

Create and destroy the composite renderer.

function BeginOpaqueRendering(): Boolean; override;

Begin opaque rendering phase.

procedure FragDepthRendering(const ARenderContext: PRenderContext); virtual;

Render fragment depth pre-pass for improved transparency.

function GetFragDepthRendering(): TTexture; virtual;

Get the fragment depth texture for use in shaders.

procedure Composite(const ARenderContext: PRenderContext); virtual;

Perform final compositing of all render layers.


TForwardRenderer

Forward renderer with WBOIT for order-independent transparency.

Inheritance: TRenderer → TCompositeRenderer → TForwardRenderer

The recommended renderer providing:

  • Weighted Blended Order Independent Transparency
  • Multiple render targets
  • Advanced effects support
  • Full Gorilla3D material support

TDeferredRenderer

Deferred renderer with multiple color channels and final composite pass.

Inheritance: TRenderer → TCompositeRenderer → TDeferredRenderer

Additional Public Properties

Property Type Description
ComponentsTexture TTexture Material component properties output.
AmbientTexture TTexture Ambient lighting output.
SpecularTexture TTexture Specular lighting output.

Public Methods

procedure Composite(const ARenderContext: PRenderContext); override;

Deferred compositing combining all G-buffer layers.

Types

TRendererType

Enumeration of renderer types.

Values:

  • ForwardRenderer - Forward renderer with WBOIT (recommended)
  • LegacyRenderer - Simple single-pass renderer

TRendererFlag

Flags controlling renderer behavior.

Values:

  • IgnoreRenderTargets - Don't create render targets
  • IgnoreCompositeCtrl - Don't create composite render pass
  • IgnoreEmissiveBlur - Don't create emissive blur pass
  • IgnoreGlobalIllum - Don't create global illumination pass
  • IgnoreSSS - Don't create screen space shadows pass
  • IgnoreSSAO - Don't create SSAO pass
  • IgnoreSSR - Don't create screen space reflections pass

TRendererFlags

Set of TRendererFlag values.

TRendererOutputLayer

Enumeration of output layers for debugging.

Values:

  • OutputAll - All layers combined (normal rendering)
  • OutputAlbedo - Albedo/color only
  • OutputTranslucentAlbedo - Translucent albedo only
  • OutputAlpha - Alpha channel only
  • OutputDepth - Depth buffer
  • OutputPosition - World space positions
  • OutputNormal - World space normals
  • OutputEmissive - Emissive channel only
  • OutputComps - Material components
  • OutputAmbient - Ambient lighting only
  • OutputSpecular - Specular lighting only
  • OutputSSS - Screen space shadows
  • OutputSSAO - Ambient occlusion

TOnRendererCreateCompositeTexture

Event type for custom composite texture creation.

TOnRendererCreateCompositeTexture = procedure(
  ASender: TObject;
  const ASize: TPoint;
  const AScale: Single;
  out ATexture: TGorillaTextureBitmap
) of object;

Global Illumination Detail Levels

Level Voxel Size Target GPU Min Texture3D Size
0 - - Off
1 32 Elder GPUs 256
2 64 Elder GPUs 512
3 128 Normal GPUs 1024
4 192 Normal GPUs 2048
5 256 Better GPUs 2048
6 384 High-end GPUs 4096
7 512 High-end GPUs 4096

Usage Notes

  1. Renderer Selection: Use TForwardRenderer for most cases. Only use TLegacyRenderer when you need maximum FMX compatibility or are doing extensive native OpenGL rendering.

  2. MSAA: Set multisample level in constructor or via the Multisample property. Not all platforms support all MSAA levels.

  3. Render Targets: The composite renderer creates multiple render targets for different rendering stages. Access these via properties like AlbedoTexture, NormalsTexture, etc.

  4. Performance: Higher EmissiveBlur and FXAA values significantly impact performance. Start with low values and increase as needed.

  5. Debugging: Use OutputLayer to visualize individual render passes during development.

  6. Global Illumination: Only available in GAME_PACKAGE edition. Requires significant GPU resources at higher detail levels.

See Also