Fix bloom artifacts appearing due to bad specular data #7605
+4
−2
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.
Description
Fixes black square artifacts appearing on screen when the Bloom or Dof effects were used with the CameraFrame script. This bug was only reproduced on Ubuntu with an nvidia GPU.
Solution
This patch adds a clamp to the fresnelSchlick.js functions,
getFresnel()
andgetFresnelCC()
, to avoid bad specular values.Explanation
I still don't think I'm 100% sure why it was happening, but from what I can tell:
engine/src/scene/shader-lib/chunks/lit/frag/pass-forward/litForwardBackend.js
Lines 106 to 114 in 49ffb62
cosTheta
of-1
should not break anything.max()
would set it to0.0
and the function should work okay.engine/src/scene/shader-lib/chunks/lit/frag/fresnelSchlick.js
Lines 1 to 21 in 49ffb62
getFresnel()
to return a bad specular value.Before vs After
(Note that the flashing is more visible in-person, the low-FPS recording hides it somewhat)
Screencast.From.2025-04-25.03-26-28.mp4
Testing
Project for testing: https://playcanvas.com/editor/scene/2210459
Fixes #7492
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.