Limiting shadow length 2d


I’m using a directional light 2D and the occlusion layers of a tilemap to cast shadows. Here is the problem:

From the documentation:

To have directional shadows that are not infinitely long, you should disable shadows in the DirectionalLight2D and use a custom shader that reads from the 2D signed distance field instead. This distance field is automatically generated from LightOccluder2D nodes present in the scene.

From my understanding, there is no way for the engine to limit the shadows length and we need to use the SDF data to create a shader.

i’m looking for one of the 2 solutions :

  • Does someone have resource or a shader to do shadows and limit their length ?
  • is it possible to not cast shadows on the ground layer but cast shadows only for a specific layer (in my example the building)

EDIT: found the answer. So there is indeed a shader to code shadow length limit

Everything is in this repo: GitHub - jess-hammer/2d-shadows-demo-godot: Demo of a shader to create directional 2D shadows of limited length!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.