private void Start() { frameWidth = UnityCompositorInterface.GetFrameWidth(); frameHeight = UnityCompositorInterface.GetFrameHeight(); outputYUV = UnityCompositorInterface.OutputYUV(); renderEvent = UnityCompositorInterface.GetRenderEventFunc(); hardwareEncodeVideo = UnityCompositorInterface.HardwareEncodeVideo(); downsampleMat = LoadMaterial("Downsample"); YUVToRGBMat = LoadMaterial("YUVToRGB"); RGBToYUVMat = LoadMaterial("RGBToYUV"); BGRToRGBMat = LoadMaterial("BGRToRGB"); RGBToBGRMat = LoadMaterial("BGRToRGB"); NV12VideoMat = LoadMaterial("RGBToNV12"); BGRVideoMat = LoadMaterial("BGRToRGB"); holoAlphaMat = LoadMaterial("HoloAlpha"); extractAlphaMat = LoadMaterial("ExtractAlpha"); ignoreAlphaMat = LoadMaterial("IgnoreAlpha"); quadViewMat = LoadMaterial("QuadView"); alphaBlendMat = LoadMaterial("AlphaBlend"); textureClearMat = LoadMaterial("TextureClear"); SetHologramShaderAlpha(Compositor.DefaultAlpha); CreateColorTexture(); CreateOutputTextures(); SetupCameraAndRenderTextures(); SetShaderValues(); SetOutputTextures(); }
private void Update() { // this updates after we start running or when the video source changes, so we need to check every frame bool newOutputYUV = UnityCompositorInterface.OutputYUV(); if (outputYUV != newOutputYUV) { outputYUV = newOutputYUV; } }
private void Start() { frameWidth = UnityCompositorInterface.GetFrameWidth(); frameHeight = UnityCompositorInterface.GetFrameHeight(); outputYUV = UnityCompositorInterface.OutputYUV(); renderEvent = UnityCompositorInterface.GetRenderEventFunc(); hardwareEncodeVideo = UnityCompositorInterface.HardwareEncodeVideo(); downsampleMat = LoadMaterial("Downsample"); YUVToRGBMat = LoadMaterial("YUVToRGB"); RGBToYUVMat = LoadMaterial("RGBToYUV"); BGRToRGBMat = LoadMaterial("BGRToRGB"); RGBToBGRMat = LoadMaterial("BGRToRGB"); NV12VideoMat = LoadMaterial("RGBToNV12"); BGRVideoMat = LoadMaterial("BGRToRGB"); holoAlphaMat = LoadMaterial("HoloAlpha"); blurMat = LoadMaterial("Blur"); occlusionMaskMat = LoadMaterial("OcclusionMask"); extractAlphaMat = LoadMaterial("ExtractAlpha"); ignoreAlphaMat = LoadMaterial("IgnoreAlpha"); quadViewMat = LoadMaterial("QuadView"); alphaBlendMat = LoadMaterial("AlphaBlend"); textureClearMat = LoadMaterial("TextureClear"); colorCorrectionMat = LoadMaterial("ColorCorrection"); videoFeedColorCorrection = ColorCorrection.GetColorCorrection(VideoFeedColorCorrectionPlayerPrefName); blurSize = PlayerPrefs.GetFloat($"{nameof(TextureManager)}.{nameof(blurSize)}", 5); numBlurPasses = PlayerPrefs.GetInt($"{nameof(TextureManager)}.{nameof(numBlurPasses)}", 1); SetHologramShaderAlpha(Compositor.DefaultAlpha); CreateColorTexture(); if (Compositor.OcclusionMode == OcclusionSetting.RawDepthCamera) { CreateDepthCameraTexture(); } else if (Compositor.OcclusionMode == OcclusionSetting.BodyTracking) { CreateDepthCameraTexture(); CreateBodyDepthTexture(); } CreateOutputTextures(); SetupCameraAndRenderTextures(); SetShaderValues(); SetOutputTextures(); }