For a few days, i have been trying to build a virtual store in Maya 3D. My main goal is put this scene into Babylon and walk about in it. I’ve tried a few real-time light settings but after many readings I’ve decided to use pre-baked lightmaps. So, I imported this scene to Unity 3D and prepared all lights and material settings etc. After I’ve satisfied with final result, I searched for proper way to import this scene into Babylon js. So I have a few questions about it.
First. Should I export only lightmap from Unity and export scene from Maya as a .babylon file to Babylon with another Uv set and apply this texture to materials in the debug layer? I am not sure is this a good way because Unity created another Uv set automatically and I am not sure if lighmap is baked into first Uv set that i already have in Maya or the other one Unity automatically created.
Secondly, with Babylon toolkit exporter I exported scene from Unity as glb and gltf format. But i need to convert these formats to .babylon and I am not sure if this scene properly viewable in Babylon js because of all these lightmaps and material settings.
Thirdly, I build Unity scene with Webgl 2.0 and opened exported index.html and still satisfied with the result but I am not sure is it possible to put this Unity Webgl export to Babylon properly.
In general, I am looking for a good way to export my virtual store to Babylon with good lighting but I am pretty confused with this possibilities and I don’t know what should I do.
Any help will be fantastic. Thank you all in advance.
Maybe others will be able to help too, let’s wait a little bit.
Regarding:
The webgl code generated by Unity in its Webgl export can’t be used in Babylon, as it is raw code that runs standalone.
If you built your scene in Unity, I guess the Toolkit is the best way to do that. GLTF export is not really usable because lightmaps are not supported by GLTF.
Thank you for your quick response.
I exported only lightmap from Unity and tried to put this map into correct places in Babylon and Maya but couldn’t work it out. As far as I can see, Unity bakes this lightmap into another Uvset which i didn’t created because in Maya and Babylon, lightmap didn’t fit properly. Clearly I am making something wrong. I exported scene from Maya and changed nothing but still no response.
So if Unity Webgl build is not usable in Babylon, I have two options left. One is, as you said, export with the Toolkit the other one is use Arnold Render to Texture tool. But I have no experience with that and I am not sure I can manage that process. I should wait for another response and try to do this in Maya as you suggested. Thank you again.
So, you import the file without second UV channel into Unity, and there Unity generates 2nd UV channel and bake lightmaps??
If that’s the case. What I suggest is that you create 2nd uv channel in Maya. And export model like that. On import in Unity If it works like UE4 for example, you probably have some flag to create or not to create another UV set automatically. So disable that, as you already created the UV set in Maya.
Now, I don’t know how baking process work in Unity, but in theory, you should be able to bake light into the channel you created.
In Babylon, you use the same model (with the 2nd channel created) and create material with the lightmap texture applied
material.lightmapTexture = "lightmap"
material.lightmapTexture.coordinatesIndex = 1;
(basically targets 2nd UV channel (in Maya/Max channel numbers start with 1, in engines it is usually starting with 0. So channel 0 in Babylon or Unreal, is channel 1 in 3dsMax for example.
material.useLightmapAsShadowmap = true;
I am not sure if I missed your point completely, but as I understand it, this should work. You need to have same asset coming from Maya into Unity and Babylon, and both engines are using 2nd channel for lightmaps.
Yes, as you said, I created 2 different Uv set in Maya and than exported it to Unity. In Unity there is a checkbox for create automatic Uvs but I didn’t click it. In Unity’s viewport all is well. Everything is as expected. But after export, the lightmap never fits in. I can see that lightmap is baked to second Uvset, but still doesn’t work.
Yo @mkaanztrk Are you using my Scene Manager Extension (babylon.manager.js) either in your own project or the Babylon Toolkit generated web project ?
If so, it has everything you need, You can bake the lightmap in the editor using all the Unity Tools … the Exporter will use UV2. It will actually go thru and RE-ENCODE the meshes UV2 to match the lightmap Texture Atlas position.
Hi @MackeyK24 in Unity I didn’t try Toolkit exporter because it exports glb and gtlf and my scene viewer only accepts .babylon files and @Evgeni_Popov said gtlf doesn’t support lightmaps. So i am exporting only lightmaps to Photoshop and converting as png and trying to apply in Babylon editor but having issues with placement. Any help would be grateful thank you!
OK @mkaanztrk take a look at the video i made for how i bake lightmaps using the Babyon Toolkit with the Scene Manager extension
My system works best with the babylon.manager.js extension which loads gltf files. You still may be able to use the resulted RGBD/HDR lightmaps i export. But you would have to manually setup the materials and specify the texture.isRGBD = true in the texture on load callback.
Hello again @MackeyK24 , Toolkit did the magic and put the lightmaps into correct places, now when I press build, in localhost I see a good result. Thank you so much.
My only concern is Export Mesh Mode.
I would like to play my scene in GitHub - BabylonJS/Website: Main babylon.js website in this project. But that sub meshes mode requires additional extension which I’ve never heard. Is this going to be a problem for me?
After a few sleepless nights, I’ve solved all the problems. Copied your babylon manager.js for required cvtool extension and also added a light for mixed lighting. Now when I export my scene with toolkit, I can see the scene in my own localhost with zero problem. Thank you all very much! @MackeyK24@Evgeni_Popov@nogalo