Add environment
Property to Scene
#1156
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This PR introduces support for a scene-level environment map via the
scene.environment
attribute.It adds a
scene
parameter to theget_bindings
method ofShaderInterface
. This change enables shaders and render pipelines to access global, scene-wide information and resources.Motivation:
In some cases, when rendering an object in a scene, the shader needs access to resources beyond the object itself—such as data defined at the scene level.
For instance, in PBR rendering, Image-Based Lighting (IBL) relies on an environment map that acts like a special kind of light source, affecting all PBR materials in the scene.
Previously, users had to manually assign the environment map to each material via the
env_map
property, which was inconvenient and error-prone.This PR makes it possible to define a global environment map at the scene level, enabling centralized control of environmental lighting.
If a material such as
MeshStandardMaterial
orMeshPhysicalMaterial
does not explicitly define its own environment map, it will now automatically fall back to the one defined on the scene.This mechanism also lays the groundwork for other potential scene-level resources, such as fog.
Key Changes:
get_bindings
method signature inBaseShader
is changed fromget_bindings(wobject, shared)
toget_bindings(wobject, shared, scene)
.scene
parameter is now properly passed to all shader instances during pipeline updates.