Skip to content

FogOfWarCompositorEffect ​

Inherits: CompositorEffect

CompositorEffect that renders fog of war as a post-process. Uses depth buffer reconstruction to apply fog based on world position.

Variables ​

RenderingDevicerd
RIDshader
RIDpipeline
RIDsampler_linear
RIDshroud_texture_rid
RIDvision_texture_rid
Vector2map_minVector2(-256, -256)
Vector2map_maxVector2(256, 256)
floatshroud_alpha1.0
floatfog_alpha0.2
floatedge_threshold0.3
floatedge_softness1.0
floatblur_radius1.0

Methods ​

voidset_fog_textures( shroud_rid: RID, vision_rid: RID )
voidset_map_bounds( min_bounds: Vector2, max_bounds: Vector2 )
voidset_fog_colors( p_shroud_alpha: float, p_fog_alpha: float )
voidset_edge_params( p_threshold: float, p_softness: float )
voidset_blur_radius( p_blur_radius: float )
voidset_debug( enabled: bool )

Constants ​

  • String SHADER_PATH = "res://addons/chroniclenode/runtime_classes/world/fog/fog_of_war.glsl" - The compute shader that draws the fog.

Variable descriptions ​

RenderingDevice rd ​

The rendering device the effect draws with.

RID shader ​

The compiled shader.

RID pipeline ​

The compute pipeline of the shader.

RID sampler_linear ​

The sampler of the fog textures.

RID shroud_texture_rid ​

The texture of the shroud (the places that were never seen).

RID vision_texture_rid ​

The texture of the places seen now.

Vector2 map_min = Vector2(-256, -256) ​

The corner of the map with the lowest coordinates.

Vector2 map_max = Vector2(256, 256) ​

The corner of the map with the highest coordinates.

float shroud_alpha = 1.0 ​

How dark the shroud is (1 = fully dark).

float fog_alpha = 0.2 ​

How dark the places that were seen but are not in view are.

float edge_threshold = 0.3 ​

Where the soft edge of the fog starts.

float edge_softness = 1.0 ​

How soft the edge of the fog is.

float blur_radius = 1.0 ​

Multiplier for blur sampling distance (1.0 = normal, 1.5 = wider blur)

Method descriptions ​

void set_fog_textures( shroud_rid: RID, vision_rid: RID ) ​

Gives the effect the shroud and the vision textures.

void set_map_bounds( min_bounds: Vector2, max_bounds: Vector2 ) ​

Sets the corners of the map the fog covers.

void set_fog_colors( p_shroud_alpha: float, p_fog_alpha: float ) ​

Sets how dark the shroud and the fog are.

void set_edge_params( p_threshold: float, p_softness: float ) ​

Sets the threshold and the softness of the edge of the fog.

void set_blur_radius( p_blur_radius: float ) ​

Sets how wide the blur of the edge is (0.5 to 3).

void set_debug( enabled: bool ) ​

Turns the debug output on or off.