Skip to content

FogOfWarSystem ​

Inherits: Node3D

FogOfWarSystem manages fog of war using a CompositorEffect for rendering.

Description ​

Uses depth buffer reconstruction to apply fog based on world position. Supports configurable edge smoothing, colors, and performance settings.

Entity visibility is determined via spatial queries (RangeQueryUtil) and line-of-sight checks (LineOfSightUtility) for improved performance over viewport texture sampling.

Variables ​

PartyManagerparty_manager
WorldContainerworld_container
floatradius50.0
ColorcolorColor.WHITE

Methods ​

voidinitialize( map_size: Vector2, map_origin: Vector2 = Vector2.ZERO )
voidupdate_fog_colors( shroud_alpha: float, fog_alpha: float )
voidupdate_edge_smoothing( threshold: float, softness: float )
voidupdate_blur_radius( radius: float )
voidapply_config_settings()
voidregister_vision_source( entity: Entity )
voidunregister_vision_source( entity: Entity )
voidset_radius( new_radius: float )
GameplayConfig.FogStateget_fog_state_at_position( world_position: Vector3 )
boolis_position_visible( world_position: Vector3 )
boolis_position_explored( world_position: Vector3 )
Imageget_exploration_image()
voidclear_exploration()
voidreveal_all()
voidcleanup()
voiddebug_save_viewport_textures()

Signals ​

fog_initialized() ​

Emitted when the fog is ready.

entity_fog_state_changed( entity: Entity, old_state: GameplayConfig.FogState, new_state: GameplayConfig.FogState ) ​

Emitted when an entity moves between visible, explored and hidden.

exploration_changed() ​

Emitted when the explored area grows.

Variable descriptions ​

PartyManager party_manager ​

The manager of the party (the vision sources).

WorldContainer world_container ​

The container of the current world.

float radius = 50.0 ​

No description yet.

Color color = Color.WHITE ​

No description yet.

Method descriptions ​

void initialize( map_size: Vector2, map_origin: Vector2 = Vector2.ZERO ) ​

Sets the fog up for a map: its size and the position of its corner.

void update_fog_colors( shroud_alpha: float, fog_alpha: float ) ​

Update fog colors at runtime

void update_edge_smoothing( threshold: float, softness: float ) ​

Update edge smoothing at runtime

void update_blur_radius( radius: float ) ​

Update blur radius at runtime

void apply_config_settings() ​

Apply current config settings (call after changing gameplay_config)

void register_vision_source( entity: Entity ) ​

Makes an entity see (it clears the fog around it).

void unregister_vision_source( entity: Entity ) ​

Stops an entity from seeing.

void set_radius( new_radius: float ) ​

No description yet.

GameplayConfig.FogState get_fog_state_at_position( world_position: Vector3 ) ​

Is this position visible, explored or hidden?

bool is_position_visible( world_position: Vector3 ) ​

Can the party see this position now?

bool is_position_explored( world_position: Vector3 ) ​

Has the party seen this position?

Image get_exploration_image() ​

The picture of the explored area (for the map and for saves).

void clear_exploration() ​

Forgets everything the party explored.

void reveal_all() ​

Marks the whole map as explored.

void cleanup() ​

Removes the fog and frees what it holds.

void debug_save_viewport_textures() ​

Saves the textures of the fog to files, for debugging.