UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes

Environment Settings

Notice
The IG Template is available for SIM SDK Edition only.

One of the key factors making visualization of the terrain database, with all entities moving around, immersive, and giving a perception of being physically present in the simulation is environment. It includes sky with celestial bodies and atmospheric effects that dramatically change the look of your virtual world depending on the weather and the time of day. The following models are used:

  • An ephemeris model determines the position of the sun and moon, which both cast light into the scene, depending on given coordinates and date/time.
  • A weather model, either in the IG or supplied by an external weather simulation, provides the cloud coverage, and a global wind concept with direction and strength, affecting vegetation animation and the environment.

See Also#

  • The IG plugin API section for more details on managing IG via code (C++).
  • ISkyMap Class for more details on managing sky and celestial bodies via code (C++).
  • IMeteo Class for more details on managing global weather settings via code (C++).
  • IRegion Class for more details on managing weather regions via code (C++).

Celestial Bodies#

Using a full-year ephemeris model IG automatically updates positions of the Sun, Moon, and stars based on the date, time, and geographic location.

By default IG is configured to work in the Greenwich time zone. But you can change time zone via code by adding the following line to the AppSystemLogic::init_ig() method:

Source code (C++)
ig_manager->getSkyMap()->setTimezone(8);

Configuring the Star Field#

Star field intensity is very low by default. You may need to adjust brightness level of your displays or increase maximum brightness of the star field for your area.

To make the stars look brighter do the following:

  • Temporarily disable the sun node in the Editor
  • Open Environment Settings (Windows -> Settings -> Runtime/World/Render/Environment)
  • Make sure the Environment Texture is set to star_c.hdr
  • Click Environment Color and increase values of RGB color components until you reach the desired brightness of the star field (e.g., to 100,100,100)
    Notice
    Alpha channel is used by the system to control Star Intensity (e.g., via CIGI).
  • Enable the sun node back again and save your world.

Stars are positioned on the sky automatically, depending on the date/time and geographic location.

Configuring Sun and Moon#

IG has a built-in celestial body control (celestial_control packet). In order to use it, you should have:

  • Two nodes, one for the Sun, and one for the Moon
  • The Celestial property assigned to the sun node
  • Parameters of the Celestial property containing links to the corresponding nodes.

Positions of the Sun and the Moon are adjusted automatically depending on the date/time and geographic location.

SkyMap Change Callbacks#

Sometimes it may be necessary to perform certain actions when the state of the sky changes (e.g. enable lighting at nignt time). Callbacks can be used for this purpose. Just implement your specific actions in a callback function and set it as follows:

SkyMap change callback implementation:

Source code (C++)
/// callback function to be called when sky state changes
void SomeClass::my_callback()
{
	// pointer to your sun node (don't forget to initialize it)
	NodePtr sun;
	
	// calculating zenith angle to determine if it is night time or not
	float zenith = getAngle(vec3::UP, sun->getDirection(AXIS_Z));
	bool night = zenith > sun_zenit_threshold;
	
	// switching lights
	for (auto & it : lights)
	{
		it.data.setEnable(night);
	}
	
	// switching the emission state for emissive materials
	for (auto & it : emissive_materials)
	{
		it->setState("emission",night);
	}			
}

// ...
// somwhere in code
void SomeClass::init()
{
	// adding "my_callback" to be called on changing sky state
	ig_manager->getSkyMap()->addCallbackRefresh(this, Unigine::MakeCallback(this, &SomeClass::my_callback ) );
}

Atmospheric and Weather Effects#

IG supports the following weather effects:

  • Multiple atmospheric layers and haze
  • Sun angle-dependent haze color and density
  • Procedurally generated volumetric clouds
  • Lightning, rain, snow

Weather simulation includes three components:

  • Global - global atmospheric conditions (atmosphere_control packet): visibility range, wind speed and direction.
  • Weather layers - representing atmospheric layers, which have no distinct horizontal boundaries. Atmospheric effects are observed anywhere within the vertical range of a layer.
  • Weather regions -representing regional weather in certain areas. They have the same set of parameters (visibility, coverage, wind) as weather layers but atmospheric effects for them are limited to their boundaries.
Notice
  • Weather layers and weather regions always take precedence over global atmospheric conditions (i.e. global atmospheric changes will not affect the weather inside a layer or region).
  • When several layers and regions overlap their parameters are combined.

Weather layer wind changes global Animation Scale and Animation Wind for Vegetation depending on player's position inside weather layers.

By default there are 5 global weather layers:

  • Ground Fog - used for ground fog effect simulation.
    Notice
    This effect is currently simulated using Environment Haze, that depends on Visibility Distance of a Weather Layer.
  • Cloud Layer 1 - used for simulation of the first cloud layer
  • Cloud Layer 2 - used for simulation of the second cloud layer
  • Rain - used for rain simulation
  • Snow - used for snow simulation
You can add more layers and regions if necessary.

The following properties can be used to adjust various weather parameters (location: data/ig/weather/properties/):

  • CloudsParams.prop - clouds parameters
  • PrecipitationParams.prop - rain and snow parameters
  • LightingProperties.prop - lighting parameters (flashing type and time period)

Clouds#

Volumetric clouds are particle masses that simulate light absorption, creating a realistic reduction in visibility when flown through. Clouds can cast shadows on the terrain.

IG currently supports Stratocumulus and Stratus clouds (types 9 and 10 according to CIGI specification), but you can extend this set by inheriting new materials from the clouds_base, tweaking their parameters and assigning these materials the the corresponding fields of the CloudsParams property (data/ig/weather/properties/CloudsParams.prop).

Cloud coverage is set automatically using the Coverage value from a weather_control packet received, or you can change it manually via the following code:

Source code (C++)
// setting cloud coverage for weather region with a given id
ig_manager->getMeteo()->getRegion(region_id)->setCloudDensity(density_value);

Cloud coverage does not change immediately, it has some transition period providing smoothness. You can adjust transition time by changing value in the cloud_transition_time tag in configuration file (data/ig_config.xml).

Weather Change Callbacks#

Sometimes it may be necessary to perform certain actions when weather conditions change (e.g. to set orientation for a windsock or a vane). This can be done using callbacks the same way as for changing sky state. Just implement your specific actions in a callback function and set it as follows:

Weather change callback implementation:

Source code (C++)
/// callback function to be called when weather conditions change
void SomeClass::my_weather_callback()
{
	// setting orientation of the vane downwind
	vec3 wind_direction = ig_manager->getMeteo()->getMeanWindSpeed(vane_node->getWorldPosition());
	vane_node->setWorldDirection(wind_direction, vec3::UP);
}

// ...
// somwhere in code
void SomeClass::init()
{
	// adding "my_weather_callback" to be called on changing weather conditions
	ig_manager->getMeteo()->addCallbackMeteoChanged(this, Unigine::MakeCallback(this, &SomeClass::my_weather_callback );
}
Last update: 2019-02-14