Sun glare in a camera’s lens
Looking into the sun is the hard case for a camera on the water: the sun itself and its glare inside the lens. A renderer’s camera has a perfect lens. Give it a real one.
Add the glare
Put the glare plugin inside the camera’s sensor:
<sensor name="camera" type="camera">
<camera>...</camera>
<plugin filename="gz-maritime-camera-effects-system"
name="gz::sim::maritime::CameraGlare"/>
</sensor>
With the world’s sun in front of the camera you get:
a veil: a haze over the whole image that washes out contrast, most around the sun;
bloom: bright things bleed into what is next to them;
flare: the sun’s glow, a streak across it, and ghosts that cross the image as the camera turns.
<veil>, <bloom> and <flare>, each 0 to 1, set how much of each. The
sun is the world’s first directional light that is on; name another with
<sun>. A sun under the horizon gives no glare.
Change it while the world runs
gz topic -t /world/default/model/my_boat/link/camera_link/sensor/camera/glare/set \
-m gz.msgs.Param \
-p 'params { key: "flare" value { type: DOUBLE double_value: 0.8 } }'
.../glare/state reports where the sun is in the image (sun_u,
sun_v), its angle off the camera’s axis, and whether the pass is on the
camera and drawing.
Things to know
Nothing blocks the sun. A building in front of the sun does not stop its glare: the pass does not know what is in front of what.
Order. Glare comes before the camera’s own noise and distortion, as in a real camera. With drops on the lens the image goes through the drops first, whichever plugin is first in the file.
Cost. Nothing measurable, and nothing at all with the sun behind the camera and no bloom.