API ReferenceGE ExtensionsClient
PostFx Light Ray Effect
Volumetric light ray (god ray) post-processing effect. Two-pass pipeline: occlusion detection followed by radial light scattering.
Volumetric light ray (god ray) post-processing effect. Two-pass pipeline: occlusion detection followed by radial light scattering.
Overview
Declarative setup script (no M module). Registers:
LightRayOccludeShader- Occlusion pass shaderLightRayShader- Radial scatter/ray shaderLightRayStateBlock- 3-texture linear clamp samplerLightRayPostFX- Root PostEffect (disabled by default, priority 10)LightRayPostFXCallbacks- Handles resolution scaling and shader constants
Scene Objects
| Object | Type | Default Enabled | Description |
|---|---|---|---|
LightRayPostFX | PostEffect | false | Light ray root (occlusion pass) |
final (child) | PostEffect | - | Ray scatter pass, composites to $backBuffer |
Global Variables
| Variable | Default | Description |
|---|---|---|
$LightRayPostFX::brightScalar | 0.75 | Brightness multiplier for occlusion |
$LightRayPostFX::numSamples | 40 | Ray marching sample count |
$LightRayPostFX::density | 0.94 | Ray density factor |
$LightRayPostFX::weight | 10.0 | Ray intensity weight |
$LightRayPostFX::decay | 1.0 | Falloff per sample |
$LightRayPostFX::exposure | 0.0005 | Final exposure multiplier |
$LightRayPostFX::resolutionScale | 0.20 | Render target scale (20% of screen) |
Global Callbacks
| Global | Callback | Description |
|---|---|---|
LightRayPostFXCallbacks | preProcess() | Sets target scale from $LightRayPostFX::resolutionScale |
LightRayPostFXCallbacks | setShaderConsts() | Pushes all light ray parameters to shader uniforms |
Pipeline
$backBuffer + #prepass[RT0] + #prepass[Depth]
→ LightRayOccludeShader (at resolutionScale)
→ LightRayShader ("final") + $backBuffer
→ $backBufferUsage Example
-- Enable light rays
local pfx = scenetree.findObject("LightRayPostFX")
if pfx then pfx:enable() end
-- Adjust ray quality
TorqueScriptLua.setVar("$LightRayPostFX::numSamples", 60)
TorqueScriptLua.setVar("$LightRayPostFX::resolutionScale", 0.5)Notes
- Output format is
GFXFormatR16G16B16A16F(HDR intermediate) - Renders at
PFXBeforeBin/AfterPostFX - The
finalchild is found viafindObjectByInternalName("final") - Low resolution scale (20%) is a performance optimization for the scatter pass
See Also
- PostFx Glow - Bloom/glow effect
- PostFx SSAO - Ambient occlusion
Client Lighting
Discovers and initializes lighting system backends (Advanced Lighting, Basic Lighting) with fallback logic.
Advanced Lighting - Light Visualization
Debug visualization post effects for the Advanced Lighting deferred rendering pipeline: depth, normals, light color, light specular, and annotation buffers.