- Home /
Rendering to file in batchmode?
We're trying to write a server-side app in Unity Pro. Part of its function is to generate images and serve them to a browser. This works fine if the app is started the regular, windowed way. Ideally, we'd like the app to run headless. The problem is, as far as I understand, Unity's "-batchmode" flag disables the rendering pipeline completely.
Is there a way to run Unity in headless mode whilst retaining its rendering capabilities?
Answer by Vectrex · Jun 09, 2010 at 01:45 AM
Perhaps this commandline might work? It's the reference DX renderer which MIGHT work without a gpu since it's pure cpu, although I doubt it :)
"-force-d3d9-ref (Windows only) Make the game run using Direct3D's "Reference" software renderer. DirectX SDK has to be installed for this to work. This is mostly useful for building automated test suites, where you want to ensure rendering is exactly the same no matter what's the graphics card."
Answer by vade · Apr 06, 2012 at 01:54 AM
This totally works, however I found you have to ensure you are using a forward renderer, and force the camera to render prior to running a screen capture.
Something like:
....
camera.Render();
screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
....
Does this work for rendering in EC2, where there's no GPU?
Hi @vade, did you ever manage to get this working? I saw your other question on this topic. I am trying to do exactly the same thing. Are you able to point me in the direction of a working exampl e solution? Best regards, Ben
Answer by qJake · Jun 08, 2010 at 11:02 PM
I don't believe it's possible to run a standalone player in batch mode without automatically disabling the rendering. As per the documentation:
-batchmode
Run the game in "headless" mode. The game will not display anything and won't accept user input. This is mostly useful for running servers of networked games.
Looks like you're going to either have to think up another solution, or run the game normally unfortunately.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
running servers for networked games 0 Answers
Run Unity Pro in "Indie Mode"? 1 Answer
Unity online send a message out of unity to server 1 Answer
Remote access of Unity Asset Server? 3 Answers