Need help, ran into a wall with the CSM implementation. I got the codes and maths working for the first cascade (weird shadows but it seems like its working). The problem:
Currently, a shadowgenerator uses 1 shadowmap per light and the customrenderfunction call uses said light for viewprojection matrix calculations. see below:
this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
In CSM, for n cascades, there are n shadowmaps. So I’ve implemented it via an array of shadowmaps/RTTs.
this._cascadeShadowMaps[index].customRenderFunction = this._renderForCSMs.bind(this);
So far so good, but when it comes time for the customrenderfunction to coimpute the projection matrix, it does not know which shadowmap to work on. Usually, you’d expect to pass an arrayindex or some form of data thrhu, like so:
this._cascadeShadowMaps[index].customRenderFunction = this._renderForCSMs(index).bind(this);
But from the RTT source, it expects the customrenderfunction to be
public customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
this._renderForCSMs(index).bind(this); throws compiler errors. I’ve searched thru the entire bjs source on github but seen no other RTT arrays with a similar use case. I can live without passing the index arg as long as there is a way for me to access the shadowmap.name with the render function, I can parse it to get the index value but even that is proving difficult.
Sorry if this seems like a trivial problem, I’m not the most TS savvy coder, so any help is appreciated.
edit: made a pg: Babylon.js Playground to illustrate the problem.