How to export corretly from bleder to babylon

hello, I introduce myself I am designer and rencientemente found babylon and I like the idea of models on the web but I see that it is difficult for me to find a similar result from blender to babylon the tutorials I find are very few and some with outdated information so I make this thread to understand how babylon works. if I make a mistake please tell me.
my goal to achieve is this.

the problem is when I try it on the sandbox it looks totally different.
according to what I have read and researched is that I have to use light map and enviroment light. but is there any way to assign them in the same babylon file without touching code?
I have tried in the editor but when I try to save it I can no longer use it in the sandbox or directly the animation that has the sphere is lost.
what I have achieved so far is to get it visually looking this way that I’m doing wrong.

PD: I attach the models I’m using in case someone wants to take a look at them maybe I’m making a beginner’s mistake. GitHub - leonelG/models: models for testing babylon

1 Like

pinging our Blender experts @Vinc3r and @gryff

You may found my tutorial about lightmapping workflow? From Blender to BabylonJS - Nothing-is-3D. It’s not using gltf but logic is the same.

Also you’ll probably be interested by this playground: (availabled through Available Meshes to Import, sources on Github).

I looked at your .blend. First, I would make it a true 2.80 .blend by creating a new, then File Appending in all the objects, EXCEPT lights. Properties are different for 2.80 lights. All your window menus will then be in consistent places with 2.80

Just recreate any lights. Also a note on the area light. It is not supported in BJS, but BJS has a hemi light which Blender 2.79+ no longer has. What is actually getting written to the JSON file is a hemi light.

That may be part of it, but also this was never meant to be indistinguishable from running in Blender. BJS is not even the same across browsers, but I acknowledge the sphere is not even close.

I do not know much about light mapping, but I do have some tips if you want to get close short of baking everything. First, switch to the EEVEE render engine. Trying to compare BJS with Cycles is unrealistic. Cycles takes like a minute to display that. Who has the time for that anyway?

Also, as for the missing shadow, you can write into the export generation of dynamic shadows. They are too different from Blender to reuse their properties. You have already have both the sphere & cube mesh both casting & receiving shadows. I would turn off receiving on sphere & casting on cube. Also, use a Directional / Sun Light to have shadows generated, then the custom shadow properties you set in lights will work.

I do not know all the light types which can generate shadows, but hemi is not one of them. I will be working on that file this week. A little help, @Deltakosh, which BJS types can work with a shadow map?

On the sphere, I need to look into that. The ambientOcclusion on the red channel is not being enabled. I have to admit I did not actually have any test files for this. My own reason for looking closely at this for the purpose of stealing your scene.

Question, @sebavan, when using a metal, roughness, occlusion texture, what value should there be for the scaler property, or should there not be one at all in those cases?

Update, you are using a point light not area. You are also using a node shader for the light. This is why I say do not bring in Lights they are too different in 2.80. In a new scene, lights do not have that option. Blender may grandfather that stuff in, but we never actually supported that, and not going to do something like that. Do not even think I could, given what BJS does.

there are always multiply against the texture so if there is a scale in blender (which i have no idea) when using texture, you could use this one.

1 Like

One other thing, you are exporting in PBR. While this is a requirement to do Metallic, it also uses an environment texture. The sandbox gives you a default, if you did not include one during export. See world properties to add your own.

You left the environment intensity property, also in world, at 1. This is why the exported scene is so much brighter.

Finally, I see your sphere has reflected walls & smaller cubes in them. An environment texture can be reflected in meshes, but not other meshes without a lot of work. I fear baking / lightmapping will not work, since the sphere has a spin animation, that stuff is only for static meshes.

1 Like

Hi agains guys after a long time to research and reading your input, I feel like I see a path
first to @Vinc3r I’m noob to reading code and understanding it so sandbox is great for non-programmers, but recently i’m using playground to understand the final workflow. check the models and links to prepare lightmap and remember that I had already done that to improve render times in blender and implement it thank you very much for the data.

Holy data man your coment is a master class of babylon. thanks a lot but i have problem to get the goal let me comment.
-I first made every one of your recommendations to update to blender 2.8 and babylon exporter 6.2.0 then rename all of material and meshes fo a better comfort and light and shadows.

-second i baked all textures for get lightmap and i questioned is there any way to export the lightmap from blender to babylon?

-third I discovered babylon editor allows me to visually modify many options to the models which allowed me to see that for the pbr to look right I have to activate these functions.

I deactivated Use roughness from metallic texture alpha to get a correct pbr although when active Force Specular anti-aliasing I was able to get the roughness of the metal.
also use babylon editor to add the lightmaps and export it.
when I exported it I got a visual improvement but I lost the animation of the sphere.
What would be the process to do this inside blender?
finally tried playground and i tried to make it look good there and i found other problems that i think i could solve. however i lost a point light and i don’t know why it could be?
you can see at

PD: i update the models in case anyone wants to see what I’m wrong about, thank you very much for the help I will be ready to read and continue exploring until I achieve the goal

hi guys it me again, after see multiples way to do i see i think blender exporter do not all the work then i think see the code but this is hard to do for me, i try make philosophy kiss, simply i dont understand how to call material inside of my model to set this. " pbr.useRoughnessFromMetallicTextureAlpha = false;" ill try put in my code but i get error Sphere_PBR is not defined. and i see the code for lightmaps but is confuses for now i need a level up to do but i never surrender. let me a way to do
you can see my progress here:

here it is :

You can see more comments inlined in the code.

Thank you :smiley: we finally made it. thank you so much for the help. i show you the final result in case someone also has problems.