CSM performance

when i use csm as shadowGenerator,the draw call will increase when numCascades increase.can we use subfrustum culling to reduce draw call?

You can use your own culling for each cascade by implementing the getCustomRenderList callback.

See Cascaded Shadow Maps | Babylon.js Documentation

ok,thank you .Is there a pg to deal with it?I am a novice

I don’t know if someone ever implemented a custom culling for CSM…

i see the source code,and find

        this._shadowMap.onBeforeRenderObservable.add((layer: number) => {
            if (this._sceneUBOs) {
            this._currentLayer = layer;
            if (this._filter === ShadowGenerator.FILTER_PCF) {
            this._scene.setTransformMatrix(this.getCascadeViewMatrix(layer)!, this.getCascadeProjectionMatrix(layer)!);
            if (this._useUBO) {

i think frustum culling has been implemented,Could it be a problem with the frustum matrix calculation that caused an error in frustum culling?

This code is not doing frustum culling for the cascade, it is simply setting the transformation matrix used by the mesh rendering code.

Culling would involve getting the bounding box of each mesh, transforming them by the transformation matrix and testing them against the frustum of the cascade, something which is currently not implemented.

@woniubushiniu please try to keep the question in one thread as this looks like a dup of woniubushiniu

1 Like