Как я могу сделать автономный регистратор последовательности PNG на скорости 60 кадров в секунду? - PullRequest
0 голосов
/ 10 марта 2019

Я хочу захватить последовательность изображений, 60 кадров в секунду, 4k, камеры Unity в режиме реального времени (в автономном режиме).

Пока я могу успешно захватывать каждый кадр, но я не могу понять, как сделать его в автономном режиме и соответствовать 60 кадрам в секунду.

Я снимаю кадры следующим образом:

            // get main camera and manually render scene into rt
            Camera camera = this.GetComponent<Camera>(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera
            camera.targetTexture = renderTexture;
            camera.Render();
            this.lastRenderTime = Time.realtimeSinceStartup;

            // read pixels will read from the currently active render texture so make our offscreen 
            // render texture active and then read the pixels
            RenderTexture.active = renderTexture;
            screenShot.ReadPixels(rect, 0, 0);

            // reset active camera texture and render texture
            camera.targetTexture = null;
            RenderTexture.active = null;

            // get our unique filename
            string filename = uniqueFilename((int)rect.width, (int)rect.height);

            // pull in our file header/data bytes for the specified image format (has to be done from main thread)
            byte[] fileHeader = null;
            byte[] fileData = null;

 // create new thread to save the image to file (only operation that can be done in background)
            new System.Threading.Thread(() =>
            {
                // create file and write optional header with image bytes
                var f = System.IO.File.Create(filename);
                if (fileHeader != null) f.Write(fileHeader, 0, fileHeader.Length);
                f.Write(fileData, 0, fileData.Length);
                f.Close();
                Debug.Log(string.Format("Wrote screenshot {0} of size {1}", filename, fileData.Length));
            }).Start();

Может ли кто-нибудь указать мне правильное направление?

1 Ответ

1 голос
/ 10 марта 2019

В настройки времени , установите для всех временных шагов значение 1/60 (приблизительно 0,01666667)

Затем снимите экран в событии OnPostRender.

timesettngs

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...