Hide mesh but show it‘s shadows?

Is it possible to use mesh to make its shadow and hide it in the same time? I‘m planing to use tubes to make shadows but I would like to hide them and render lines instead (works better for my aeshetics).

Hey unfortunately so far we are not rendering meshes that are not visible but I could imagine an option for shadow maps to avoid this limitation

1 Like

I may have a way:
Use addLODLevel with the second parameter as null.
But that may be an error in BJS and will not work forever.

This is a bug indeed, setting a LOD to null should remove the mesh and hence its shadow.

You can display the shadow of a mesh without showing the mesh by applying a material with disableColorWrite = disableDepthWrite = true:

https://www.babylonjs-playground.com/#F7KZ7C#12

Another way to do it is to set visibility = 0 for the mesh and enable shadow transparency by setting transparencyShadow = true on the shadow generator:

https://www.babylonjs-playground.com/#F7KZ7C#13