fix: Apply ignoreBackground and inverted Props in SelectiveBloom #297
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.
Fix: Apply
ignoreBackground
andinverted
Props inSelectiveBloom
Fixes #111
Description of the Issue:
The
ignoreBackground
andinverted
props ofSelectiveBloom
were not being applied, causing the selective bloom effect to work incorrectly, particularly when using an HDRI environment map. This issue is further detailed in this GitHub issue.As shown in the images below:
The suggested solution in issue #111 involved using emissive materials with values above the 0-1 RGB range and setting a high luminanceThreshold to control what glows. However, this does not work with HDRI images, as they contain areas of high luminosity that still get selected, even with a high luminanceThreshold like 100. This results in unintended glowing effects in the background, making ignoreBackground essential for proper selective blooming.
Codesandbox link to reproduce the issue https://codesandbox.io/p/sandbox/selective-bloom-props-issue-6fp8vm
Solution:
The
ignoreBackground
andinverted
props are setters, but they were not passed as arguments in the constructor, resulting in them being ignored. This fix ensures that these props are now correctly applied, allowing the selective bloom effect to work as intended.Please review and let me know if any additional changes are needed. Thank you!
Side note
The demo in the Storybook does not work as it uses the Environment component from an older version of @react-three/drei. In this version, the CDN hosting the sample preset HDR files is no longer active. Upgrading to "@react-three/drei": "^9.70.0" resolves this issue. But I haven't changed the version in this PR so the Storybook demo might break with fetch error.