setFog

From Bohemia Interactive Community
Revision as of 11:22, 19 September 2023 by POLPOX (talk | contribs)
Jump to navigation Jump to search
Hover & click on the images for description

Description

Description:
Smoothly change the fog over given time (in seconds). See also fogParams.
Arma 3
This command is MP synchronised, if executed on server, the changes will propagate globally. If executed on client effect is temporary as it will soon change to the server setting.
Multiplayer:
Before Arma 3, server and clients could have each a different (local) fog value.
Groups:
Environment

Syntax

Syntax:
time setFog fog
Parameters:
time: Number - transition time to the new value
fog: Number - fog density in range 0..1
Return Value:
Nothing

Alternative Syntax

Syntax:
time setFog [fogValue, fogDecay, fogBase]
Parameters:
time: Number - transition time to the new value
fogValue: Number - normal fog value that represents fog density at fogBase level, in range 0..1
fogDecay: Number - decay of fog density with altitude, in range -1..1; a negative value means a "ceiling" fog
fogBase: Number - base altitude (ASL) of fog (in meters), in range -5000..5000
Return Value:
Nothing

Examples

Example 1:
15 setFog 0.5;
Example 2:
Force no fog:
0 setFog 0; // forceWeatherChange; // change is immediate 999999 setFog 0;
Example 3:
// Arma 3 examples: 0 setFog [1, 0.01, 0]; 0 setFog [1, -1, 70]; // mountain fog, starts from 70m ASL and thickens the higher you climb 0 setFog [1, 1, 60]; // valley fog, starts from 60m ASL and thickens the lower you descend 0 setFog [1, 1, 0]; // fooooog on the waaaater

Additional Information

See also:
Arma 3: Improved Fog fog fogParams fogForecast nextWeatherChange forceWeatherChange setRain

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Ceeeb - c
Posted on Apr 20, 2007 - 04:25 (UTC)
Only one script command induced weather change (either setOvercast or setFog) can be happening at a time. Starting a new weather change will immediately halt the current weather change. setRain changes are independent and can occur simultaneously to a weather change.
Zapat - c
Posted on Dec 15, 2015 - 14:32 (UTC)
setTimeMultiplier DOES affect transition time.
Killzone_Kid - c
Posted on Jan 10, 2019 - 10:23 (UTC)
A little information about how Alt Syntax works. The fogValue is normal fog value that could be set independently with original setFog command. fogBase is the ASL altitude at which the fog will start. 0 is the sea level. fogDecay is how defined the fog start is. The more defined, the denser is the fog. 1 (or -1) are the max values. If it is positive the fog will be generated below fogBase line, if negative, above it. If fogDecay is small, the fog will transition more smoothly from no fog to full fog, and because of that it will cross fogBase line by quite a lot, depending on how small is fogDecay value. Current values of fogDecay and fogBase can be retrieved with fogParams.
samatra - c
Posted on Jul 05, 2022 - 05:29 (UTC)
Few notes about network behavior of the fog:
  • Fog is the only weather parameter that is almost properly network-synchronized by the engine. You can rely on it for both connected players and JIP players without jumping through hoops like other weather commands.
  • time is not synchronized over the network exactly, fog values changes will be linear over time where you run the command, while network-synced time will be non-linear, but in the end fog is still will be somewhat close between clients and servers, so its not much of a game breaker.
  • Say fog all 0 on both server and client, instantly setting fog on the server with 0 setFog 1 or even 0 setFog [1,1,1] will not set it instantly on clients, but rather interpolate it there over few seconds (~10-15), non-linearly (slower the closer it gets to server values)
  • Setting fogValue to values above 1 is allowed where you run the command, but network sync will still clamp it to 1, so if you do 0 setFog 100, clients will still interpolate fogValue to 1, including JIP, so make sure you don't set it above 1 if you expect consistent values between server and client for some calculations.
samatra - c
Posted on Aug 01, 2022 - 09:43 (UTC)
Be aware that this command is affected by setWindStr and windStr! Max fogValue = 1 - windStr, so if you do 0 setWindStr 1, setting any fog with time>0 will actually set fog to 0! Doing instant fog changes with time=0 strangely still works though.
POLPOX - c
Posted on Sep 19, 2023 - 10:22 (UTC)
Calculate approx fog density on the certain height:
fogParams params ["_fogPower","_fogDecay","_fogHeight"] ; _height = AGLToASL (positionCameraToWorld [0,0,0])#2 ; _height = _height - _fogHeight ; (_fogPower*(1/2)^(_height/2.45*_fogDecay) min 1 max 0) ;
Where _height is a current camera's height