/// <summary> /// Sets up and returns a recursion camera at index i /// </summary> /// <param name="index">index</param> /// <returns></returns> private Camera InstantiateCamera(int index) { GameObject cameraRecursor = new GameObject(); cameraRecursor.transform.SetParent(RenderingCameraParent); cameraRecursor.transform.localPosition = Vector3.zero; cameraRecursor.transform.localRotation = Quaternion.identity; CameraMarker marker = cameraRecursor.AddComponent <CameraMarker>(); marker.Initialize(CameraLib, RenderData.SourceRenderer); Camera camera = cameraRecursor.AddComponent <Camera>(); camera.cullingMask = PrimaryCam.cullingMask; camera.renderingPath = PrimaryCam.renderingPath; camera.stereoTargetEye = PrimaryCam.stereoTargetEye; camera.useOcclusionCulling = PrimaryCam.useOcclusionCulling; camera.depthTextureMode = PrimaryCam.depthTextureMode; camera.enabled = false; camera.ResetProjectionMatrix(); camera.ResetWorldToCameraMatrix(); camera.ResetCullingMatrix(); //camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, invertBuffer); RecursionCams[index] = camera; return(camera); }
/// <summary> /// Instantiate recursion cameras /// </summary> /// <param name="count"></param> private void InstantiateRecursion(int count) { count++; RecursionCams = new Camera[count + 1]; string name = this.name + Random.value; CameraMarker mainMarker = gameObject.AddComponent <CameraMarker>(); mainMarker.Initialize(CameraLib, RenderData.SourceRenderer); for (int i = 1; i < count; i++) { Camera cam = InstantiateCamera(i); cam.name = name + "Recursor " + i; } RecursionCams[0] = PrimaryCam; }