Is there a way to create a Lightmap for a Scene only using BabylonJS? I am working on a Project where I want the best lighting possible with a nice performance as priority. I was trying out a way to bake AO to my Scene in blender and export it back to Babylon, but this obviously requires the export and import after the effects are baked… So is there a way to create a Lightmap and apply it to the Scene, just using Babylon? Some sort of “on load function” that works its way before the scene is fully loaded. Maybe with a Custom loading Screen to hide the long waiting time I know that I am asking for a lot here
@Sarrus4x4, currently, there is no way to do create an environment map from the scene. It is on our wish list but didn’t make it into our priorities for the 6.0 release. I can pitch it to the team again for 7.0, but it will have to compete against all of the other features and enhancements that are on the horizon.
The process would likely need to be an offline process, where you are able to do a set-up step to bake from a scene and save out an env file to be used like any other. This would be most performant as it is no different than what we have for IBL now. If we need it to be done at runtime, it would likely need to be done during a loading screen as we would need to write out six HDR textures at a size that retains the quality you need, which could get expensive.
Otherwise, in terms of performance if needed while a scene was running, it would likely be similar to real-time filtering or reflection probes and would need to be able to be throttled so as to not eat up too much frame time. The problem is the trade-off for calculations done for real-time environment map creation versus everything else you are doing in your scene on any given frame.
But I will tag it again for discussion in our planning session for the next release.
So what you are explaining here is purely hypothetical? Could it be done automatically if the use of some external program is acceptable? What is mean is: Is it possible to export a Scene from Babylon, apply some visual effects and reimport it back to Babylon all during the load time? And if so, how could this be done? I have this awesome Blender Plugin for shadows and AO, and I’d love to use it on my Scene before it is loaded in Babylon. But this would have to be done automatically ‘on Load’ because the Scene might change on every new Load (it is a 2D room editor with an option to turn your Scene into 3D by pressing a button).
I wasn’t really in need of shadowmap. My scene is all around alpha blended materials, refraction and reflection and shadows are of little importance. My need was to be able to have a blend of exterior and interior environment on the parts that are visible both from the exterior and the inside. Typically glass-like.
So, I don’t think my little trick will work for you. For the record, what I did is that I loaded once a default env for the interior and made tiled (skybox mode) screenshot from an orthographic camera. Did the same with my exterior, custom skybox. Next blended both in photoshop, did some mask painting and generated a new env for my interior from there.
I’m sorry. I know it’s a burdain and a downside to building the scene with fx in BJS (rather than just simply all from blender). Hopefully, we’ll have access to a solution in a near future. Meanwhile, I suppose you will need to find some sort of ‘compromise’. May be bake some of your shadows in blender, those less affected by fx and who don’t need to be dynamic. May be still add a shadowgenerator for the others (with of course an impact on performance).
As I mentioned in my reply to @PatrickRyan I will try to use Blender as a tool to bake some shadows to my Scene. Now I’ll need to find a way to create an automated workflow to export a scene from Babylon, import it to blender, bake some shadows + AO and finally reimport it to Babylon
@Sarrus4x4, I think I mentioned this in another thread, but you could try exporting your Babylon scene as a glTF file and bringing it to Blender to bake your lighting or IBL. You should then be able to just use the product of that bake in your scene without needing to send the scene back to Babylon.
If you are baking an hdr file for IBL, you can then import that and apply it to your scene. If you are baking shadow maps onto a pre-existing UV set in your mesh - for shadow maps you need a separate atlased UV set for all meshes so that the lightmap can be baked into a single texture - then you can simply take the baked texture back to Babylon and apply it in your scene.
As you mention, the connective tissue here is the missing piece. I haven’t worked on a pipeline like this, but I have heard of others doing a scene export to render a ray traced image in headless Blender for things like room configurators. The user sets up their scene, then they can generate a high-quality render of the space, obviously not in real time.
What do you mean by “without needing to send it back”? When I bake something to my Scene in Blender I still need to get the results back to my Babylon application… But this would also require some of that “connective tissue” in some form of pipeline, right?
That sounds like something I could use. A view minutes of waiting for a Scene to get exported, baked and displayed in Babylon with new visual features would be a great solution. I’ll investigate further and try to find information on such a pipeline.
I guess the key word is ‘the scene’. Of course you still need to import the result in BJS but it will be through the meshes materials and the new atlased UV. I hope your scene, meshes and UVs aren’t all too many and complex though. Else, this is likely to take quite a bit of effort the way I understand it.
I mean fully automatic
Yes, I am working on a 2D room editor where users have the option to press a button and (possibly after some time) see the 3D version of the scene. The Basic Functionality is already there (2D view is fully functional and on the press of a button you can see the 3D rendered scene). Now I want to make it look pretty by adding AO, Shadows, etc. without my performance going to waste (because it also runs on mobile). So all/most effects should be baked before the scene is loaded.
I take it from your message, that this is a quite complicated process, and I am in for some nerve wracking hours of Work
Edit: Just thinking of it right now. Now that I understand better where you’re heading.
Ever thought of using Houdini for the bake and the backend? May be check this out and cc @br-matt might be able to give you some hints on the process they used for this awesome project, will you? thx a lot
Yep Houdini indeed can be used for that. The other good part about it, can be containerized and run in the cloud. I can’t go too much into specifics as I just know the topic at a high level. Someday @Valentine will get to present the whole crazy process beyond just baked textures.
One thing to watch out for is cost of sending off to a render farm. The larger scenes cost hundreds to thousands to get a really good render.
@Sarrus4x4, my apologies for not being clear. I was specifically speaking about sending the glb back to Babylon after baking. If the UVs on your meshes are set up to accept baked lighting before export, then you only need to send the texture(s) back to the scene with a simple texture load and apply to material. There would be no need to send the entire scene glb back into Babylon since the only addition would be the textures. This would save on some download time on the user’s end.