← Home SEEBIE90 DOCS
Download PDF
The GTG Thermal Framework mod is published under the Arma Public License (APL)Example code is free to useSuggestions: Discord to the author

GTG Thermal Framework

Night vision and the infrared gate

An infrared light should be visible to everybody with night vision – and to nobody without. And a night-vision effect that is not given back burns the next picture out.

In plain wordsNight vision uses the game's own materials. An infrared light is only visible to a viewer who looks through night vision, decided on that viewer's machine. And whatever you write to a camera, you must give back.

The game’s own night vision

Since game version 1.9 the night vision of the vanilla sights is a pair of materials. The component uses them by default, so a device with the framework looks like a vanilla night-vision sight:

EffectSlotDefault material
HDR (the green phosphor look)16Common/Postprocess/NightVision/NV_HDR_GreenPhosphor.emat
Film grain19Common/Postprocess/NightVision/NV_FilmGrain.emat
Thermal12 (m_iThermalSlot)the 40 thermal materials

Leave m_sNightVisionMaterial and m_sNightGrainMaterial empty for those. A material of your own goes into the same attributes. The slot numbers are not free choices: slot 16 holds the world’s HDR effect, which is why leaving night vision must put the game’s own back, see below.

Infrared is a per-viewer fact

Whether this client can see infrared light right now is purely local. A real IR laser is visible to anyone with night vision of their own, whatever the operator of the device selected. So nothing is replicated: each machine keeps one flag, set while the player looks through a night-vision optic. It is a static field of GTG_SOFLAM_NVState.

Example code – free to useGTG_SOFLAM_NVState.c (excerpt)
class GTG_SOFLAM_NVState
{
	protected static bool s_bTemporaryNV;

	// set by devices: true = this client looks through a night-vision optic and can see IR light
	static void SetTemporaryNVState(bool state)
	{
		s_bTemporaryNV = state;
	}

	static bool IsTemporaryNVState() { return s_bTemporaryNV; }
	static bool CanLocalPlayerSeeIR() { ... }
}

The vision component sets the flag itself while night vision is on. Two things are yours:

Your own optic with its own night vision

Example code – free to useMyOptic_NightComponent.c
protected void MyOptic_SetNight(bool on)
{
	// FIRST, before any early return: the flag is pure state and has nothing to do with drawing
	GTG_SOFLAM_NVState.SetTemporaryNVState(on);

	if (!MyOptic_HasRenderer())
		return;

	// ... then write or clear your effect
}
A static flagThe flag is static: it lasts for the whole client and the rest of the session. It used to be set at the end of the night-vision method, behind the check “is there a renderer”. Whenever the method left early, the flag kept its old value, and that player saw every infrared light without goggles, day and night. Set it first.

Your own infrared light

Ask the gate before you switch an IR light on. The light of the SOFLAM does it in one place; this is the pattern:

Example code – free to useMyOptic_IrLight.c
protected void MyOptic_UpdateIrLight(bool wanted)
{
	bool visible = wanted && GTG_SOFLAM_NVState.CanLocalPlayerSeeIR();
	m_Light.SetEnabled(visible);		// m_Light: your own light entity
}

If the viewer wears the goggles of another mod, that counts as well: CanLocalPlayerSeeIR() asks RHS_IsNVOff on the player controller by name at runtime. If that mod is loaded, the call returns the real answer; if not, it fails and only the framework’s own state counts. The framework therefore builds without that mod.

Effects on a camera of your own

Night vision is written to a camera by a method the framework adds to the vanilla SCR_ScreenEffectsManager. The camera id says which camera; -1 is the player camera:

Example code – free to useGTG_SOFLAM_ScreenEffects.c (signatures)
modded class SCR_ScreenEffectsManager
{
	// material = the effect, enable = on/off, camId = -1 for the player camera, keepCleared = do not restore the vanilla default on switch-off
	void GTG_SOFLAM_SetHDR(ResourceName material, bool enable, int camId = -1, bool keepCleared = false);
	void GTG_SOFLAM_SetGrain(ResourceName material, bool enable, int camId = -1, bool keepCleared = false);
}
Example code – free to useMyOptic_Feed.c
SCR_ScreenEffectsManager effects = SCR_ScreenEffectsManager.GetScreenEffectsDisplay();
if (effects)
	effects.GTG_SOFLAM_SetHDR(MYOPTIC_NIGHT_MATERIAL, true, MYOPTIC_FEED_CAMERA);		// tint only the feed camera

Both methods do nothing on a dedicated server (no renderer).

Switching off means clearing, not replacing

An empty material clears the slot. An early version put the vanilla HDR material back on slot 16 when night vision ended, without the parameters the game runs it with. The slot stayed occupied and, by day, the whole picture burned out after leaving night vision. In game version 1.9 the problem has a second half: slot 16 carries the world’s HDR effect. Clearing it freezes the exposure at its last value and the picture goes white. So on the player camera the framework restores the game’s default HDR and grain on exit; on a foreign camera, which never had one, it clears the slot. That is what the camId and keepCleared parameters decide.

Camera brightness is an override you must give back

The night-vision gain writes a fixed brightness to the camera, SetCameraHDRBrightness(cameraId, value). That value is not a one-frame setting: it stays until somebody takes it away. Measured on a dedicated server: after the top gain step the camera read exactly that value from then on, the thermal picture was white, and so was the normal view after leaving and entering again. The value -1 hands the brightness back to the game’s automatic exposure.

Example code – free to useMyOptic_NightComponent.c
protected void MyOptic_ReleaseBrightness(BaseWorld world, int cameraId)
{
	// -1 = automatic exposure again; any other value stays on the camera
	world.SetCameraHDRBrightness(cameraId, -1);
}
Whose camera is itNever write -1 to a foreign camera that pins its own exposure (a screen with a fixed brightness): that gave a white-out of 85 to 1078. The component releases only the player camera and leaves camera-of-your-own exposure to you.

The full story of the camera-id trap and of the exposure measurements is on the SOFLAM page Night and thermal vision.

Example code on this page is free to use in your own projects (credit appreciated). The GTG Thermal Framework mod is published under the Arma Public License (APL). Suggestions: Discord. Arma Reforger / Enfusion are trademarks of Bohemia Interactive.
Impressum · Privacy Policy