Backend rendering of a scene

Hi guys,
I know it’s not a babylon.js question per se so it might not be the perfect place to ask it. anyway hope it’s not against the community rules

I have a 3d online room editor (written in babylonjs) each room is represented by a JSON and an item is a .babylon file (we can also export it in a different format if needed)
Babylon really does the trick when speaking of real-time editing of the scene but we want to export much more realistic 2d images out of those scenes, and I assume it will be easier (and maybe even possible) to do in the backend using different rendering engine that can do ray tracing and other tricks.
I do understand that rendering the scene in such engine will take time (much more time than 60 per second).
Does any of you guys ever done something like it? can you recommend on rendering engines that I can programmatically wrap and generate those images? (no limitation on programming lang) any suggestions will be welcome.


This can be interested to you: Render a Scene and take a screenshot on a remote server - Babylon.js Documentation

Also for our integration tests, we are basically relying on linux xvfb and mozilla which sounds easiy to control from web drivers.

@sebavan thanks :slight_smile: but that’s not exactly what I was looking for, using headless browser with Babylonjs will probably result pretty much the same quality of rendered image, I might be able to use more detailed shadow maps and use better textures, but won’t be able to use ray tracing or something like it.
The thing I want to do is transfer the scene to the backend, render it with a better rendering engine (no offence) and send back a realistic image to the user.

In this case you need to serialize the scene to a format like the .babylon or .gltf one or I do not see how this could work ?

Of curse, what I have right now is a 3d room editor, and I created a data structure that represents this room, I can recreate the scene file in the backend using this data structure the same way I recreate it when a user saves a room, close the page and open his room.
Do you know of any render engine I can use to programmatically render still image?

Maybe an open source ray tracing renderer can do it:

Also, I would be surprised if one could not use Blender as a backend renderer? […] => Command Line Rendering — Blender Manual

1 Like

Thanks a lot I will check them out!
your references got me to GitHub - nmalex/renderfarm.js-server: Three.js ↔ Vray bridge (renderfarm.js backend), do you know of anything like it for Babylon.js?

No, sorry, I don’t know (note also that Vray is not free).

Blender CYCLES

Run the given python script(-P) in background(-b)
blender -b -P

import bpy

IN = "path/to/the/scene.gltf"
OUT = "path/to/the/output/file/excludes/extname"
IMG = (1920, 1080, 50)

def rm():
  for o in bpy.context.scene.objects:
    if o.type == "MESH": 

def imp():

def ren():
  bpy.context.scene.render.filepath = OUT
  bpy.context.scene.render.image_settings.file_format = EXT
  bpy.context.scene.render.engine = "CYCLES"
  bpy.context.scene.cycles.device = "GPU"
  bpy.context.scene.render.resolution_x = IMG[0]
  bpy.context.scene.render.resolution_y = IMG[1]
  bpy.context.scene.render.resolution_percentage = IMG[2]




Thanks a lot guys :slight_smile: