Controlling rain droplets on sensor

Bifrost supports rain effects and camera lens droplets to simulate wet weather conditions. These are controlled through world.env.weather and can be used independently or together.

../_images/med_droplets.png

MEDIUM — Small running droplets on the camera lens

../_images/very_large_droplets.png

VERY_LARGE — Very large droplets on the camera lens

Rain intensity

Rain intensity controls the amount of rain particles in the scene.

Example: setting rain intensity
# Set rain intensity (0.0 to 10.0)
world.env.weather.set_rain_intensity(5.0)

Screen droplet presets

Screen droplets simulate water droplets on the camera lens. You can apply a preset to quickly set a desired level of droplet coverage using ScreenDropletsPreset.

Example: applying a screen droplet preset
world.env.weather.set_rain_screen_droplets(ScreenDropletsPreset.HEAVY)

bbi.ScreenDropletsPreset.NONE

No droplets on the camera lens

bbi.ScreenDropletsPreset.LIGHT

Small droplets on the camera lens

bbi.ScreenDropletsPreset.MEDIUM

Small running droplets on the camera lens

bbi.ScreenDropletsPreset.HEAVY

Large running droplets on the camera lens

bbi.ScreenDropletsPreset.VERY_LARGE

Very large droplets on the camera lens

Note

Setting a new screen droplet preset resets any fine-grained overrides you may have applied. If you want to customize individual droplet parameters, apply the preset first and then set the overrides.

Fine-grained droplet control

For more precise control, you can override individual droplet parameters on top of a preset.

Method

Description

set_rain_screen_droplets_blur(blur)

Controls the blur intensity of droplets on the lens. A value of 0 produces streaking raindrops.

Range: 0.0 to 1.0

set_rain_screen_droplets_speed(speed)

Controls how quickly droplets scroll vertically across the screen. Negative values scroll downward, positive values scroll upward.

Range: -1.0 to 1.0

set_rain_screen_droplets_scroll_offset(offset_x, offset_y)

Sets the starting position of the droplet pattern on the screen.

Range: 0.0 to 1.0 for each axis

set_rain_screen_droplets_drips_intensity(intensity)

Controls the intensity of drip streaks running down the lens.

Range: 0.0 and above

set_rain_screen_droplets_scale(scale)

Controls the size of the droplets on the screen.

Range: greater than 0.0 up to 1.0

Example: customizing droplet parameters on top of a preset
# Start with a preset
world.env.weather.set_rain_screen_droplets(ScreenDropletsPreset.MEDIUM)

# Override specific parameters
world.env.weather.set_rain_screen_droplets_blur(0.5)
world.env.weather.set_rain_screen_droplets_speed(-0.3)
world.env.weather.set_rain_screen_droplets_drips_intensity(1.5)

Animating rain and droplets

Rain and droplet parameters can be animated through scenario keyframes, allowing them to vary across frames.

Example: animating rain and droplets over time
world.env.set_preset("rainy_a")

scenario = world.new_scenario(num_frames=10)

for frame_idx in range(scenario.num_frames):
    scenario.set_keyframe(
        world.env.weather,
        frame_idx,
        rain_intensity=rng.uniform(2, 8),
        rain_screen_droplets=rng.choice(list(ScreenDropletsPreset)),
        screen_droplets_blur=rng.uniform(0, 0.5),
        screen_droplets_speed=rng.uniform(-0.5, 0),
    )

Tip

When randomizing rain, pair rain_intensity with a matching rain_screen_droplets preset to keep the visual effect consistent. For example, higher rain intensities look more natural with HEAVY or VERY_LARGE droplet presets.