Drop shadow on a transparent mesh instance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bashan

I have a simple 3D scene with a mesh instance using as a floor and some cube (also a mesh instance) and some direction light with shadow turned on.
I would like to make the floor transparent but still show the shadow effect on it, so it will look like the cube is on the air, but still with some shadow effect below it. The color of the shadow should be inherent from the color of the background of the viewport.
Any easy way of doing it?

:bust_in_silhouette: Reply From: Zylann

Shadows cannot have color, but I think projecting a shadow on a transparent surface already works.
I just tried to make a scene with a cube, a transparent plane and opaque ground below it (like a water pond), and I can see the cube project a shadow both on the surface and the ground below it.

Thanks for your answer.
Sorry, but I didn’t exactly understand what you tried and what are the steps you took to do it. I am also not sure you did the same setup I am talking about.

I need that a single cube to drop shadow on a surface below it, but I do not want the surface to be shown at all. I just want to show the shadow effect. The cube itself SHOULDN’T be transparent at all. So eventually the scene will show a cube and shadow, but there won’t be any surface.

bashan | 2020-02-24 21:06

:bust_in_silhouette: Reply From: bashan

I was able to solve this issue by setting the floor (MeshInstance) Spatial Material property under “Flags” section named: “Use Shadow to Opacity” to “checked”.
The problem is that it works only in the simulator of Godot. When I run it on an Android device I see the floor below the cube with the shadow, but the floor is not transparent as it looks in the simulator.

Any reason for this behavior?

Are you using the GLES3 or GLES2 renderer? The GLES3 renderer has known issues on mobile devices, so I’d recommend switching to GLES2 using the dropdown in the top-right corner of the editor.

However, I’m not sure if shadow to opacity is supported in the GLES2 renderer. Such is the state of mobile GPU drivers :frowning:

Calinou | 2020-02-26 12:48

Originally I am using GLES3, but I also tried using GLES2 and I see the same effect: I see the shadows, but the mesh is also visible.
Do you have any idea how can I achieve this effect in a different way?

bashan | 2020-02-26 23:05