void SetTexture(PanoramicCamera.TSubCamera camera) { var renderTexture = linkedLidar.GetTexture(camera); if (renderTexture == null) { // front is always active and compute shader will fail if any of them is null (even if not used) renderTexture = linkedLidar.GetTexture(PanoramicCamera.TSubCamera.Front); } exportShader.SetTexture(0, "_" + camera, renderTexture); }
/// <summary> /// Gets a subcamera texture /// </summary> /// <param name="camera">Subcamera direction</param> /// <returns>Subcamera's render texture</returns> public RenderTexture GetTexture(PanoramicCamera.TSubCamera camera) { return(subCameras[(int)camera].linkedCamera.targetTexture); }
void RefreshSubCamera(PanoramicCamera.TSubCamera subCamera) { SingleTrueDepthCamera depthCamera = subCameras[(int)subCamera]; Camera camera = depthCamera.linkedCamera; GameObject cameraGameObject = camera.gameObject; #if DEBUG_LIDAR camera.gameObject.hideFlags &= ~HideFlags.HideInHierarchy; #else camera.gameObject.hideFlags |= HideFlags.HideInHierarchy; #endif if (!enabled) { cameraGameObject.SetActive(false); return; } switch (subCamera) { case PanoramicCamera.TSubCamera.Left: cameraGameObject.SetActive(_horizontalFieldOfView >= 90f); break; case PanoramicCamera.TSubCamera.Right: cameraGameObject.SetActive(_horizontalFieldOfView >= 90f); break; case PanoramicCamera.TSubCamera.Back: cameraGameObject.SetActive(_horizontalFieldOfView >= 270f); break; case PanoramicCamera.TSubCamera.Top: cameraGameObject.SetActive(_verticalFieldOfView >= 68f); break; case PanoramicCamera.TSubCamera.Bottom: cameraGameObject.SetActive(_verticalFieldOfView >= 68f); break; case PanoramicCamera.TSubCamera.Front: default: cameraGameObject.SetActive(true); break; } if (camera.gameObject.activeInHierarchy) { var targetDimensions = new Vector2Int( Mathf.CeilToInt(subCameraResolution.x), Mathf.CeilToInt(subCameraResolution.y)); if (camera.targetTexture) { if (camera.targetTexture.width != targetDimensions.x || camera.targetTexture.height != targetDimensions.y) { var rt = camera.targetTexture; camera.targetTexture = null; rt.Release(); DestroyImmediate(rt); } } if (camera.targetTexture == null) { RenderTexture texture = new RenderTexture( targetDimensions.x, targetDimensions.y, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear) { filterMode = FilterMode.Point, wrapMode = TextureWrapMode.Clamp, anisoLevel = 0 }; texture.Create(); camera.targetTexture = texture; } } else { if (camera.targetTexture != null) { var rt = camera.targetTexture; camera.targetTexture = null; rt.Release(); DestroyImmediate(rt); } } camera.cullingMask = cullingMask; camera.nearClipPlane = nearClipPlane; camera.farClipPlane = farClipPlane; camera.depth = 0; camera.renderingPath = RenderingPath.Forward; camera.useOcclusionCulling = false; camera.allowHDR = true; camera.allowMSAA = false; camera.fieldOfView = 90f; camera.aspect = 1; camera.layerCullSpherical = true; depthCamera.noiseGenerator = noiseGenerator; }