DataUtils: Add toRGB9E5()
and fromRGB9E5()
.
#28012
Merged
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.
Related issue: #27992
Description
This PR adds two helper methods to
DataUtils
for packing/unpacking floating point values in context ofRGB9E5
. The code is based on the C implementation of https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_shared_exponent.txt.I have tested the change with a modified version of
RGBELoader
andwebgl_loader_texture_hdr
. I did not add these changes to this PR sinceRGBELoader
might not be the best spot for usingRGB9E5
. That's becauseRGB9E5
is not a color renderable format so we can't convert aRGB9E5
equirectangular environment map to aRGB9E5
cube map. This is required though since we don't support equirectangular textures in the shaders. If we switch to half float in the conversion process, it would not make sense to useRGB9E5
in the first place. The same issue exists with PMREM as well.As pointed out in #27971,
WEBGL_render_shared_exponent
is required to makeRGB9E5
color renderable but browser/device support for that isn't great right now.