Don't use ImageBitmap unless colorSpaceConversion option is supported #10111
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.
We were seeing some artifacts in 3D Tiles Next demos that use feature id textures on Safari desktop and mobile. Interestingly the S2 demo, which also uses feature id textures, didn't have these artifacts. After more investigation the only difference was that the first two demos had images with embedded color profiles, and the S2 demo did not.
The glTF spec requires that embedded color profiles in images are ignored since it's the material definition that determines whether images are considered sRGB or linear. The same rule extends to feature ID textures. There are two ways of ensuring that:
ImageBitmapis not supported thengl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE)should be called before theHTMLImageElementis passed togl.texImage2DImageBitmapis supportedcolorSpaceConversion: "none"should be passed tocreateImageBitmap, sinceUNPACK_COLORSPACE_CONVERSION_WEBGLhas no effect forImageBitmapMost of this was already done in #9624. The problem is that Firefox and Safari support
ImageBitmapbut they don't support thecolorSpaceConversionoption so they would always apply some sort of color correction, which really breaks feature id textures. We don't want gamma correction applied to non-color data 😄So this PR disables
ImageBitmapif thecolorSpaceConversionoption isn't supported. Unfortunately there's no way for the browser to tell us this, made worse by the fact that thecreateImageBitmappromise resolves even when a non-defaultcolorSpaceConversionoption is passed in, so the approach here is forResource.supportsImageBitmapOptionsto create an ImageBitmap from a PNG with an embedded color profile twice, once withcolorSpaceConversion: "none"and again withcolorSpaceConversion: "default", and check that the results are different.Downside is that we can no longer use
ImageBitmapin Firefox and Safari. But at least feature ID textures are working properly now.Fixes #9875