Hi!
I’ve built a little physics simulation drawing test here:
(Click and drag the canvas to see shapes appear).
In the code sample above, you’ll notice on line 140 I’ve tried to use customProjectionMatrix as shown here to limit the shadowmap bounds. Without a limit the shadow map seems to grow as more shapes are added to the scene, very quickly blurring into nothingness.
But I can’t get it to work. The shadows just disappear when I use that customProjectMatrix code.
Has anyone worked with it? I can’t find any other references or examples on how to use, and I’m unsure if I’m even going about it correclty…
Awesome. Thank you so much!
So I tested both methods and got them working, and here’s my final code (with the alternative method commented out):
// So Babylon knows where to project hte shadowmap from...
dirLight.position = new Vector3(0, 100, 0);
// Then, to define the size of the shadowmap area
dirLight.shadowFrustumSize = 200;
// OR...
// dirLight.customProjectionMatrixBuilder = function (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) {
// // Ortho because it's a directional light
// Matrix.OrthoLHToRef(200, 200, camera.minZ, camera.maxZ, result);
// }