Skip to content
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

Video textures look washed out in safari starting with version 0.152.0 #26516

Closed
justinrhodes1 opened this issue Jul 31, 2023 · 14 comments · Fixed by #26521
Closed

Video textures look washed out in safari starting with version 0.152.0 #26516

justinrhodes1 opened this issue Jul 31, 2023 · 14 comments · Fixed by #26521

Comments

@justinrhodes1
Copy link

justinrhodes1 commented Jul 31, 2023

Description

Video textures look washed out in safari with mesh basic materials (Version 16.3/18614.4.6.1.6). In Chrome the texture colors look fine. Setting the texture colorspace to SRGBColorSpace doesn't seem to make any difference.

Related to the changes in color management in version 0.152.0.

Live example

Screenshots

Safari
safari

Chrome
chrome

Version

0.155.0

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 31, 2023

I can reproduce on macOS 13.4.1 with Safari 16.5.2. It seems the texture indeed ignores the SRGBColorSpace definition. Enhancing the built-on shader with a manual sRGB decode seems to fix the issue:

https://codesandbox.io/s/white-snow-77vjd8?file=/src/index.ts:744-1348

Is SRGB8_APLHA8 broken for video textures in WebKit?

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 31, 2023

https://threejs.org/examples/webgl_video_panorama_equirectangular shows the same issue.

FF is fine, btw.

@cankahya
Copy link

cankahya commented Jul 31, 2023

Any updates on this? Running into the same problem with a 360 Video – based on https://threejs.org/examples/webgl_video_panorama_equirectangular

Insights / ideas would be much appreciated.

Edit: oops, just seeing this issue was created 6h ago. Sorry, don't wanna be impatient. But +1 for this issue :)

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 1, 2023

@donmccurdy Given the broken Webkit support and #26183, I think it's best for now to revert #25752. I originally did not want to go this route but the current situation is simply not acceptable. The fact is, video textures can't be properly used in production without patching the built-in shaders like in #26516 (comment).

I also doubt that the browser vendors will soon fix their issues so we need a fix in the engine.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 1, 2023

Insights / ideas would be much appreciated.

@cankahya Until there is a fix in the engine, use the workaround from #26516 (comment).

@justinrhodes1
Copy link
Author

I can reproduce on macOS 13.4.1 with Safari 16.5.2. It seems the texture indeed ignores the SRGBColorSpace definition. Enhancing the built-on shader with a manual sRGB decode seems to fix the issue:

https://codesandbox.io/s/white-snow-77vjd8?file=/src/index.ts:744-1348

Is SRGB8_APLHA8 broken for video textures in WebKit?

Thanks for the quick reply. This solution will do for now! 👍

@donmccurdy
Copy link
Collaborator

@Mugen87 Agreed — seems like inline sRGB decoding is still necessary for video textures. 😔

@cankahya
Copy link

cankahya commented Aug 1, 2023

Insights / ideas would be much appreciated.

@cankahya Until there is a fix in the engine, use the workaround from #26516 (comment).

@Mugen87 You are my hero! Thank you, I didn't get that on the first read. Thanks for pointing that out again!! Works like a charm.

@marcofugaro
Copy link
Contributor

So this is broken on Webkit, is there already a webkit issue about this?

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 2, 2023

It seems there is no bug reported yet. At least when searching for SRGB8_APLHA8.

https://bugs.webkit.org/buglist.cgi?quicksearch=SRGB8_APLHA8

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 3, 2023

I've filed a bug today: https://bugs.webkit.org/show_bug.cgi?id=259768

@cgauld
Copy link
Contributor

cgauld commented Aug 3, 2023

I have a worry that there may be no performant way for browsers to implement this on their side. I suspect the issue is that the underlying video texture comes straight from the video decoding hardware. In order for the browser to perform the conversion to linear then I think the only options available to them would be:

  1. do the conversion CPU-side, which would be suuuper slow
  2. render the texture into another texture doing this conversion in a shader, which would also be much slower than just doing the conversion after sampling in the final fragment shader (as @Mugen87's fix does)

If they're already doing 2 then it may not incur very much any additional performance cost than there already is, but it does require the browsers to do the correct conversion in that intermediate shader.

@donmccurdy
Copy link
Collaborator

donmccurdy commented Aug 3, 2023

sRGB decoding is a standardized feature of WebGL, and works in other browsers. If there's a reason browsers cannot implement it efficiently, then the feature should be evicted from the standard. But I expect it's just a bug, lots has been changing in Webkit's WebGL implementation over the past few years.

@cgauld
Copy link
Contributor

cgauld commented Aug 3, 2023

I agree for sure :-) I think the reason things might be different for video textures is that accelerated path straight from the hardware decoder. Hopefully I'm wrong and it can be implemented in a performant way :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants