Though I’m able to create a pbrCustomMaterial for creating the shadowDepthWrapper for the material, I think it should be a feature that material plugin support shadowGenerator.
This PR will fix the problem:
Note that this won’t work with
PBRCustomMaterial either, because you need to update the position before projection so that the correct projection can be calculated when generating the shadow map (we are projecting based on the light position, not the camera position). So you need to update the position in
CUSTOM_VERTEX_UPDATE_POSITION instead of
Also, because the code in the
Light class, which is responsible for calculating the extent of the light frustum, is not aware of the mesh position offset, the dimensions are not calculated correctly. The easiest way to solve this problem is to enlarge the frustum by a certain % (20% in the PG below).
Finally, you should create the
ShadowDepthWrapper with the
new keyword (although it doesn’t seem to make a difference in this specific PG).
This PG will work after the PR is merged: