-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Fix half-float render target fallback for mobile GPUs missing EXT_color_buffer_half_float
#33114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
RodrigoHamuy
wants to merge
7
commits into
mrdoob:dev
Choose a base branch
from
RodrigoHamuy:fix/mobile-ocean-example
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−1
Draft
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61a94dc
add more controls to debug
RodrigoHamuy 5561458
add names
RodrigoHamuy 9f8dc61
extras/PMREMGenerator: fall back to FloatType when EXT_color_buffer_h…
RodrigoHamuy 15cd9d3
jsm/objects/Water: fall back to FloatType when EXT_color_buffer_half_…
RodrigoHamuy e331e97
examples/webgl_shaders_ocean: enable water and disable debug light by…
RodrigoHamuy 12f3b41
examples/webgl_shaders_ocean: revert debug scaffolding
RodrigoHamuy 406268b
WebGLTextures: auto-downgrade HalfFloatType render targets on unsuppo…
RodrigoHamuy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect a fallback to
UnsignedByteTypeif half float isn't available. The render target setup for transmission works like that:three.js/src/renderers/WebGLRenderer.js
Lines 1950 to 1961 in 320e432
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify: There is no need to use
FloatType. We can keep usingHalfFloatTypebut just requestEXT_color_buffer_floatinstead. This extension includes formats likegl.RGBA16F.Reference: https://registry.khronos.org/webgl/extensions/EXT_color_buffer_float/
The thing is, the renderer already requests
EXT_color_buffer_floathere:three.js/src/renderers/webgl/WebGLExtensions.js
Lines 33 to 38 in 320e432
I'm now confused why the changes in the PR are required in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My phone has the following capabilities:
❌ EXT_color_buffer_half_float
✅ EXT_color_buffer_float
✅ OES_texture_float_linear
If I replace
FloatTypewithUnsignedByteTypeas fallback, I get darker brightsWith PR as it is
With
UnsignedByteTypefallbackWhat would you like me to do?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
EXT_color_buffer_floatis supported on your device,HalfFloatTypeshould work. If it doesn't, we must find out the root cause.Do you see any console warnings when
HalfFloatTypeis used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No console warnings, silently passes. Driver issue?
Btw, I moved the fallback to
WebGLTexturesas it seems like the right place instead as suggested by @mrdoob .Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the issue was introduced with #32680 which has added bloom to the demo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pixels in
webgl_shaders_oceancan get very bright due to how the sky is implemented now (it does not use a built-in gamma correction since r183). If you then generate a PMREM from the scene and use it as an environment map, the objects in your scene end up bright as well. If you then add bloom to the scene, it further increases the luminance. I think this gets to a point where certain devices can't handle the values anymore.Given that there is no issues on Desktop and the demo uses RGBAF16 on all devices, the root cause must be related to something device specific.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue in r183 happens even if I disable bloom (which I did while debugging this).
r182 does work fine, although, damn, that was a nice upgrade in the last version 😄 . The new sky looks so much better!!
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, without bloom the rendering breaks but more subtle. Here is a test link right before the bloom addition:
https://rawcdn.githack.com/mrdoob/three.js/98a7dd547f988ad0cfaf697ec41a0ff5bf254d0b/examples/webgl_shaders_ocean.html
With a high elevation, the box mesh becomes black (it should turn white though). Nevertheless, bloom seems to amplify the issue. The breakage on mobile starts with #32677 though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we must somehow isolate this issue into a smaller test case. Like the one from #33114 (comment). In this way, it will be easier to get feedback from the browser dev side.