void OnRenderImage(RenderTexture source, RenderTexture destination) { if (_pipe != null && _recorderState == RecorderState.RECORDING) { var tempRT = RenderTexture.GetTemporary(source.width, source.height); if (_material != null) { Graphics.Blit(source, tempRT, _material, 0); } else { Debug.LogWarning("Material for the recorder is null, fix this!"); } var tempTex = new Texture2D(source.width, source.height, TextureFormat.RGB24, false); tempTex.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0, false); tempTex.Apply(); // With the winter 2017 release of this plugin, Pupil timestamp is set to Unity time when connecting timeStampList.AddRange(System.BitConverter.GetBytes(Time.time)); _pipe.Write(tempTex.GetRawTextureData()); Destroy(tempTex); RenderTexture.ReleaseTemporary(tempRT); } Graphics.Blit(source, destination); }
void RecorderThreadMethod() { renderPipeQueue.Clear(); while (true) { Thread.Sleep(1); if (renderPipeQueue.Count > 0) { _pipe.Write(renderPipeQueue [0]); writtenFrameCount++; renderPipeQueue.RemoveAt(0); // print ("writing data. Remaining : " + renderPipeQueue.Count); } else { if (_recorderState == RecorderState.PROCESSING) { Recorder.isProcessing = false; _recorderState = RecorderState.STOPPING; RecorderThread.Join(); } } } }
void OnRenderImage(RenderTexture source, RenderTexture destination) { if (_pipe != null) { _startTime = Mathf.Max(_startTime, 0); _recordLength = Mathf.Max(_recordLength, 0.01f); if (!_anim.isPlaying) { return; } // HACK First frame is from last animation. Skip. if (_firstFrame) { _firstFrame = false; return; } var tempRT = RenderTexture.GetTemporary(source.width, source.height); Graphics.Blit(source, tempRT, _material, 0); var tempTex = new Texture2D(source.width, source.height, TextureFormat.RGB24, false); tempTex.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0, false); tempTex.Apply(); _pipe.Write(tempTex.GetRawTextureData()); Destroy(tempTex); RenderTexture.ReleaseTemporary(tempRT); } Graphics.Blit(source, destination); }
void RecorderThreadMethod() { while (true) { Thread.Sleep(10); if (renderPipeQueue.Count > 0) { _pipe.Write(renderPipeQueue [0]); renderPipeQueue.RemoveAt(0); } } }
void OnRenderImage(RenderTexture source, RenderTexture destination) { if (_pipe != null) { var tempRT = RenderTexture.GetTemporary(source.width, source.height); Graphics.Blit(source, tempRT, _material, 0); var tempTex = new Texture2D(source.width, source.height, TextureFormat.RGBA32, false); tempTex.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0, false); tempTex.Apply(); _pipe.Write(tempTex.GetRawTextureData()); Destroy(tempTex); RenderTexture.ReleaseTemporary(tempRT); } Graphics.Blit(source, destination); }
void OnRenderImage(RenderTexture source, RenderTexture destination) { if (_pipe == null) { return; } if (_useCustomTexture) { source = _renderTexture; } var tempRT = RenderTexture.GetTemporary(source.width, source.height); Graphics.Blit(source, tempRT, _material, 0); var tempTex = new Texture2D(source.width, source.height, TextureFormat.RGBA32, false); if (_useCustomTexture) { Graphics.CopyTexture(tempRT, tempTex); } else { tempTex.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0, false); } tempTex.Apply(); _pipe.Write(tempTex.GetRawTextureData()); Destroy(tempTex); RenderTexture.ReleaseTemporary(tempRT); Graphics.Blit(source, destination); }