private void OnRenderImage(RenderTexture src, RenderTexture dst) { // Blit to recording frame if (!IsPaused) { var encoderFrame = NatCorder.AcquireFrame(); encoderFrame.timestamp = (long)(Time.realtimeSinceStartup * 1e+9f); Graphics.Blit(src, encoderFrame); NatCorder.CommitFrame(encoderFrame); } // Blit to render pipeline Graphics.Blit(src, dst); }
private void OnRenderImage(RenderTexture src, RenderTexture dst) { // Blit to recording frame bool canRecordFrame = IsRecording && !IsPaused; if (canRecordFrame && (Time.frameCount % frameSkip) == 0) { var encoderFrame = NatCorder.AcquireFrame(); encoderFrame.timestamp = (long)(timestamp * 1e+9f); Graphics.Blit(src, encoderFrame); NatCorder.CommitFrame(encoderFrame); } // Increment timestamp if (canRecordFrame) { timestamp += Time.unscaledDeltaTime; } // Blit to render pipeline Graphics.Blit(src, dst); }
private void OnRenderImage(RenderTexture src, RenderTexture dst) { // Calculate time var frameTime = Frame.CurrentTimestamp; if (!IsPaused) { timestamp += lastTime > 0 ? frameTime - lastTime : 0; } lastTime = frameTime; // Blit to recording frame if (IsRecording && !IsPaused && UnityEngine.Time.frameCount % frameSkip == 0) { var encoderFrame = NatCorder.AcquireFrame(); encoderFrame.timestamp = timestamp; Graphics.Blit(src, encoderFrame, aspectFitter); NatCorder.CommitFrame(encoderFrame); } // Blit to render pipeline Graphics.Blit(src, dst); }