<p>I'm working on an application that needs to quickly render simple 3D scenes on the server, and then return them as a JPEG via HTTP. Basically, I want to be able to simply include a dynamic 3D scene in an HTML page, by doing something like:</p>

<pre><code>&lt;img src="http://www.myserver.com/renderimage?scene=1&amp;x=123&amp;y=123&amp;z=123"&gt;
</code></pre>

<p>My question is about what technologies to use to do the rendering. In a desktop application I would quite naturally use DirectX, but I'm afraid it might not be ideal for a server-side application that would be creating images for dozens or even hundreds of users in tandem. Does anyone have any experience with this? Is there a 3D API (preferably freely available) that would be ideal for this application? Is it better to write a software renderer from scratch?</p>

<p>My main concerns about using DirectX or OpenGL, is whether it will function well in a virtualized server environment, and whether it makes sense with typical server hardware (over which I have little control). </p>

[{'answer_id': 64315, 'author': 'Fire Lancer', 'author_id': 6266, 'author_profile': 'https://Stackoverflow.com/users/6266', 'pm_score': 2, 'selected': False, 'text': "<p>Id say your best bet is have a Direct3D/OpenGL app running on the server (without stopping). THen making the server page send a request to the rendering app, and have the rendering app snend a jpg/png/whatever back.</p>\n\n<ul>\n<li>If Direct3D/OpenGL is to slow to render the scene in hardware, then any software solution will be worse</li>\n<li>By keep the rendering app running, you are avoiding the overhead of creating/destroying textures, backbuffers, vertex buffers, etc. You could potentialy render a simply scene 100's of times a second.</li>\n</ul>\n\n<p>However many servers do not have graphics cards. Direct3D is largly useless in software (there is an emulated device from Ms, but its only good for testing effects), never tried OpenGL in software.</p>\n"}, {'answer_id': 64409, 'author': 'epatel', 'author_id': 842, 'author_profile': 'https://Stackoverflow.com/users/842', 'pm_score': 0, 'selected': False, 'text': '<p>Not so much an API but rather a renderer; <a href="http://www.povray.org/" rel="nofollow noreferrer">Povray</a>? There also seem to exist a <a href="http://columbiegg.com/httpov/" rel="nofollow noreferrer">http</a> interface...</p>\n'}, {'answer_id': 64421, 'author': 'Skizz', 'author_id': 1898, 'author_profile': 'https://Stackoverflow.com/users/1898', 'pm_score': 1, 'selected': False, 'text': '<p>Server side rendering only makes sense if the scene consists of a huge number of objects such that the download of the data set to the client for client rendering would be far too slow and the rendering is not expected to be in realtime. Client side rendering isn\'t too difficult if you use something like <a href="https://jogl.dev.java.net/" rel="nofollow noreferrer">jogl</a> coupled with progressive scene download (i.e. download foreground objects and render, then incrementally download objects based on distance from view point and re-render).</p>\n\n<p>If you really want to do server side rendering, you may want to separate the web server part and the rendering part onto two computers with each configured optimally for their task (renderer has OpenGL card, minimal HD and just enough RAM, server has lots of fast disks, lots of ram, backups and no OpenGL). I very much doubt you will be able to do hardware rendering on a virtualised server since the server probably doesn\'t have a GPU.</p>\n'}, {'answer_id': 69035, 'author': 'DarenW', 'author_id': 10468, 'author_profile': 'https://Stackoverflow.com/users/10468', 'pm_score': 0, 'selected': False, 'text': '<p>Yafaray (<a href="http://www.yafaray.org/" rel="nofollow noreferrer">http://www.yafaray.org/</a>)  might be a good first choice to consider for general 3D rendering.  It\'s reasonably fast and the results look great.  It can be used within other software, e.g. the Blender 3D modeler. The license is LPGL.</p>\n\n<p>If the server-side software happens to be written in Python, and the desired 3D scene is a visualization of scientific data, look into MayaVi2 <a href="http://mayavi.sourceforge.net/" rel="nofollow noreferrer">http://mayavi.sourceforge.net/</a>, or if not, go for a browse at <a href="http://www.vrplumber.com/py3d.py" rel="nofollow noreferrer">http://www.vrplumber.com/py3d.py</a></p>\n\n<p>Those who suggest the widely popular POV-Ray need to realize it\'s not a library or any kind of entity that offers an API.  The server-side process would need to write a text scene file, execute a new process to run POV-Ray with the right options, and take the resulting image file.   If that\'s easy to set up for a particular application, and if you\'ve more expertise with POV-Ray than with other renderers, well go for it!</p>\n'}, {'answer_id': 124881, 'author': 'AndrewR', 'author_id': 2994, 'author_profile': 'https://Stackoverflow.com/users/2994', 'pm_score': 0, 'selected': False, 'text': '<p>You could also look at Java3D (<a href="https://java3d.dev.java.net/" rel="nofollow noreferrer">https://java3d.dev.java.net/</a>), which would be an elegant solution if your server architecture was Java-based already.</p>\n\n<p>I\'d also recommend trying to get away with a software-only rendering solution if you can - trying to wrangle a whole lot of server processes that are all making concurrent demands on the 3D rendering hardware sounds like a lot of work.</p>\n'}, {'answer_id': 1266970, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': True, 'text': '<p>RealityServer by mental images is designed to do precisely what is described here. More details are available on the product page (including a downloadable Developer Edition).</p>\n\n<p><a href="http://www.migenius.com/doc/realityserver/latest/" rel="nofollow noreferrer">RealityServer docs</a></p>\n'}, {'answer_id': 12820722, 'author': 'Janus Troelsen', 'author_id': 309483, 'author_profile': 'https://Stackoverflow.com/users/309483', 'pm_score': 2, 'selected': False, 'text': '<p>You could wrap Pov-ray (here using POSIX and the Windows build). PHP example:</p>\n\n<pre class="lang-php prettyprint-override"><code>&lt;?php\nchdir("/tmp");\n@unlink("demo.png");\nsystem("~janus/.wine/drive_c/POV-Ray-v3.7-RC6/bin/pvengine-sse2.exe /render demo.pov /exit");\nheader("Content-type: image/png");\nfpassthru($f = fopen("demo.png","r"));\nfclose($f);\n?&gt;\n</code></pre>\n\n<p><code>demo.pov</code> available <a href="http://www.csb.yale.edu/userguides/graphics/povray/demo.pov.html" rel="nofollow">here</a>.</p>\n\n<p>You could use a templating language like Jinja2 to insert your own camera coordinates.</p>\n'}, {'answer_id': 19776439, 'author': 'Magdalena', 'author_id': 2953969, 'author_profile': 'https://Stackoverflow.com/users/2953969', 'pm_score': -1, 'selected': False, 'text': '<p>Check out <a href="http://www.wgpu.net" rel="nofollow">wgpu.net</a>.</p>\n\n<p>I think it\'s very helpful.</p>\n'}]
['https://Stackoverflow.com/questions/64291', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8409/']