Files
deepgrain-foundry/docs/systems/fog.md
T

1.6 KiB

Fog of war

Unexplored ground is black with a soft edge. The sky and the first few grains of the surface start seen. Exploration never changes the simulation.

Data and revealing

src/sim/fog.js keeps a Uint8Array at half the grain resolution (FOG = 2). Values run from 0 (unseen) to 255 (seen) and only increase. alloc allocates it with the other world arrays. fogInit reveals above surfY and fades eight grains below it.

Every four ticks, 256 rays from the bot's centre reveal up to 48 grains. The last eight grains fade out. Solid and powder stop sight after a four-grain fade into their face; air, gas and liquid pass sight. Bars and machine voids do not block it.

Saving

The fog buffer is saved and exported with the other typed arrays, without a save version change. Older saves rebuild the surface, reveal a radius of 12 grains around built blocks, machine footprints and molds, then look from the bot. Loading and generating also look immediately from the bot.

Drawing and setting

Both looks and the thermal lens sample fog bilinearly. Seen grains use the usual drawing; unseen grains use the out-of-world colour and smooth-look buffers, hiding their shapes. Partial values dim foreground, background and trees. Bloom sources need at least 128; bars, flyers, rain and particles need at least 64. Hover info and the cursor label say only “Unexplored” below 64.

Game settings → Fog of war is on by default. Turning it off shows the whole world while exploration continues to be recorded and saved. Browser scenes and performance tools turn it off in their shared setup; dedicated fog checks enable it explicitly.