Change weather and lighting¶
BBI allows you to vary environmental parameters including weather and lighting.
These are accessible through world.env.weather
and world.env.time_of_day
.
Manual weather control¶
Weather attributes can be set directly using the following methods:
world.env.weather.set_cloud_coverage(5)
world.env.weather.set_fog_distance(100)
world.env.weather.set_fog_intensity(3)
world.env.weather.set_fog_max_opacity(0.5)
world.env.weather.set_rain_intensity(5)
world.env.weather.set_rain_screen_droplets(ScreenDropletsPreset.MEDIUM)
world.env.weather.set_sky_atmosphere_contribution_color_scale(Color(1.0, 0.5, 0.5, 1.0))
Cloud coverage¶
float
Cloud coverage controls the amount of cloud cover in the sky. Recommended values range from 0.0 (no clouds) to 10.0 (completely overcast). Values more than 10 work, but are not generally useful.
Fog distance¶
float
Fog distance controls the distance at which fog starts to appear. The value is in meters.
Fog intensity¶
float
Fog intensity controls the density of the fog. Recommended values range from 0.0 (no fog) to 10.0 (dense fog). For foggy scenes, a value of 3.5-6.0 is recommended. Tweaking the fog intensity alongside the fog distance is recommended. Values more than 10 work, but are not generally useful.
Fog max opacity¶
float
Fog max opacity controls the maximum opacity of the fog. Values range from 0.0 (transparent) to 1.0 (opaque).
Rain intensity¶
float
Rain intensity controls the amount of rain. Recommended values range from 0.0 (no rain) to 10.0 (heavy rain). A value of 5.0 is recommended for moderate to heavy rain.
Rain screen droplets¶
Rain screen droplets control the visibility of rain droplets on the screen. This is
useful for simulating raindrops on the camera lens.
Values are either NONE
, LIGHT
, MEDIUM
or HEAVY
.
No droplets on the camera lens |
|
Small droplets on the camera lens |
|
Small running droplets on the camera lens |
|
Large running droplets on the camera lens |
Fog sky atmosphere contribution color scale¶
Color
Fog sky atmosphere contribution color scale controls the color of the fog. The color is
specified using a Color
object.
Color values range from 0.0 to 1.0 for each channel (red, green, blue, alpha).
Manual lighting control¶
Note
Use either manual sun parameter control or time of day to change the weather. Using both may result in unexpected behavior.
Lighting can be set directly using the following methods:
world.env.weather.set_sun_azimuth(180)
world.env.weather.set_sun_elevation(5)
world.env.weather.set_sun_intensity(10)
Weather presets can be used to quickly set a combination of weather parameters.
world.env.time_of_day.set_time(18)
Sun azimuth¶
float
Sun azimuth controls the position of the sun. Values range from 0 (north of the default camera), to 90 (east), 180 (south), 270 (west), up to 360 (same as 0). Negative values work as well.
Sun elevation¶
float
Sun elevation controls the vertical position of the sun. Values range from 0 to 90 degrees, with 0 being at the horizon, and 90 being directly overhead. Negative values do not work. Values above 90 work, but are not generally useful as they become conflated with the sun azimuth control.
Sun intensity¶
float
Sun intensity controls the brightness of the sun. Recommended values range from 0.0 (no sun) to 50.0 (very bright sun). Values above 50 work but may be too bright.
Time¶
int
Time controls the hour of the of day. Values range from 0 to 24, with 0 being midnight and
12 being noon. When using world.env.time_of_day.set_time()
, avoid using the
world.env.weather.set_sun_*()
methods.
Animating weather and lighting¶
Weather and lighting can be animated through scenario keyframes, allowing them to vary across frames.
scenario = world.new_scenario(num_frames=10)
for i in range(scenario.num_frames):
scenario.set_keyframe(world.env.weather, i, sun_azimuth=180 - i * 10, sun_elevation=5 + i * 2)
if i % 2 == 0: # Toggle rain every other frame
scenario.set_keyframe(world.env.weather, i, rain_intensity=5)
else:
scenario.set_keyframe(world.env.weather, i, rain_intensity=0)