public void OnEnable() { Color clearColor = new Color(0f, 0f, 0f, 0f); //Set up catch cameras. runtimeDatasMap.Clear(); foreach (var pair in lightLayerMap) { var runtimeData = new LayerRuntimeData(); var go = GoUtils.AddAnEmptyGameObject("Catch " + pair.Key, transform); var camera = CameraUtils.AddRenderCamera(go, pair.Value.catchLayer); camera.depth = -2; camera.backgroundColor = clearColor; runtimeData.catchCamera = camera; runtimeData.catchTexture = ScreenTextureAllocator.generateRenderTexture(); runtimeData.catchCamera.targetTexture = runtimeData.catchTexture; StartCoroutine(UpdateRuntimeData(runtimeData)); runtimeDatasMap.Add(pair.Key, runtimeData); } MixEffect.SetLightMixShader(LightMixMesh); MixEffect.SetScreenMixShader(ScreenMix); BlurEffect.SetShader(BlurShader); finalTexture = ScreenTextureAllocator.generateRenderTexture(); layers = new List <string>(lightLayerMap.Keys); layers.Sort((ll, rl) => lightLayerMap[ll].depth.CompareTo(lightLayerMap[rl].depth)); originMainCameraCullingMask = Camera.main.cullingMask; Camera.main.cullingMask = finalTexLayerMask; }