Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Bobby21 · Aug 13, 2020 at 01:00 AM · bugwebglvideo

WebGL Video colors washed out

Here's a quick background on the issue,

I have a video I'm looking to play for a WebGL project. While the video looks just fine in the editor, when I go to build it out for the web, the colors are noticeably different (washed out) compared to the original/editor quality.

(Left: Web Build, Right: Original Video)

[Picture of video quality comparison][2]


As shown in the image, the colors are significantly washed out.

The problem exists in both the locally hosted build and the web build hosted via GitHub pages. I'm using Chrome (Version 84.0.4147.125 (Official Build) (64-bit))


I stream the video in using a URL from Dropbox. For privacy reasons, I haven't shown the entire video URL but I end it with ".mp4?dl=0" which I read about from here, (https://answers.unity.com/questions/1370621/using-videoplayer-to-stream-a-video-from-a-website.html Sir-Gatlin 's comment)

In regards to the VideoPlayer, the video is played on a plane mesh that has a custom material with the URP Unlit shader. The VideoPlayer render mode is set to Render Texture. I have not tweaked any of the default Render Texture settings, aside from the dimensions to match the video file.

The file type of the video is .mp4


Below is a picture of the inspector properties for the following (left to right)

  1. The Video Player gameObject (the plane) and it's VideoPlayer component.

  2. The Render Texture.

  3. The Plane's Material with the Render Texture applied to the base map.

Picture of inspector properties


Here's a little more background about the render pipeline / lighting / editor settings. (Might seem random but I've read about these potentially creating issues with video playback.)

  1. The color space is Linear.

  2. There is no fog enabled.

  3. I am using the Universal Render Pipeline.

  4. I am using Post Processing effects (Bloom, Vignette, Tonemapping)

  5. I am using Unity 2020.1.0f1


My thoughts on the issue,

If I had to guess I'd say the problem lies in the Render Texture's Color Format. Unfortunately looking at the Unity Docs for answers hasn't proved very helpful explaining how/when to select certain ones. (https://docs.unity3d.com/2020.1/Documentation/ScriptReference/RenderTextureFormat.html)

Any thoughts/insights would be greatly appreciated!

Thanks for reading!

washedoutcolor.png (121.5 kB)
inspectorsettings.png (132.8 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Edwige · Aug 17, 2020 at 02:36 PM 0
Share

Same issue here (washed out, very pale video), with "near camera plane" option in the video player. Our unity version is 2019.3.1f1.

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Edwige · Aug 18, 2020 at 09:31 AM

I had the same issue : the video was low quality and pale, even if I was using streamingassets to load my video.

The solution for me was to change the color space, in the webgl player settings. Instead of Linear, I choose Gamma, and now it works fine :)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bobby21 · Aug 18, 2020 at 07:26 PM 0
Share

That worked thanks!

Sure it messed up the prior lighting settings but it beats shelling out for paid assets that wouldn't necessarily work.

avatar image InesHilz · Feb 19, 2021 at 11:55 AM 0
Share

Thank you! I was searching for this answer for days :)

avatar image
5

Answer by hakimbawa · Oct 05, 2021 at 09:27 AM

Changing the global color space was not convenient for us. Created a new unlit shader with a conversion from GammaToLinear (the other way around makes it even more washed out). It's not 100% perfect, but much better than before. Simply assign the shader to a new material, and assign that material to your RawImage component that renders the video. We attach it conditionally if the player is WebGL, otherwise other players become too dark. Mainly the important line is

 col.rgb = GammaToLinearSpace(col.rgb);

The stencil is optional, we needed it because the video is behind a mask.

 Shader "Unlit/VideoPlayerShader"
 {
 
     Properties
     {
         _MainTex ("Texture", 2D) = "white" {}
         _Stencil ("Stencil Ref", Float) = 1
         _StencilComp ("Stencil Comparison", Float) = 3
         _StencilOp ("Stencil Operation", Float) = 0
         _StencilWriteMask ("Stencil Write Mask", Float) = 0
         _StencilReadMask ("Stencil Read Mask", Float) = 1
         _ColorMask ("Color Mask", Float) = 15
     }
 
     SubShader
     {
         Tags { "RenderType"="Opaque" }
         LOD 100
 
         Stencil 
         {
             Ref [_Stencil]
             ReadMask [_StencilReadMask]
             WriteMask [_StencilWriteMask]
             Comp [_StencilComp]
             Pass [_StencilOp]
         }
 
         Pass
         {
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
 
             #include "UnityCG.cginc"
 
             struct appdata
             {
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             };
 
             struct v2f
             {
                 float2 uv : TEXCOORD0;
                 float4 vertex : SV_POSITION;
             };
 
             sampler2D _MainTex;
             float4 _MainTex_ST;
 
             v2f vert (appdata v)
             {
                 v2f o;
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 return o;
             }
 
             fixed4 frag (v2f i) : SV_Target
             {
                 fixed4 col = tex2D(_MainTex, i.uv);
                 col.rgb = GammaToLinearSpace(col.rgb);
                 return col;
             }
             ENDCG
         }
     }
 }



Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image karinarigby · Nov 10, 2021 at 07:02 PM 0
Share

Thank you so much, this worked like a dream!!

avatar image hakimbawa karinarigby · Nov 11, 2021 at 12:56 AM 0
Share

Glad I could help! :)

avatar image darklord849 · May 31 at 07:05 AM 0
Share

Brother , my project was so huge that i cant switch to gamma or to 2021. and you helped me , the day you will read this message remember you are awesome <3

avatar image
0

Answer by DhiaSendi · Apr 09 at 10:05 AM

Fixed by upgrading to Unity 2021.2.19f

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

163 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I play videos in WebGL? 0 Answers

Video don't play unity WebGL on URL 1 Answer

Web GL and Unity editor defferent behaviour 0 Answers

Screen Recording in WebGL 0 Answers

Record and Share Game Play Video in WebGL 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges