Light Glow parameters
In this case we will present you how to parametrize Light Glow postprocess step.
Agenda:
- Light Glow theory
- Light Glow step usage
Scene setup
Let's use custom scene composer to set up the scene.
from skyrenderer.cases.utils import LightGlowSceneComposer
from skyrenderer.render_chain import RenderChain
scene_composer = LightGlowSceneComposer(antialiasing_level=64)
scene_composer.setup_scene()
2025-02-21 13:37:04,689 | 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-21 13:37:05,066 | skyalembic.archive_manager | WARNING: Loading not adapted alembic file 2025-02-21 13:37:05,069 | skyrenderer.basic_types.provider.iprovider | WARNING: Provider for this config has been already initialized! There should be just one Provider created per unit source, consider fixing the scene. Config: metal
Activate threshold parameter
Activate threshold is value which any of r, g, b channels must pass to activate threshold.
Let's set it to 0.99, above neon RGB levels, so that light glow effect won't be applied and compare it with
0.80 threshold.
from skyrenderer.render_chain import LightsGlowPostprocess
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context, activate_threshold=0.99
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, light_glow],
width=600,
height=600,
),
)
threshold_99 = scene_composer.get_render(setup=True)
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context, activate_threshold=0.8
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, light_glow],
width=600,
height=600,
),
)
threshold_80 = scene_composer.get_render()
render_dict = {"Threshold 0.99": threshold_99, "Threshold 0.80": threshold_80}
scene_composer.visualize_grid_desc(render_dict, shape=(600, 1200), n_cols=2)
2025-02-21 13:37:07,997 | skyrenderer.utils.time_measurement | INFO: Setup time: 2.91 seconds 2025-02-21 13:37:08,558 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:37:08,559 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:37:21,665 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.67 seconds 2025-02-21 13:37:36,631 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:37:36,633 | skyrenderer.utils.time_measurement | INFO: Render time: 14.97 seconds 2025-02-21 13:37:36,649 | skyrenderer.basic_types.light.mesh_light | WARNING: Creating light parameter provider in context which is set up - hanging link possible 2025-02-21 13:37:36,705 | skyrenderer.utils.time_measurement | INFO: Setup time: 59 ms 2025-02-21 13:37:37,229 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:37:37,229 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:37:50,362 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.65 seconds 2025-02-21 13:37:57,100 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:37:57,101 | skyrenderer.utils.time_measurement | INFO: Render time: 6.74 seconds
Kernel Radius parameter
Kernel radius defines the size of the region around each pixel that is used to calculate the light glow effect.
A larger kernel radius includes more neighboring pixels, resulting in a broader light glow effect,
as more pixels contribute to the final value of the glowed pixel.
Let's compare two renders: with high and low kernel radius
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context,
activate_threshold=0.8,
kernel_radius=10,
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[
scene_composer.visible_light_render_step,
light_glow,
],
width=600,
height=600,
),
)
small_kernel = scene_composer.get_render()
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context,
activate_threshold=0.8,
kernel_radius=100,
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[
scene_composer.visible_light_render_step,
light_glow,
],
width=600,
height=600,
),
)
large_kernel = scene_composer.get_render()
render_dict = {"Kernel radius: 10": small_kernel, "Kernel radius: 100": large_kernel}
scene_composer.visualize_grid_desc(render_dict, shape=(600, 1200), n_cols=2)
2025-02-21 13:37:57,475 | skyrenderer.basic_types.light.mesh_light | WARNING: Creating light parameter provider in context which is set up - hanging link possible 2025-02-21 13:37:57,529 | skyrenderer.utils.time_measurement | INFO: Setup time: 56 ms 2025-02-21 13:37:58,050 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:37:58,050 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:38:11,435 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.91 seconds 2025-02-21 13:38:25,822 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:38:25,823 | skyrenderer.utils.time_measurement | INFO: Render time: 14.39 seconds 2025-02-21 13:38:25,913 | skyrenderer.basic_types.light.mesh_light | WARNING: Creating light parameter provider in context which is set up - hanging link possible 2025-02-21 13:38:25,967 | skyrenderer.utils.time_measurement | INFO: Setup time: 57 ms 2025-02-21 13:38:26,490 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:38:26,491 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:38:39,671 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.70 seconds 2025-02-21 13:38:55,397 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:38:55,399 | skyrenderer.utils.time_measurement | INFO: Render time: 15.73 seconds
Sigma parameters
The sigma parameter controls the amount of light glow by determining the spread of pixel weights in the light glow.
Sigma dictates how much neighboring pixels influence each other in the light glow effect. Higher sigma values make
the light glow stronger and wider, whereas lower sigma values produce a sharp, localized light glow around the pixel.
Let's compare two renders: with high and low sigma values.
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context, activate_threshold=0.6, sigma_x=5, sigma_y=5
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[scene_composer.visible_light_render_step, light_glow],
width=600,
height=600,
),
)
low_sigma = scene_composer.get_render()
light_glow = LightsGlowPostprocess(
scene_composer.renderer_context,
parameter_provider=LightsGlowPostprocess.create_parameter_provider(
scene_composer.renderer_context, activate_threshold=0.6, sigma_x=30, sigma_y=30
),
)
scene_composer.renderer_context.define_render_chain(
RenderChain(
render_steps=[
scene_composer.visible_light_render_step,
light_glow,
],
width=600,
height=600,
),
)
high_sigma = scene_composer.get_render()
render_dict = {"Sigma: 5": low_sigma, "Sigma: 30": high_sigma}
scene_composer.visualize_grid_desc(render_dict, shape=(600, 1200), n_cols=2)
2025-02-21 13:38:55,768 | skyrenderer.basic_types.light.mesh_light | WARNING: Creating light parameter provider in context which is set up - hanging link possible 2025-02-21 13:38:55,822 | skyrenderer.utils.time_measurement | INFO: Setup time: 57 ms 2025-02-21 13:38:56,345 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:38:56,345 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:39:09,371 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.55 seconds 2025-02-21 13:39:16,903 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:39:16,904 | skyrenderer.utils.time_measurement | INFO: Render time: 7.53 seconds 2025-02-21 13:39:16,912 | skyrenderer.basic_types.light.mesh_light | WARNING: Creating light parameter provider in context which is set up - hanging link possible 2025-02-21 13:39:17,754 | skyrenderer.utils.time_measurement | INFO: Setup time: 844 ms 2025-02-21 13:39:18,289 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Calculating 'position_map' and 'pdf_map' for Neon_GEOshape_NeonSE_emission, this may take a while... 2025-02-21 13:39:18,290 | skyrenderer.basic_types.provider.unit_providers.alembic_buffer_provider | INFO: Consider adding mesh cacher if you want to avoid waiting in the future. 2025-02-21 13:39:31,359 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.60 seconds 2025-02-21 13:39:40,880 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms 2025-02-21 13:39:40,881 | skyrenderer.utils.time_measurement | INFO: Render time: 9.52 seconds
Summary
In this section you have learnt:
- Activate threshold is value which any of r, g, b channels must pass to activate threshold of light glow effect.
- Kernel radius parameter controls the broadness of light glow.
- Sigma parameter controls the softness of the light glow.
- You can increase the light glow effect by adding Lights Glow Postprocess step multiple times to the render
chain.