Client PostFX Manager
Central manager for all post-processing effects (PostFX). Handles initialization, preset loading/saving, backup/restore, and per-effect settings synchronization (SSAO, HDR, DOF, LightRays).
Central manager for all post-processing effects (PostFX). Handles initialization, preset loading/saving, backup/restore, and per-effect settings synchronization (SSAO, HDR, DOF, LightRays).
Module Overview
| Property | Value |
|---|---|
| Source | lua/ge/client/postFx.lua |
| Returns | Module table M |
| Dependencies | client/postFx/* sub-modules |
Public Functions
| Function | Args | Returns | Description |
|---|---|---|---|
M.initPostEffects | - | - | Loads all PostFX sub-modules, loads default preset |
M.reloadPostEffects | - | - | Re-requires all PostFX sub-modules (hot-reload) |
M.applyDefaultPreset | - | - | Loads user or default preset, applies settings |
M.loadPresetFile | filename | boolean | Loads a .postfx JSON preset file into $PostFXManager::Settings::* |
M.savePresetFile | filename | - | Exports current settings to JSON preset file |
M.settingsApplyFromPreset | - | - | Applies preset vars to runtime effect vars |
M.settingsApplyAll | - | - | Copies runtime vars back to preset vars |
M.settingsSetEnabled | enablePostFX | - | Enables/disables all PostFX based on per-effect flags |
M.applySSAOPreset | - | - | Copies $PostFXManager::Settings::SSAO::* → $SSAOPostFx::* |
M.applyHDRPreset | - | - | Copies $PostFXManager::Settings::HDR1::* → $HDRPostFX::* |
M.applyLightRaysPreset | - | - | Copies LightRays preset → runtime |
M.applyDOFPreset | - | - | Copies DOF preset → runtime, calls updateDOFSettings() |
M.backupCurrentSettings | - | - | Saves current PostFX state to M.backupSettings |
M.clearBackup | - | - | Clears backup (allows saving current values) |
PostFX Sub-Modules Loaded
| Module | PostEffect Object |
|---|---|
client/postFx/caustics | CausticsPFX |
client/postFx/chromaticLens | ChromaticLensPostFX |
client/postFx/dof | DOFPostEffect |
client/postFx/edgeAA | EdgeDetectPostEffect, EdgeAAPostEffect |
client/postFx/flash | Flash overlay |
client/postFx/fog | Fog |
client/postFx/fxaa | FXAA |
client/postFx/GammaPostFX | GammaPostFX |
client/postFx/glow | Glow/bloom |
client/postFx/lightRay | LightRayPostFX |
client/postFx/maskedScreenBlur | Masked blur |
client/postFx/MotionBlurFx | MotionBlurFX |
client/postFx/smaa | SMAA |
client/postFx/ssao | SSAOPostFx |
client/postFx/turbulence | Turbulence |
Scene Objects Created
| Object | Type | Purpose |
|---|---|---|
PFX_DefaultStateBlock | GFXStateBlockData | Default PostFX state: z-off, clamp-linear |
PFX_DefaultBlitStateBlock | GFXStateBlockData | Alpha-blended blit state |
PFX_PassthruShader | ShaderData | Simple passthrough shader |
AL_FormatBlit | PostEffect | Format conversion blit (disabled by default) |
Preset File Format
Presets are JSON files (.postfx) with structure:
{
"header": { "version": 1 },
"SSAO": { "Enable": true, "quality": "2", ... },
"HDR1": { "Enable": true, "enableBloom": true, ... },
"DOF": { "Enable": false, ... },
"LightRays": { "Enable": true, ... },
"EnablePostFX": true
}Preset Search Order
settings/postfxSettings.postfx(user settings)lua/ge/client/postFx/presets/defaultPostfxPreset.postfx(fallback)
Named Presets
| Variable | File |
|---|---|
$PostFXManager::highPreset | defaultPostfxPreset.postfx |
$PostFXManager::normalPreset | lowestPostfxPreset.postfx |
$PostFXManager::lowPreset | lowestPostfxPreset.postfx |
$PostFXManager::lowestPreset | lowestPostfxPreset.postfx |
Globals Set
| Global | Type | Description |
|---|---|---|
postEffectCallbacks | table | Default onEnabled callback (returns true) |
Backup System
-- Backup current settings before making temporary changes
postFxModule.backupCurrentSettings()
-- Later: restore by clearing backup and reapplying preset
postFxModule.clearBackup()
postFxModule.settingsApplyFromPreset()Backs up DOF, LightRay, HDR, and SSAO runtime variables.
Notes
- Settings use a two-layer system:
$PostFXManager::Settings::*(preset) ↔$<Effect>::*(runtime). settingsApplyFromPresetcopies preset → runtime;settingsApplyAllcopies runtime → preset.- Includes legacy CS preset migration (
settings/default.postfxpreset.cs→ JSON). - Null graphics device detection skips all PostFX initialization.
Additional Exports
| Key | Signature | Description |
|---|---|---|
M.restore_cs_preset_from_json | () | (No description available) |
See Also
- client/postFx/dof - Depth of Field
- client/postFx/GammaPostFX - Gamma correction
- client/postFx/MotionBlurFx - Motion blur
- client/init - Calls
initPostEffects
Additional Functions
restore_cs_preset_from_json()
(No description available)
Client Parse Args
Parses command-line arguments passed to the BeamNG engine, handling flags for logging, display, vehicles, levels, Lua execution, and tech communication.
Render Manager
Initializes the Advanced Lighting (AL) render format token and MSAA copy PostEffect. Ensures driver MSAA does not interfere with deferred lighting passes.