private void InitializeLocalVolume() { // CustomPassManager is either marked for destruction or wasn't yet spawned - no need for cleanup unlitPass = null; var customPassVolumes = gameObject.GetComponents <CustomPassVolume>(); if (customPassVolumes.Length == 1) { customPassVolumes[0].enabled = true; TryGetLocalUnlitPass(customPassVolumes[0], ref unlitPass); } if (unlitPass == null) { foreach (var pass in customPassVolumes) { CoreUtils.Destroy(pass); } var unlitVolume = gameObject.AddComponent <CustomPassVolume>(); unlitVolume.injectionPoint = UnlitInjectionPoint; unlitVolume.AddPassOfType(typeof(PointCloudRenderPass)); TryGetLocalUnlitPass(unlitVolume, ref unlitPass); } if (unlitPass == null) { Debug.LogWarning("Unable to initialize custom pass volumes for point clouds."); } RefreshRenderers(); }
private IEnumerator MigrateToGlobalVolumeCoroutine() { while (!SimulatorManager.InstanceAvailable) { yield return(null); } // Disable all local volumes, add passes to global ones var localVolumes = gameObject.GetComponents <CustomPassVolume>(); if (localVolumes != null) { foreach (var localVolume in localVolumes) { localVolume.enabled = false; } } var customPassManager = SimulatorManager.Instance.CustomPassManager; unlitPass = customPassManager.AddPass <PointCloudRenderPass>(UnlitInjectionPoint, -200); litPass = customPassManager.AddPass <PointCloudRenderPass>(LitInjectionPoint, -200, CustomPass.TargetBuffer.None); RefreshRenderers(); }
private static bool TryGetLocalUnlitPass(CustomPassVolume volume, ref PointCloudRenderPass pass) { if (volume.injectionPoint != UnlitInjectionPoint || volume.customPasses.Count != 1 || !(volume.customPasses[0] is PointCloudRenderPass p)) { return(false); } pass = p; pass.targetColorBuffer = CustomPass.TargetBuffer.Camera; pass.targetDepthBuffer = CustomPass.TargetBuffer.Camera; return(true); }
private static bool TryGetLitPass(CustomPassVolume volume, ref PointCloudRenderPass pass) { if (volume.injectionPoint != LitInjectionPoint || volume.customPasses.Count != 1 || !(volume.customPasses[0] is PointCloudRenderPass p)) { return(false); } pass = p; // Don't bind camera color buffer when using lighting - it's going to use GBuffer instead anyway pass.targetColorBuffer = CustomPass.TargetBuffer.None; pass.targetDepthBuffer = CustomPass.TargetBuffer.Camera; return(true); }
private void InitializeCustomPassVolumes() { litPass = null; unlitPass = null; var customPassVolumes = gameObject.GetComponents <CustomPassVolume>(); if (customPassVolumes.Length == 2) { for (var i = 0; i < 2; ++i) { if (TryGetUnlitPass(customPassVolumes[i], ref unlitPass)) { continue; } TryGetLitPass(customPassVolumes[i], ref litPass); } } if (litPass == null || unlitPass == null) { foreach (var pass in customPassVolumes) { CoreUtils.Destroy(pass); } var unlitVolume = gameObject.AddComponent <CustomPassVolume>(); unlitVolume.injectionPoint = UnlitInjectionPoint; unlitVolume.AddPassOfType(typeof(PointCloudRenderPass)); TryGetUnlitPass(unlitVolume, ref unlitPass); var litVolume = gameObject.AddComponent <CustomPassVolume>(); litVolume.injectionPoint = LitInjectionPoint; litVolume.AddPassOfType(typeof(PointCloudRenderPass)); TryGetLitPass(litVolume, ref litPass); } if (litPass == null || unlitPass == null) { Debug.LogError("Unable to initialize custom pass volumes for point clouds."); } }