E543 Add `environment` Property to `Scene` by panxinmiao · Pull Request #1156 · pygfx/pygfx · GitHub
[go: up one dir, main page]

Skip to content

Conversation

panxinmiao
Copy link
Contributor
@panxinmiao panxinmiao commented Jul 30, 2025

Summary:

This PR introduces support for a scene-level environment map via the scene.environment attribute.
It adds a scene parameter to the get_bindings method of ShaderInterface. 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 or MeshPhysicalMaterial 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:

  • The get_bindings method signature in BaseShader is changed from get_bindings(wobject, shared) to get_bindings(wobject, shared, scene).
  • The scene parameter is now properly passed to all shader instances during pipeline updates.

@panxinmiao panxinmiao requested a review from Korijn as a code owner July 30, 2025 07:32
@panxinmiao panxinmiao changed the title Add environment Property to `Scene Add environment Property to Scene Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0