private static void ApplyPostFX(CinemachineBrain brain) { PostProcessLayer component = brain.GetComponent <PostProcessLayer>(); if (component == null || !component.enabled || component.volumeLayer == 0) { return; } CameraState currentCameraState = brain.CurrentCameraState; int numCustomBlendables = currentCameraState.NumCustomBlendables; List <PostProcessVolume> dynamicBrainVolumes = CinemachinePostProcessing.GetDynamicBrainVolumes(brain, component, numCustomBlendables); for (int i = 0; i < dynamicBrainVolumes.Count; i++) { dynamicBrainVolumes[i].weight = 0f; dynamicBrainVolumes[i].sharedProfile = null; dynamicBrainVolumes[i].profile = null; } for (int j = 0; j < numCustomBlendables; j++) { CameraState.CustomBlendable customBlendable = currentCameraState.GetCustomBlendable(j); CinemachinePostProcessing cinemachinePostProcessing = customBlendable.m_Custom as CinemachinePostProcessing; if (!(cinemachinePostProcessing == null)) { PostProcessVolume postProcessVolume = dynamicBrainVolumes[j]; postProcessVolume.sharedProfile = cinemachinePostProcessing.Profile; postProcessVolume.isGlobal = true; postProcessVolume.priority = float.MaxValue; postProcessVolume.weight = customBlendable.m_Weight; } } }
static void ApplyPostFX(CinemachineBrain brain) { //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX"); PostProcessLayer ppLayer = brain.GetComponent <PostProcessLayer>(); if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0) { return; } CameraState state = brain.CurrentCameraState; int numBlendables = state.NumCustomBlendables; List <PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables); for (int i = 0; i < volumes.Count; ++i) { volumes[i].weight = 0; volumes[i].sharedProfile = null; volumes[i].profile = null; } for (int i = 0; i < numBlendables; ++i) { var b = state.GetCustomBlendable(i); CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing; if (!(src == null)) // in case it was deleted { PostProcessVolume v = volumes[i]; v.sharedProfile = src.Profile; v.isGlobal = true; v.priority = float.MaxValue - 1; v.weight = b.m_Weight; } } //UnityEngine.Profiling.Profiler.EndSample(); }
static void ApplyPostFX(CinemachineBrain brain) { //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX"); PostProcessLayer ppLayer = brain.PostProcessingComponent as PostProcessLayer; if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0) { return; } CameraState state = brain.CurrentCameraState; int numBlendables = state.NumCustomBlendables; List <PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables); for (int i = 0; i < volumes.Count; ++i) { volumes[i].weight = 0; volumes[i].sharedProfile = null; volumes[i].profile = null; } PostProcessVolume firstVolume = null; int numPPblendables = 0; for (int i = 0; i < numBlendables; ++i) { var b = state.GetCustomBlendable(i); CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing; if (!(src == null)) // in case it was deleted { PostProcessVolume v = volumes[i]; if (firstVolume == null) { firstVolume = v; } v.sharedProfile = src.Profile; v.isGlobal = true; v.priority = float.MaxValue - (numBlendables - i) - 1; v.weight = b.m_Weight; ++numPPblendables; } #if true // set this to true to force first weight to 1 // If more than one volume, then set the frst one's weight to 1 if (numPPblendables > 1) { firstVolume.weight = 1; } #endif } //UnityEngine.Profiling.Profiler.EndSample(); }
static void ApplyPostFX(CinemachineBrain brain) { CameraState state = brain.CurrentCameraState; int numBlendables = state.NumCustomBlendables; var volumes = GetDynamicBrainVolumes(brain, numBlendables); for (int i = 0; i < volumes.Count; ++i) { volumes[i].weight = 0; volumes[i].sharedProfile = null; volumes[i].profile = null; } Volume firstVolume = null; int numPPblendables = 0; for (int i = 0; i < numBlendables; ++i) { var b = state.GetCustomBlendable(i); CinemachineVolumeSettings src = b.m_Custom as CinemachineVolumeSettings; if (!(src == null)) // in case it was deleted { var v = volumes[i]; if (firstVolume == null) { firstVolume = v; } v.sharedProfile = src.Profile; v.isGlobal = true; v.priority = float.MaxValue - (numBlendables - i) - 1; v.weight = b.m_Weight; ++numPPblendables; } #if true // set this to true to force first weight to 1 // If more than one volume, then set the frst one's weight to 1 if (numPPblendables > 1) { firstVolume.weight = 1; } #endif } }