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

"shadowGenerators":[]

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?

"cascadedShadowGenerators":[]

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:

https://playground.babylonjs.com/#9WM46I

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:

https://palmer-jc.github.io/cascadeProblem.html

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. Palmer-JC.github.io/cascadeProblem.html at master · Palmer-JC/Palmer-JC.github.io · GitHub

It is not assigning a Filter, just

"shadowGenerators":[ {
 "mapSize":512,
 "lightId":"Light",
 "bias":0.00005,
 "darkness":0,
 "className":"CascadedShadowGenerator",
 "renderList":["Cube"]
}]

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