0 votes

I'm trying to have a shadow catcher in godot: a material which is generally transparent, except it should shows the shadows cast onto it.

As per this thread this shader should do the job:

void fragment() {
  ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
}

However, when I try to use it:
1. the material is not transparent (it's tinted blue)
2. it doesn't actually catch the shadows: you can see the shadow of the mug/hand can be seen twice:

What am I doing wrong? How do I get a working shadow catcher?

screenshot

Godot version 3.4
in Engine by (132 points)

1 Answer

0 votes

I managed to solve the first problem (lack of transparency) by hacking with shadow_to_opacity:

render_mode shadow_to_opacity;

void fragment() {
  vec3 g = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
  float mean = (g[0] + g[1] + g[2])/12.;
  ALBEDO = vec3(mean, mean, mean);
}

I still don't know how to make the material to prevent the shadow to passing through, though.

by (132 points)

can't You try it in higher scope - Geometry Instance (meshinstance) ? Try to reach in editor and flag off shadow casting. It will still be able to receive shadows

The problem is, I do want the mesh (the cup) to cast shadow: I just want this shadow to fall only on the plane (table), but not on the ground. If you mean to turn off shadow casting in the table, it's already turned off, but it has no effect as the shadow comes from the cup (although I agree it's weird).

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.