schellingb / UnityCapture

Streams Unity rendered output to other Windows applications as virtual capture device
430 stars 68 forks source link

Transparency into OBS #2

Closed fryguy1013 closed 6 years ago

fryguy1013 commented 6 years ago

I'm having trouble getting the alpha channel working with this plugin. Both convincing Unity3D to render a scene with a transparent background, and using the texture plugin with directly set alpha channel values to get the transparency showing up in OBS.

Given that the readme supports transparency, can you make an example program that supports transparency so I can know it's something wrong with my setup rather than my lack of doing the unity programming correctly?

schellingb commented 6 years ago

Hi there

The regular sample should work fine when receiving in ARGB (colors + alpha channel) format. Try the following with the included example Unity project:

  1. Open UnityCaptureExample scene
  2. Because the camera background color is controled by the CubesSwayBeeps component, edit the color of Element 0 of the Per Frame Background property
  3. Change the background color to something with zero (or at least less than 255) A
  4. Press play
  5. In OBS open the properties for the UnityCapture video capture device
  6. Make sure the Video Format setting is set to ARGB
  7. If there is flickering (or maybe any other issue) restart OBS (I think it's a bug when switching Video Format)

If you want to capture a camera that is not outputting to the display but to a render texture, make sure the camera target render texture has Color Format set to ARGB32 or ARGB Half.

If your code is based on the CaptureTexture example it worked fine for me out-of-the-box by just drawing into the texture with something like new Color(1, 0, 0, .25f) (25% alpha).

It should look like this: unitywithalphacapture

Good luck!

fryguy1013 commented 6 years ago

I "figured it out" right after posting this. I thought maybe it was for the old version of OBS so I installed it. When I went back to the new version it just worked and I felt very frustrated. Such is the life of software developer T_T.

Thanks for the work on this great plugin :)