Shadow on hardware instances

Hello, it is possible that my hardware instances are casting shadows between themselves ?

Hi @MLB,

Hardware instanced models use the regular Standard Material shader that supports shadow casting.

If you aren’t seeing shadows then it may be the case the shadows renderer isn’t calculating the right frustum for rendering (it may be too small).

This can happen when your mesh instance AABB isn’t correct and there aren’t any other models rendering in the scene. So basically the shadows renderer assumes only a small sized model is being rendered.

Try calculating and setting the AABB on the mesh instance that you enable instancing. Just set the halfExtents and center point on the aabb property to include all of your instances, and not only the original mesh:

https://developer.playcanvas.com/en/api/pc.MeshInstance.html#aabb

Most likely that will fix it.

2 Likes

Thanks for your explanation