Serializing Cascaded Shadow generators for FileLoader

I added Cascaded Shadow generators to Blender 2.93 exporter, then realized this is not in the class of ShadowGenerators like all the others. For those, I group them inside a


Inside FileLoader, I do not even see when the Parse for them is called. Kind of a wild guess, but probably need a section like this, right?


No it looks like that was a bad guess. Seems like a need to add a "className":"CascadedShadowGenerator" to an entry.

The easiest way to know is probably to look at the serialized json of a scene with a CSM:

I think I am encountering a bug when putting a Cascaded shadow generator in a babylon file. It is a little tricky to publish, because both sandbox & playground use the minimized versions of BJS. Here is the full scene using max with inlined JSON:

It dies in the CascadedShadowGenerator constructor. Here is the stack from there down

Unsupported filter "2"! 
    _validateFilter cascadedShadowGenerator.ts:85
    set shadowGenerator.ts:445
    set shadowGenerator.ts:412
    set shadowGenerator.ts:545
    CascadedShadowGenerator cascadedShadowGenerator.ts:725

The line numbers from stack are different source files, but line 725 is the last line of the constructor

this.usePercentageCloserFiltering = true;

This is a setter. I am not sure what happens, but as this problem is occurring in the constructor, and there is no opportunity to even specify a filter, I do not see how this could be fixed in JSON.

Only “none”, “PCF” and “PCSS” are supported as filter values for CSM. Value 2 is Poisson sampling => it seems the json file is setting the filter value to 2.

This is the page from prior link. at master · Palmer-JC/ · GitHub

It is not assigning a Filter, just

"shadowGenerators":[ {

filter or _filter is not even a parsed property.

You are setting a CSM for a point light, which is invalid: CSM works only with directional lights.

1 Like