public void Init() { switch (captureType) { case CaptureType.Capture: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.sRGB; rtDepth = 24; break; case CaptureType.Segmentation: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.sRGB; rtDepth = 24; break; case CaptureType.Depth: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.Linear; rtDepth = 24; break; default: break; } switch (resolutionType) { case ResolutionType.SD: videoWidth = 640; videoHeight = 480; break; case ResolutionType.HD: videoWidth = 1920; videoHeight = 1080; break; default: break; } RenderTexture activeRT = new RenderTexture(videoWidth, videoHeight, rtDepth, rtFormat, rtReadWrite) { dimension = UnityEngine.Rendering.TextureDimension.Tex2D, antiAliasing = 1, useMipMap = false, useDynamicScale = false, wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear }; activeRT.name = captureType.ToString() + resolutionType.ToString(); activeRT.Create(); renderCam = GetComponent <Camera>(); renderCam.targetTexture = activeRT; Reader = new AsyncTextureReader <byte>(renderCam.targetTexture); GetComponentInParent <CameraSettingsManager>().AddCamera(renderCam); // TODO better way if (sensorName == "Main Camera") { GetComponentInParent <AgentSetup>().MainCam = renderCam; } addUIElement(); }
public void Init() { switch (captureType) { case CaptureType.Capture: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.sRGB; rtDepth = 24; break; case CaptureType.Segmentation: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.sRGB; rtDepth = 24; break; case CaptureType.Depth: rtFormat = RenderTextureFormat.ARGB32; rtReadWrite = RenderTextureReadWrite.Linear; rtDepth = 24; break; default: break; } switch (resolutionType) { case ResolutionType.SD: videoWidth = 640; videoHeight = 480; break; case ResolutionType.HD: videoWidth = 1920; videoHeight = 1080; break; default: break; } RenderTexture activeRT = new RenderTexture(videoWidth, videoHeight, rtDepth, rtFormat, rtReadWrite) { dimension = UnityEngine.Rendering.TextureDimension.Tex2D, antiAliasing = 1, useMipMap = false, useDynamicScale = false, wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear }; activeRT.name = captureType.ToString() + resolutionType.ToString(); activeRT.Create(); renderCam = GetComponent <Camera>(); renderCam.targetTexture = activeRT; if (captureType == CaptureType.Segmentation) { SegmentColorer segColorer = FindObjectOfType <SegmentColorer>(); if (segColorer != null) { renderCam.SetReplacementShader(segColorer.Shader, "SegmentColor"); // TODO needs to be local ref or manager? renderCam.backgroundColor = segColorer.SkyColor; // TODO needs to be local ref or manager? renderCam.clearFlags = CameraClearFlags.SolidColor; renderCam.renderingPath = RenderingPath.Forward; } } Reader = new AsyncTextureReader <byte>(renderCam.targetTexture); GetComponentInParent <CameraSettingsManager>().AddCamera(renderCam); // TODO better way if (sensorName == "Main Camera") { GetComponentInParent <RobotSetup>().MainCam = renderCam; } addUIElement(); }