Log in or register to post comments

Asking for VuforiaRenderer.VideoTextureInfo videoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo(); breaks video out

February 25, 2020 - 7:42pm #1

While I would love some answers to my other question about video and camera image. For now I find the on 8.6.10 calling 

videoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo();

makes the video playback like it never focuses and is muddy black

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

using Vuforia;







public class MoreVUforiiiiia : MonoBehaviour
{
    #region VUFORIA_STUFF

    VuforiaRenderer.VideoTextureInfo m_VideoTextureInfo;
    bool m_VideoBackgroundReady;
    bool m_ShaderHasBeenSetup;
    bool m_EnableLogging = false;
    Vector2 m_TexureRatio;
    Vector2 m_ViewportSize;
    Vector2 m_ViewportOrig;
    Vector2 m_Prefix;
    Vector2 m_InversionMultiplier;

    public Material m_OcclusionMaterial;

    public Material _AR_Mat_Out;

    void Awake()
    {
        VuforiaRenderer.Instance.SetLegacyRenderingEnabledCondition(()=>true); //Currently post processing effects using the video background texture are only supported by legacy rendering
        // Reset();
    }



    void Start()
    {
        // m_OcclusionMaterial = GetComponent().material;

        VuforiaARController.Instance.RegisterVideoBgConfigChangedCallback(OnVideoBackgroundConfigChanged);
        VuforiaARController.Instance.RegisterBackgroundTextureChangedCallback(OnBackgroundTextureChanged);
    }

    void Update()
    {

      // VuforiaRenderer.VideoTextureInfo videoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo();

        // if (!m_VideoBackgroundReady)
        // {
        //     m_VideoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo();
        //
        //     if (m_EnableLogging)
        //     {
        //         Debug.Log(
        //             "\nBkgdInfoAvail: " + VuforiaRenderer.Instance.IsVideoBackgroundInfoAvailable() +
        //             "\nImageSize: " + m_VideoTextureInfo.imageSize.x + "x" + m_VideoTextureInfo.imageSize.y +
        //             "\nTextureSize: " + m_VideoTextureInfo.textureSize.x + "x" + m_VideoTextureInfo.textureSize.y);
        //     }
        // }
        //
        // if (!m_ShaderHasBeenSetup)
        // {
        //     // Before setting up the shader, code will verify that background info is available
        //     // and that sizes in VideoBGCfgData and VideoTextureInfo are not zero.
        //     // The asynchonous init order may differ between PlayMode and Device.
        //     if (VuforiaRenderer.Instance.IsVideoBackgroundInfoAvailable() &&
        //         m_VideoTextureInfo.imageSize.x > 0 &&
        //         m_VideoTextureInfo.textureSize.x > 0)
        //     {
        //         m_VideoBackgroundReady = true;
        //
        //         m_OcclusionMaterial.mainTexture = VuforiaRenderer.Instance.VideoBackgroundTexture;
        //         // _AR_Mat_Out.mainTexture = VuforiaRenderer.Instance.VideoBackgroundTexture;
        //         // finishMat.SetTexture("_ARVideoFeed", VuforiaRenderer.Instance.VideoBackgroundTexture);
        //         SetViewportParameters();
        //
        //         m_ShaderHasBeenSetup = true;
        //     }
        // }


        // MagicNewUpdates();


    }

    void OnDestroy()
    {
        VuforiaARController.Instance.UnregisterVideoBgConfigChangedCallback(OnVideoBackgroundConfigChanged);
        VuforiaARController.Instance.UnregisterBackgroundTextureChangedCallback(OnBackgroundTextureChanged);
    }


    public void OnVideoBackgroundConfigChanged()
    {
        // If the video background config is changed, recalculate and pass new values to shader
        SetViewportParameters();
    }

    void OnBackgroundTextureChanged()
    {
        // VuforiaRenderer.VideoTextureInfo videoTextureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo();

        // Debug.Log("OnBackgroundTextureChanged() called with:" +
        //           "\nImage Size: " + videoTextureInfo.imageSize.x + "x" + videoTextureInfo.imageSize.y +
        //           "\nTexture Size: " + videoTextureInfo.textureSize.x + "x" + videoTextureInfo.textureSize.y);

        // If the video background texture is changed, reassign to the occlusion material texture
        m_OcclusionMaterial.mainTexture = VuforiaRenderer.Instance.VideoBackgroundTexture;

        // _AR_Mat_Out.mainTexture = VuforiaRenderer.Instance.VideoBackgroundTexture;
        // finishMat.SetTexture("_ARVideoFeed", VuforiaRenderer.Instance.VideoBackgroundTexture);
    }




    void SetViewportParameters()
    {
        // VuforiaRenderer.VideoTextureInfo textureInfo = VuforiaRenderer.Instance.GetVideoTextureInfo();



        // m_OcclusionMaterial.SetFloat("_InversionMultiplierY", m_InversionMultiplier.y);
    }

    #endregion // VUFORIA stuff



}

Log in or register to post comments