Skip to content

Improve IBL baker performance, Singlepass Spherical Harmonics baker and Hammersley based sampler#2779

Open
riccardobl wants to merge 2 commits into
jMonkeyEngine:masterfrom
riccardobl:spsph
Open

Improve IBL baker performance, Singlepass Spherical Harmonics baker and Hammersley based sampler#2779
riccardobl wants to merge 2 commits into
jMonkeyEngine:masterfrom
riccardobl:spsph

Conversation

@riccardobl
Copy link
Copy Markdown
Member

@riccardobl riccardobl commented May 16, 2026

This PR replaces the ping-pong based IBL spherical harmonics baker with a singlepass version to workaround some bugs in Angle on iOS, it is also a small performance improvement for other platforms.

In addition to that, hammersley based sampling is implemented as a lower quality "Fast path" for the spherical harmonics baker. This is set by default to AUTO, that enables it on iOS and android, but not on desktop.

Textures and Framebuffers are now reused to improve rebake() performances

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds configurable Spherical Harmonics (SH) baking modes (AUTO, FAST, and QUALITY) to environment probes, enabling performance optimizations like Hammersley sampling for mobile platforms. The implementation involves updates to IBLGLEnvBakerLight, the IBLSphH shader, and EnvironmentProbeControl, including new serialization and test case functionality. Feedback focuses on the new cloneForSpatial implementation in EnvironmentProbeControl, which contains critical flaws: it bypasses the setSpatial logic required for proper light attachment, incorrectly shares UUIDs and filter states between clones, and omits several inherited properties from the Light class.

Comment thread jme3-core/src/main/java/com/jme3/environment/EnvironmentProbeControl.java Outdated
@riccardobl
Copy link
Copy Markdown
Member Author

@gemini-code-assist review pls

@riccardobl riccardobl changed the title Singlepass Spherical Harmonics Baker and Hammersley based baker Improve IBL baker performance, Singlepass Spherical Harmonics and Hammersley based sampler May 16, 2026
@riccardobl riccardobl changed the title Improve IBL baker performance, Singlepass Spherical Harmonics and Hammersley based sampler Improve IBL baker performance, Singlepass Spherical Harmonics baker and Hammersley based sampler May 16, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes environment probe baking by introducing a configurable Spherical Harmonics (SH) baking mode and implementing resource caching for frame buffers and bakers. Key additions include a Hammersley-based fast path for SH coefficients in the shader and improved lifecycle management in EnvironmentProbeControl, including support for cloning and proper resource cleanup. Review feedback identified a type mismatch in the shader's Hammersley implementation and suggested simplifying vector accumulation logic for better readability.

Comment thread jme3-core/src/main/resources/Common/IBLSphH/IBLSphH.frag
Comment thread jme3-core/src/main/resources/Common/IBLSphH/IBLSphH.frag
Comment thread jme3-core/src/main/resources/Common/IBLSphH/IBLSphH.frag
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