Exporting shadows from blender to babylon js

Hello i am trying to create my world in blender, but i have a problem with exporting shadows.

Here are the setup in blender, with the plugin used to export blender 2 babylon.

Here is the results in babylonjs:

The problem is that there is no guide to how to set the settings, to get the final results.

How do you solve this problem?

Regards,
Fadi Bunni

@JCPalmer Maybe you can help here?

Thanks :slight_smile:

This section of the docs may help you: Shadows | Babylon.js Documentation

Notably, with the inspector try to change the bias value and see if that helps.

1 Like

Thank you soo much, I made it kinda work. But another problem occured.

When i have “Receive shadows” on an object it just goes black:

(with received shadows)

(with recieved shadows turned off)

As you can see the castted shadow on the ground plane is alright.

Do you have any idea what the reason might be?

/Fadi

If the object is also a shadow caster, it could be that the bias value of the shadow generator is too low, try to raise it.

FYI, the cast & receive shadows properties can be set on export using properties of that name in the export custom properties section for a mesh.

Alright I found a solution that works for me.

By setting shadowgenerator to: useBlurCloseExponentialShadowMap = true

And

For directional light: autoCalcShadowZBounds = true:

But the problem is, the plugin does not allow me to set these settings. I therefore have to go in to the .babylon file and manually change it. How do you solve this problem?

It also seems that one cannot set shadowMaxZ and shadowMinZ for a better solution rather than autoCalcShadowZBounds

Can these functionalities be added to the exporter?

/Fadi

You can set those properties yourself if you don’t set autoCalcShadowZBounds to true. Or do you mean you can’t set those values in Blender exporter?

I will let @JCPalmer answer regarding the exporter.

I have not done anything with shadows in the exporter in over 3 years. Those properties probably didn’t exist at that time.

I have bookmarked this for when I start working on exporter for next Blender LTS version. Till then, set them in your own code.

Adding shadowMaxZ, shadowMinZ, & autoCalcShadowZBounds to the Custom properties of a Light for the Blender exporter.

Working directly with an early beta of Blender 2.93, so will never be tested on 2.92. Also not going to very many pushes to repo, just one after all the functionality added. People never do any testing, so it is just a waste of my time to do multiple pushes.

2 Likes

complete in 2.93 exporter

4 Likes

Thank you for your help :slight_smile: