Mesh Light Introduction
In this case you will get familiar with Mesh Light. Mesh light is a light source that covers any
arbitrary geometry.
Agenda:
- Emissive shader basic usage
- Cover neon with a mesh light
Scene setup
Let's use custom scene composer to set up the scene.
Scene consists of:
- neon - location: (0, 0.07, 0)
- plane - location: (0, 0, 0)
- camera - location: (-1, -0.5, 1)
from skyrenderer.cases.utils import MeshLightSceneComposer
scene_composer = MeshLightSceneComposer(antialiasing_level=2048)
scene_composer.setup_scene(width=1400, height=900)
2025-02-04 10:22:05,440 | skyrenderer.scene.renderer_context | INFO: Root paths:
- root path: /dli/skyenvironment/skyrenderer/skyrenderer
- assets path: /dli/mount/assets
- config path: /dli/skyenvironment/skyrenderer/skyrenderer/config
- gpu sources path: /dli/skyenvironment/skyrenderer/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-04 10:22:05,787 | skyalembic.archive_manager | WARNING: Loading not adapted alembic file
Emissive shader basic usage
Material definition and geometry
Before we add a mesh light, we need to specify material definition for our geometry.
We create a EmissiveShader parameter provider passing a renderer context and leaving other parameters as default.
Then we pass parameter provider to material definition and assign it to the geometry we choose.
from skyrenderer.scene.scene_layout.layout_elements_definitions import MaterialDefinition
from skyrenderer.basic_types.procedure import EmissiveShader
source_parameters = EmissiveShader.create_parameter_provider(scene_composer.renderer_context)
neon_material = MaterialDefinition(
shader=EmissiveShader(scene_composer.renderer_context), parameter_set=source_parameters
)
geometry_name = "Neon_GEOshape_NeonSE_emission"
scene_composer.renderer_context.set_material_definition(node_name=geometry_name, material_definition=neon_material)
Cover neon with a mesh light
Our geometry is covered with emissive material, now we can make it glow! Let's add a mesh light.
To do so we must pass to MeshLightDefinition class the following arguments: context, origin_name, illuminance,
sample_density. For more information about these parameters, see MeshLightDefinition documentation.
We will keep sample density low to decrease rendering time.
from skyrenderer.basic_types.light.mesh_light_definition import MeshLightDefinition
scene_composer.renderer_context.set_light(
MeshLightDefinition(scene_composer.renderer_context, geometry_name, illuminance=0.5, sample_density=0.0001)
)
scene_composer.visualize()
2025-02-04 10:22:05,893 | skyrenderer.utils.time_measurement | INFO: Setup time: 78 ms
2025-02-04 10:22:06,473 | 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-04 10:22:06,475 | 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-04 10:22:19,301 | skyrenderer.utils.time_measurement | INFO: Context update time: 13.41 seconds
2025-02-04 10:22:41,017 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms
2025-02-04 10:22:41,017 | skyrenderer.utils.time_measurement | INFO: Render time: 21.72 seconds
For more information check MeshLight and EmissiveShader class documentation.
Summary
In this section you have learnt:
- In order to emit mesh light, we need to set material definition with emissive shader first.
- We set mesh light using MeshLightDefinition.