Gorilla.Light Unit Reference
Overview
The Gorilla.Light unit provides an extended light source component for Gorilla3D. TGorillaLight enhances FireMonkey's TLight with additional properties used by Gorilla3D shaders, including ambient and specular colors, attenuation control, intensity, and light scattering parameters for global illumination.
Classes
TGorillaLight
Extended light source component with additional properties for Gorilla3D shaders.
Inheritance: TLight → TGorillaLight
Platforms: All Gorilla3D supported platforms
Public Properties
| Property | Type | Access | Description |
|---|---|---|---|
| Def | TLightDef | Read | Access to the light definition object containing light parameters. |
| LightDescriptionEx | TGorillaShaderLight | Read | Extended light description for shader use, including all Gorilla3D-specific parameters. |
Published Properties
Color Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Color | TAlphaColor | - | Diffuse color of the light (inherited from TLight). |
| Ambient | TAlphaColorF | (0,0,0,1) | Ambient component of light color. Affects overall scene brightness. |
| Specular | TAlphaColorF | (1,1,1,1) | Specular component of light color. Affects shiny highlights on surfaces. |
Intensity
| Property | Type | Range | Default | Description |
|---|---|---|---|---|
| Intensity | Single | 0.0-10.0 | 1.0 | Light intensity controlling the range and strength of light application. Clamped to 0-10. |
Attenuation
Attenuation controls how light intensity decreases with distance using the formula:
Attenuation = 1 / (Constant + Linear * Distance + Quadratic * Distance²)
| Property | Type | Default | Description |
|---|---|---|---|
| ConstantAttenuation | Single | 1.0 | Constant factor in attenuation calculation. Always applied regardless of distance. |
| LinearAttenuation | Single | 0.0 | Linear factor in attenuation. Causes proportional falloff with distance. |
| QuadraticAttenuation | Single | 0.0 | Quadratic factor in attenuation. Causes rapid falloff at distance. |
Light Scattering (Global Illumination)
Light scattering parameters for volumetric lighting effects in global illumination rendering. Each light source can have individual scattering settings.
| Property | Type | Range | Default | Description |
|---|---|---|---|---|
| ScatteringIntensity | Single | 0.0-10.0 | 0.1 | How intensely light scattering is mixed into the final image. |
| ScatteringExposure | Single | 0.0-1.0 | 0.0034 | Ray exposure parameter controlling visibility of light rays. |
| ScatteringDecay | Single | 0.0-2.0 | 1.0 | How quickly light rays decay along their path. |
| ScatteringDensity | Single | 0.0-10.0 | 0.84 | Density of the scattering medium. Higher = more visible rays. |
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure AfterConstruction(); override;
Standard lifecycle methods.
procedure LoadFromDefinition(const ADef: TLightDef); virtual;
Load light settings from a light definition object, including:
- Light type
- All color properties (diffuse, ambient, specular)
- Intensity
- Attenuation parameters
- Light scattering settings
- Position and rotation
Light Types (Inherited)
From FireMonkey's TLight, accessible via the LightType property:
- Point Light - Omnidirectional light emanating from a point
- Directional Light - Parallel rays in one direction (like sunlight)
- Spot Light - Cone-shaped light with direction and angle
Attenuation Presets
Common attenuation configurations for different light ranges:
No Attenuation (Directional Light)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.0;
Light.QuadraticAttenuation := 0.0;
Short Range (7 units)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.7;
Light.QuadraticAttenuation := 1.8;
Medium Range (13 units)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.35;
Light.QuadraticAttenuation := 0.44;
Long Range (20 units)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.22;
Light.QuadraticAttenuation := 0.20;
Very Long Range (50 units)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.07;
Light.QuadraticAttenuation := 0.017;
Extremely Long Range (100 units)
Light.ConstantAttenuation := 1.0;
Light.LinearAttenuation := 0.045;
Light.QuadraticAttenuation := 0.0075;
Usage Notes
-
Ambient vs Diffuse:
- Diffuse (
Color) - Direct light on surfaces - Ambient (
Ambient) - Indirect/environmental light - Specular (
Specular) - Shiny highlights
- Diffuse (
-
Intensity: Use intensity to control light strength without changing color. More intuitive than adjusting color brightness.
-
Attenuation:
- Only affects Point and Spot lights
- Directional lights typically use default (no attenuation)
- Adjust based on your scene's scale
-
Light Scattering:
- Only visible when Global Illumination is enabled
- Requires GAME_PACKAGE edition
- Creates volumetric "god rays" effect
- Performance impact depends on scattering intensity and density
-
Performance: Each additional light increases rendering cost. Use the minimum number of lights necessary and disable lights when not visible.
-
Gorilla3D Materials Required: Advanced light properties only affect Gorilla3D default materials, not standard FMX materials.