# Backend rendering of a scene

**URL:** <https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156>\
**Category:** Questions\
**Created:** [May 26, 2020, 4:14pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156 "2020-05-26T16:14:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kutomer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kutomer/32/55_2.png) [@kutomer](https://forum.babylonjs.com/u/kutomer)\
**Post date:** [May 26, 2020, 4:14pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/1 "2020-05-26T16:14:39Z")

</div>

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.

Tomer.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 27, 2020, 12:35pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/2 "2020-05-27T12:35:19Z")

</div>

This can be interested to you: [Render a Scene and take a screenshot on a remote server - Babylon.js Documentation](https://doc.babylonjs.com/how_to/render_scene_on_a_server)

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

---

<div class="post-metadata">

**Author:** ![kutomer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kutomer/32/55_2.png) [@kutomer](https://forum.babylonjs.com/u/kutomer)\
**Post date:** [May 27, 2020, 4:06pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/3 "2020-05-27T16:06:18Z")

</div>

@sebavan thanks 🙂 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.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 27, 2020, 4:08pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/4 "2020-05-27T16:08:48Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![kutomer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kutomer/32/55_2.png) [@kutomer](https://forum.babylonjs.com/u/kutomer)\
**Post date:** [May 27, 2020, 4:16pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/5 "2020-05-27T16:16:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2020, 4:25pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/6 "2020-05-27T16:25:37Z")

</div>

Maybe an open source ray tracing renderer can do it:

- PBRT: [GitHub - mmp/pbrt-v3: Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.](https://github.com/mmp/pbrt-v3)
- Mitsuba: [https://www.mitsuba-renderer.org/](https://www.mitsuba-renderer.org/)
- Pov-ray: [http://www.povray.org/](http://www.povray.org/)
- and many more

Also, I would be surprised if one could not use Blender as a backend renderer? […] =\> [Command Line Rendering — Blender Manual](https://docs.blender.org/manual/en/latest/advanced/command_line/render.html)

---

<div class="post-metadata">

**Author:** ![kutomer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kutomer/32/55_2.png) [@kutomer](https://forum.babylonjs.com/u/kutomer)\
**Post date:** [May 27, 2020, 6:06pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/7 "2020-05-27T18:06:43Z")

</div>

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)](https://github.com/nmalex/renderfarm.js-server), do you know of anything like it for Babylon.js?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 27, 2020, 6:13pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/8 "2020-05-27T18:13:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ycw](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ycw/32/4315_2.png) [@ycw](https://forum.babylonjs.com/u/ycw)\
**Post date:** [May 28, 2020, 7:24am UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/9 "2020-05-28T07:24:59Z")

</div>

Blender CYCLES

Run the given python script(-P) in background(-b)  
`blender -b -P a.py`

a.py

```auto
import bpy

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

def rm():
  for o in bpy.context.scene.objects:
    if o.type == "MESH": 
      o.select_set(True)
    else:
      o.select_set(False)
  bpy.ops.object.delete()

def imp():
  bpy.ops.import_scene.gltf(filepath=IN)

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]
  bpy.ops.render.render(write_still=True)

rm()
imp()
ren()

```

👋

---

<div class="post-metadata">

**Author:** ![kutomer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kutomer/32/55_2.png) [@kutomer](https://forum.babylonjs.com/u/kutomer)\
**Post date:** [May 28, 2020, 10:01am UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/10 "2020-05-28T10:01:29Z")

</div>

Thanks a lot guys 🙂

---

<div class="post-metadata">

**Author:** ![fedkaa](https://avatars.discourse-cdn.com/v4/letter/f/b9bd4f/32.png) [@fedkaa](https://forum.babylonjs.com/u/fedkaa)\
**Post date:** [March 12, 2021, 8:14pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/11 "2021-03-12T20:14:26Z")

</div>

@kutomer have you found any suitable solution for a questions you had? i’m looking into pretty much the same approach and wondering if anything worked out for you

---

<div class="post-metadata">

**Author:** ![aman0x](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aman0x/32/38211_2.png) [@aman0x](https://forum.babylonjs.com/u/aman0x)\
**Post date:** [March 10, 2024, 5:31pm UTC](https://forum.babylonjs.com/t/backend-rendering-of-a-scene/11156/12 "2024-03-10T17:31:08Z")

</div>

@kutomer @fedkaa,  
I’m working on a 3D project and struggling to replicate the exact camera angles and positions across Babylon js to Blender. Any tips on ensuring consistent camera setups?

> [@Babyloan Js scene rendering using blender](https://forum.babylonjs.com/t/babyloan-js-scene-rendering-using-blender/48630):
>
> Hello, everyone! I’m currently working on a project that involves transferring scenes from Babylon.js to Blender, and I’m facing a bit of a challenge with accurately cloning camera settings from Babylon.js into Blender. I want to ensure that the camera’s position, rotation, field of view (FOV), and clipping planes are precisely replicated in Blender to maintain the same perspective and scene framing. Here are the specific details and steps I’ve considered for this process: Exporting Camera D…
