Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 arumiat · Sep 20, 2015 at 07:05 AM · webgl

Embed webGL in webpage with transparent background

I'm looking to embed a simple Unity webGL object on my site homepage. I'd like to do it exactly like they've done on www.sketchfab.com. Ie the background (loading screen and scene view) is transparent & you can see the hero graphic and text underneath.

Is this possible?

Comment
Add comment · Show 2
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 Steven-1 · Sep 25, 2015 at 08:29 AM 0
Share

Haven't tried it yet, but Im guessing this will help: http://docs.unity3d.com/$$anonymous$$anual/CustomizingtheUnityWebPlayerloadingscreen.html It's for webplayer though

avatar image theLucre · Nov 06, 2015 at 02:44 AM 0
Share

Also looking for a solution here. I tried to set the context clearColor but that stops the unity draw cycle. There's nothing mentioned about transparency or bg color in the Unity WebGL player docs, either.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by theLucre · Nov 06, 2015 at 02:57 AM

Ok, found a working solution, though the Unity people admit it's a little hacky.

Create a .jslib file in your project with this code. It will clear the alpha on the webGL context. Confirmed working with HTML elements below and above the renderer.

 var LibraryGLClear = {
     glClear: function(mask)
     {
         if (mask == 0x00004000)
         {
             var v = GLctx.getParameter(GLctx.COLOR_WRITEMASK);
             if (!v[0] && !v[1] && !v[2] && v[3])
                 // We are trying to clear alpha only -- skip.
                 return;
         }
         GLctx.clear(mask);
     }
 };
  
 mergeInto(LibraryManager.library, LibraryGLClear);

Source

Comment
Add comment · Show 6 · 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 ValeValerin · Sep 15, 2016 at 06:50 PM 0
Share

Do you know what shaders this works with?

avatar image Bunny83 ValeValerin · Sep 15, 2016 at 07:28 PM 0
Share

$$anonymous$$ost shaders should work except some special shaders which require screen alpha values.

avatar image ValeValerin Bunny83 · Sep 15, 2016 at 07:42 PM 0
Share

I haven't been able to get this to work. I thought maybe it was a shader issue but after some experimenting it doesn't appear to be. I'm not sure what my next step should be.

avatar image Bunny83 · Sep 15, 2016 at 07:27 PM 0
Share

Have you actually tried to set the clear color to a color that has 0 as alpha value? How do you actually clear the screen? What clearflags do you use on your camera?

According to this SO post WebGL should support transparency out of the box. You just have to clear with alpha value 0. If that doesn't work from inside Unity you might want to simply set the clear color manually

avatar image shishihenge · Jul 19, 2017 at 08:10 AM 0
Share

I can't get this to work on 5.6.1f1 anymore. Has anybody find a workaround?

avatar image chitzui · Feb 13, 2018 at 08:47 PM 0
Share

While I get a transparent background in Chrome, this does not work in Firefox. I get a white background.

avatar image
0

Answer by seltar_ · Mar 14, 2017 at 09:53 AM

The unity knowledge base contains a solution, including how to set up the shaders. https://support.unity3d.com/hc/en-us/articles/208892946-How-can-I-make-the-canvas-transparent-on-WebGL-

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

35 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

Related Questions

Unity webGL build changes not reflecting,Unity webgl changes is not reflecting in build 1 Answer

Can one use a .NET library in a WebGL build? 1 Answer

WebGL,WebGL error 0 Answers

Youtube videos in Unity WebGL 2020.3 0 Answers

Webpage freeze with WaitForCompletion() 2 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