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.
MEDIUM — Small running droplets on the camera lens
VERY_LARGE — Very large droplets on the camera lens
Rain intensity¶
Rain intensity controls the amount of rain particles in the scene.
# 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.
world.env.weather.set_rain_screen_droplets(ScreenDropletsPreset.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 |
|
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 |
|---|---|
|
Controls the blur intensity of droplets on the lens. A value of Range: |
|
Controls how quickly droplets scroll vertically across the screen. Negative values scroll downward, positive values scroll upward. Range: |
|
Sets the starting position of the droplet pattern on the screen. Range: |
|
Controls the intensity of drip streaks running down the lens. Range: |
|
Controls the size of the droplets on the screen. Range: greater than |
# 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.
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.