CSM has been added in Bablyon.js as a new shadow generator (CascadedShadowGenerator).
Documentation can be found here. The inspector has not been updated yet, but will be in the coming days.
I know some people were asking for this feature for a long time, so let us know how it works for you and please feel free to leave any comments / remarks in this thread.
First picture with cascaded shadow generator, 1024x1024x4 cascades, so same overall texture size than in the second picture (for fair comparison).
Second picture with standard shadow generator, 2048x2048 texture.
Also:
Hey there, this is great!
I started playing around with it and trying to make shadows not refresh gives some weird artifacts zooming in https://playground.babylonjs.com/#15UN5M#5
Is this normal behavior? Also, seems like performance wise, at least in your demo, the CSM is 10 fps slower than the standard shadows.
Nevertheless this is great and I am very much looking forward to using this in the future!
I’m afraid BABYLON.RenderTargetTexture.REFRESHRATE_RENDER_ONCE can’t be used for CSM because the projection matrices (and so the depth maps) are recalculated each frame according to the camera view, so matrices (/ shadow maps) calculated (/ rendered) for frame X are generally not suitable for frame X+t, except if you keep t low so that the changes are minimal (so REFRESHRATE_RENDER_ONEVERYTWOFRAMES should work, albeit you may experience some rendering artifacts depending on your scene and movements).
If you want a one shot shadow rendering, you are better off using baked / pre-calculated shadows I think.
CSM is doing N shadow map rendering, N being the number of cascades (4 by default), so it’s expected it takes a little more time than the standard generator to render, that does a single rendering. However, we tried to optimize as much as possible, removing code from the shaders depending on the options you choose: have a look at the “Optimizing for speed” section in the documentation for detail.
Also, proper culling of the shadow casters is not implemented yet, all objects (shadow casters) are currently sent for rendering in each shadow map. So, if you have a lot of shadow casters in your scene and only a small number is relevant for a given frame, it might affect the performances.
I’m seeing many more clicks on the standard shadow generator version than the new CSM version. You might want to put the CSM PG first or just clearly label the links.
No, there’s no fallback for WebGL1, it’s a WebGL2 only feature as for performance sake it uses a Sampler2DArrayShadow (and filtering are PCF or PCSS, which are WebGL2 only features too).
So just a basic question about shadows, i guess it’s easy to answer if you already changed the shadow behavior:
Is it possible in WebGL (in general or babylon) to color the shadow?
Thing is - slightly colored shadows brings more variety to applications and the look/feel of images or sceneries.