API ReferenceGE Extensionsflowgraphnodesgfx
DOF - Depth of Field (Flowgraph Node)
- **Node Name:** `DOF`
Overview
- Node Name:
DOF - File:
extensions/flowgraph/nodes/gfx/dof.lua - Tags: gfx, dof
Animates Depth of Field blur in or out over a configurable fade time. Saves and restores the original DOF settings on reset.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
flow | flow | - | Inflow for this node |
blurIn | flow | - | Start fading DOF blur in |
blurOut | flow | - | Start fading DOF blur out |
fadeTime | number | 1 | Duration of fade in seconds |
Output Pins
| Pin | Type | Description |
|---|---|---|
blurDone | flow | Fires when the fade animation completes |
Internals
- State:
modetracks current animation ("in","out", or""),timertracks elapsed time. - On mode change, saves current TorqueScript DOF variables:
$DOFPostFx::BlurMin,$DOFPostFx::BlurMax,$DOFPostFx::FocusRangeMax,$DOFPostFx::BlurCurveFar
- Sets
$DOFPostFx::FocusRangeMaxto3andtargetBlurto430. - Each frame, interpolates
BlurMin,BlurMax, andBlurCurveFarbased on timer progress. - On reset or execution stop, restores all saved DOF values.
- Calls
dofPostEffect.updateDOFSettings()via scenetree after every change.
How It Works
- When
blurInorblurOutflow activates, saves current DOF state and begins animation. - Each frame, updates DOF parameters based on elapsed time vs fade duration.
- For
blurIn: interpolates from 0 to 1. ForblurOut: interpolates from 1 to 0. BlurCurveFaris scaled bytargetBlur(430).- When timer exceeds fadeTime, outputs
blurDone = true. - On reset, restores original DOF settings.
Lua Code Example
-- Manually set DOF blur via TorqueScript variables
TorqueScriptLua.setVar('$DOFPostFx::BlurMin', 0.5)
TorqueScriptLua.setVar('$DOFPostFx::BlurMax', 0.5)
TorqueScriptLua.setVar('$DOFPostFx::FocusRangeMax', 3)
TorqueScriptLua.setVar('$DOFPostFx::BlurCurveFar', 215)
local dofPostEffect = scenetree.findObject("DOFPostEffect")
if dofPostEffect and dofPostEffect.updateDOFSettings then
dofPostEffect.updateDOFSettings()
endKey Dependencies
TorqueScriptLua.setVar()/getVar()- reads/writes DOF TorqueScript globalsDOFPostEffectscene object - the depth of field post-processing effect
Additional Methods
C:_executionStopped()
Called when graph execution stops. Used for cleanup.
C:init(mgr, ...)
Initializes the node, setting up pins and default properties.
Parameters:
mgr...
C:updateSettings()
Node method.
C:work()
Main work function called each frame/tick when the node is active.
See Also
- Blur (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide