Lens Bloom
In this case we will present you Lens Bloom postprocess step.
Agenda:
- Lens bloom theory
- Lens Bloom step usage
Scene setup
Let's use custom scene composer to set up the scene.
Scene consists of:
- sphere - location: (0, 0, 0)
- camera - location: (5, 0, 0)
- point light - location: (2, 2, 2)
from skyrenderer.cases.utils import LensBloomSceneComposer
from skyrenderer.render_chain import RenderChain
scene_composer = LensBloomSceneComposer()
scene_composer.setup_scene()
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step],
width=1600,
height=900,
),
)
scene_composer.visualize()
2025-02-14 12:47:01,851 | skyrenderer.scene.renderer_context | INFO: Root paths: - root path: /home/skyengine/anaconda/lib/python3.6/site-packages/skyrenderer - assets path: /dli/mount/assets - config path: /home/skyengine/anaconda/lib/python3.6/site-packages/skyrenderer/config - gpu sources path: /home/skyengine/anaconda/lib/python3.6/site-packages/skyrenderer/optix_sources/sources - cache path: /dli/mount/cache - ptx cache path: compiled_ptx/ptx - ocio path: ocio_configs/aces_1.2/config.ocio 2025-02-14 12:47:04,972 | skyrenderer.utils.time_measurement | INFO: Setup time: 3.09 seconds 2025-02-14 12:47:05,630 | skyrenderer.utils.time_measurement | INFO: Context update time: 656 ms 2025-02-14 12:47:09,837 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-14 12:47:09,838 | skyrenderer.utils.time_measurement | INFO: Render time: 4.21 seconds
Lens Bloom theory
Lens Bloom is an optical phenomenon which manifest itself as bright flashes of light around light sources or
overexposed elements of the scene. This effect is a consequence of light diffraction on the aperture of a sensor.
In SkyRenderer it is modelled with addition of the light diffraction pattern due to the aperture of the camera and
applying it to the rendered image.
Lens Bloom step usage
We define a new render chain with two steps:
- predefined scene composer's visible light render step
- LensBloom postprocess step
Let's start with default parameters:
from skyrenderer.render_chain.postprocess_steps.lens_bloom import LensBloomPostprocess
lens_bloom = LensBloomPostprocess(scene_composer.renderer_context)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, lens_bloom],
width=1600,
height=900,
),
)
scene_composer.visualize()
2025-02-14 12:47:10,936 | skyrenderer.utils.time_measurement | INFO: Setup time: 85 ms 2025-02-14 12:47:12,293 | skyrenderer.utils.time_measurement | INFO: Context update time: 1.36 seconds 2025-02-14 12:47:16,111 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-14 12:47:16,114 | skyrenderer.utils.time_measurement | INFO: Render time: 3.82 seconds
We suggest using default values for the parameters. However, if you need a very specialized effect, you can
tweak some of them for better results. In particular, "effect_contribution" can have a major effect on
the resulting image. The higher the "effect_contribution" the more prominent the bloom effect.
lens_bloom = LensBloomPostprocess(
scene_composer.renderer_context,
parameter_provider=LensBloomPostprocess.create_parameter_provider(
scene_composer.renderer_context, effect_contribution=10
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, lens_bloom],
width=1600,
height=900,
),
)
scene_composer.visualize()
2025-02-14 12:47:17,103 | skyrenderer.utils.time_measurement | INFO: Setup time: 67 ms 2025-02-14 12:47:17,806 | skyrenderer.utils.time_measurement | INFO: Context update time: 701 ms 2025-02-14 12:47:19,761 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-14 12:47:19,762 | skyrenderer.utils.time_measurement | INFO: Render time: 1.96 seconds
Summary
In this section you have learnt:
- LensBloom postprocess step must be added after visible right render step.
- LensBloom creates light blooming effect around light sources and highly reflective surfaces.
- The default parameters are generally recommended, but you can change them for more specialized effects.