- Home /
Render to a file in batch mode
In my project I am rendering each frame to images. This is the code snippet:
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Debug.Log("ON RENDER IMAGE");
Texture2D texture = new Texture2D(Screen.width, Screen.height,
GraphicsFormat.R8G8B8A8_SRGB, TextureCreationFlags.None);
texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0,
false);
texture.Apply();
string path = outputPath + "Frame" + frameNumber;
byte[] buffer = texture.GetRawTextureData();
File.WriteAllBytes(path, buffer);
UnityEngine.Object.DestroyImmediate(texture);
Graphics.Blit(source, destination);
}
It works fine in the stand alone player, but I couldn't find a way to make it work in batch mode. I tried to use the OnPostRender function as well with no success.
command line call: .\RenderFrames.exe -batchmode -logfile output.txt
I think neither of those routines get called in batchmode, because I don't see my log there. Is there a way to render to a file in batch mode? Thanks,
Your answer
Follow this Question
Related Questions
Best way to convert particles and sprites in a single sprite at runTime 1 Answer
dynamic hole in layer / texture / camera 0 Answers
Render a camera multiple times in a single frame? 1 Answer
Render Single Camera to Two Displays 0 Answers
Masking elements with non-rendered layers? Culling masks, camera, render textures 0 Answers