private void Start() { frameWidth = UnityCompositorInterface.GetFrameWidth(); frameHeight = UnityCompositorInterface.GetFrameHeight(); providesYUV = UnityCompositorInterface.ProvidesYUV(); expectsYUV = UnityCompositorInterface.ExpectsYUV(); 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(); }
public static void StoreColorCorrection(string namePrefix, ColorCorrection colorCorrection) { PlayerPrefs.SetInt($"{namePrefix}.{nameof(Enabled)}", colorCorrection.Enabled ? 1 : 0); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(RScale)}", colorCorrection.RScale); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(GScale)}", colorCorrection.GScale); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(BScale)}", colorCorrection.BScale); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(HOffset)}", colorCorrection.HOffset); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(SOffset)}", colorCorrection.SOffset); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(VOffset)}", colorCorrection.VOffset); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(Brightness)}", colorCorrection.Brightness); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(Contrast)}", colorCorrection.Contrast); PlayerPrefs.SetFloat($"{namePrefix}.{nameof(Gamma)}", colorCorrection.Gamma); }
public static ColorCorrection GetColorCorrection(string namePrefix) { ColorCorrection output = new ColorCorrection(false); if (!PlayerPrefs.HasKey($"{namePrefix}.{nameof(Enabled)}")) { return(output); } output.Enabled = PlayerPrefs.GetInt($"{namePrefix}.{nameof(Enabled)}") > 0; output.RScale = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(RScale)}"); output.GScale = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(GScale)}"); output.BScale = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(BScale)}"); output.HOffset = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(HOffset)}"); output.SOffset = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(SOffset)}"); output.VOffset = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(VOffset)}"); output.Brightness = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(Brightness)}"); output.Contrast = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(Contrast)}"); output.Gamma = PlayerPrefs.GetFloat($"{namePrefix}.{nameof(Gamma)}"); return(output); }
private void OnDestroy() { ColorCorrection.StoreColorCorrection(VideoFeedColorCorrectionPlayerPrefName, videoFeedColorCorrection); PlayerPrefs.SetFloat($"{nameof(TextureManager)}.{nameof(blurSize)}", blurSize); PlayerPrefs.SetInt($"{nameof(TextureManager)}.{nameof(numBlurPasses)}", numBlurPasses); }