Hello, I have to make a realistic art gallery, but I don’t have a proper file to use it in Babylon.js, so I downloaded a good-looking scene in Blender to see if it’s viable. Blend file
The problem is, when I export it to glTF, there is only one ceiling support (idk if that’s what you call it) while there should be more, and the ceiling doesn’t look anything like in the blend file. So I downloaded Blender Exporter (Blender2Babylon-3.3x.zip) and tried to export it as .babylon. Export in some scenes goes through and in some it doesn’t I don’t know why, but when it does, the scene looks nothing like in Blender. In the case of the provided scene, the ceiling looks very nice, but the rest is awful.
What am I doing wrong?
My Blender version is 3.3.1, Blender Exporter is Blender2babylon-3.3x.zip, Babylon is v5.46.0.
Here is a link to my repo with code: avanrish/sample-scene (github.com)
Hello, it would be helpful to have the scene in a Playground
Here is playground! Blender Export | Babylon.js Playground (babylonjs.com)
Edit:
We bought a model which was made on Blender 2.93, so I downloaded Blender Exporter for 2.93 and I got this error log Error Log - Pastebin.com
Maybe I need to modify something in the model itself for it to work? When I removed normal maps in Shader Editor, it exported successfully, but it didn’t look that much different from glTF Imgur - Exporter.
The scene is using custom materials not supported by the exporters as well as unexpected node types SHADERNODENORMALMAP. You can see it all in the logs.
I guess you will have to work a bit on the scene to ensure it is fully exportable
cc @PatrickRyan and @JCPalmer
Thanks for checking for me. I am not really doing much today. I saw this post sitting on the couch this morning. As soon as I saw the op did not make the .blend & it looks like crap in both formats, I knew it was material settings which have no equivalent. Answering from the couch has been blowing up in my face lately, so did not reply.
@avanrish in looking at the Blender file, I’m sure it was intended for pre-render and not export to glTF for real time rendering. There are a bunch of things in the file that are not optimized for glTF and some others that I saw that likely will cause problems on export.
The non-optimized issues are concept like multi-materials. You can certainly use multi-materials in Babylon, but it is a heavier process at runtime because you need to assign materials per vertex rather than per mesh. You can see in this light fixture that you have three materials assigned to the mesh:
Ideally, if you were to optimize the scene, you would UV the light to be able to use one material with UV islands controlling your color breaks. In the case of materials where you simply want to use a different set of material factors rather than textures, then combine all meshes that use each material. So, for example, if all of the diffusers on the can lights use the same material, rather than combining the diffuser into each individual light, combine all diffusers into one mesh with one material assigned. Do this for each material needed in the scene to prevent some of the overhead and exporting issues of multi-materials.
The other issue I saw was in the case of some of the materials, there are operations being done on the textures before wiring to the Principled BSDF.
In this example, it is using the same texture for base color and roughness, while adding a curve operation to the roughness texture before using it as base color. It is also manipulating the Y axis of the normal texture as well as scaling all of the texture tiling. The texture tiling can be handled with KHR_texture_transform which will export correctly with this setup. However, if you look at the Blender manual about how to set up your materials for glTF export you will see that the exporter is looking for png and jpg textures assigned to the shader for export. Any operation done in the shader between the texture and the input will likely be ignored outside texture transform which would come before the texture.
I think the best approach would be to read through the glTF docs on the blender site and make sure the materials in your file support what the glTF exporter is looking for. At that point you may want to look at how to optimize this for real time rendering. Hope this helps, but feel free to ping with questions.
Thank you very much for the explanation! I’m not an artist and I can’t do anything in Blender myself, so we’ll leave it to someone who knows what they’re doing and can prepare the scene for us to make sure it looks good in Babylon.