Point Light Introduction
In this case you will get familiar with Point Light. It is a light source that has a dimension of a single point.
You will learn what are the properties and characteristic of this light source.
Agenda:
- PointLight basic usage
- Light manipulation
Scene setup
Let's use custom scene composer to set up the scene.
Scene consists of:
- shaderball - location: (0, 0, 0)
- plane - location: (0, 0, 0)
- camera - location: (-2, 4, 4)
from skyrenderer.cases.utils import BaseLightSceneComposer
scene_composer = BaseLightSceneComposer()
scene_composer.setup_scene()
renderer_context = scene_composer.renderer_context
2025-02-04 13:23:00,057 | 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 13:23:00,396 | skyalembic.archive_manager | WARNING: Loading not adapted alembic file
PointLight basic usage
Let's create a Point Light object in the location of a newly created light_LIGHT_NUL node.
We will place it a few units to the right from camera origin using LocusDefinition.
Afterward we have to register light node in the renderer_context by set_light() method.
Notice the characteristic effects of a Point Light:
- the shadows are very distinct
- intensity of light falls with distance squared
- light shines uniformly in all directions
from skyrenderer.scene.scene_layout.layout_elements_definitions import LocusDefinition
from skyrenderer.basic_types.locus.transform import Transform
from skyrenderer.basic_types.light import PointLight
light_locus = LocusDefinition(transform=Transform(translation_vector=[2, 2, 4]))
renderer_context.add_node(node_key="light_LIGHT_NUL", locus_def=light_locus)
light = PointLight(
context=renderer_context,
origin_name="light_LIGHT_NUL",
)
renderer_context.set_light(light)
scene_composer.visualize()
2025-02-04 13:23:00,518 | skyrenderer.utils.time_measurement | INFO: Setup time: 97 ms
2025-02-04 13:23:00,669 | skyrenderer.utils.time_measurement | INFO: Context update time: 150 ms
2025-02-04 13:23:04,356 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms
2025-02-04 13:23:04,357 | skyrenderer.utils.time_measurement | INFO: Render time: 3.69 seconds
Light manipulation
Let's change the location of the first light source and place them further from the shaderball.
As you can see, the shaderball is lit less when we move away the light source.
renderer_context.get_node("light_LIGHT_NUL").translation = [2, 2, 10]
scene_composer.visualize()
2025-02-04 13:23:04,654 | skyrenderer.utils.time_measurement | INFO: Setup time: 69 ms
2025-02-04 13:23:04,777 | skyrenderer.utils.time_measurement | INFO: Context update time: 121 ms
2025-02-04 13:23:08,232 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms
2025-02-04 13:23:08,232 | skyrenderer.utils.time_measurement | INFO: Render time: 3.45 seconds
For more information about PointLight’s specific parameters, check PointLight class documentation.
Summary
In this section you have learnt:
- PointLight causes very distinct shadows, its intensity diminishes with distance squared and shines
uniformly in all directions. - Location of PointLight may be modified by accessing node's translation.