Sphere Light Introduction
In this case you will get familiar with Sphere Light. For this light type, light comes from the sphere of
the specified radius. You will learn what are the properties and characteristic of this light source.
Agenda:
- SphereLight basic usage
Scene Setup
Let's use custom scene composer to set up other aspects of 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
/dli/skyenvironment/skyrenderer/skyrenderer/basic_types/provider/tools/loop_subdivision.py:4: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
from tqdm.autonotebook import tqdm
scene_composer = BaseLightSceneComposer()
scene_composer.setup_scene()
renderer_context = scene_composer.renderer_context
2024-12-02 14:55:39,242 | 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
2024-12-02 14:55:39,242 | skyrenderer.core.asset_manager.asset_manager | INFO: Syncing assets...
2024-12-02 14:55:41,359 | skyrenderer.core.asset_manager.asset_manager | INFO: Syncing git annex done.
2024-12-02 14:55:41,784 | skyalembic.archive_manager | WARNING: Loading not adapted alembic file
SphereLight basic usage
Let's create a Sphere 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 Sphere Light:
- the shadows are soft, not 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 SphereLight
light_locus = LocusDefinition(transform=Transform(translation_vector=[2, 2, 4]))
renderer_context.add_node(node_key="yellow_light_NUL", locus_def=light_locus)
yellow_light_params = SphereLight.create_parameter_provider(
renderer_context, color=(0.5, 0.5, 0), illuminance=25, radius=0.5
)
renderer_context.set_light(
SphereLight(renderer_context, "yellow_light_NUL", parameter_provider=yellow_light_params)
)
scene_composer.visualize()
2024-12-02 14:55:41,872 | skyrenderer.utils.time_measurement | INFO: Setup time: 71 ms
2024-12-02 14:55:42,010 | skyrenderer.utils.time_measurement | INFO: Context update time: 137 ms
2024-12-02 14:55:43,686 | skyrenderer.utils.time_measurement | INFO: Key points calculation time: 0 ms
2024-12-02 14:55:43,686 | skyrenderer.utils.time_measurement | INFO: Render time: 1.68 seconds
Summary
In this section you have learnt:
- SphereLight causes soft, not distinct shadows, its intensity diminishes with distance squared and shines
uniformly in all directions.
For more information about SphereLight's parameters check SphereLight class documentation.