Search Unity

Render Camera to Cubemap for 3D Capture

Discussion in 'General Graphics' started by kshoemoney, Apr 22, 2021.

  1. kshoemoney

    kshoemoney

    Joined:
    Mar 8, 2021
    Posts:
    1
    I'm trying to modify the UnityCapture plug-in (which renders a camera in Unity to be used as a webcam device on other programs like OBS) to make a 360 webcam device. Essentially I need to take this plugin and get it to output a equirectangular or cubemap image instead of a normal 2d one, to use in OBS. This feels like it should be simple but I'm not sure what I'm doing wrong:

    Code (CSharp):
    1. void OnRenderImage(RenderTexture source, RenderTexture destination)
    2. {
    3.     GetComponentInParent<Camera>().RenderToCubemap(cubemapTarget, 63, Camera.MonoOrStereoscopicEye.Mono);
    4.     cubemapTarget.ConvertToEquirect(equirect, Camera.MonoOrStereoscopicEye.Mono);
    5.     Graphics.Blit(equirect, destination);
    6.     switch (CaptureInterface.SendTexture(equirect, Timeout, DoubleBuffering, ResizeMode, MirrorMode))
    The output of this is just a black screen. If I skip the ConvertToEquirect and Blit the Cubemap render, it is a grey screen. Any thoughts on what I'm doing wrong here?