godotengine / godotengine/godot-docs

LightOccluder2D always occlude Sprite

Open
#7,624 3 comments 5 reactions 0 assignees View on GitHub
area:manual bug topic:2d topic:rendering
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Godot Version 4.1.0**

**Issue Description:**
In an object with both a Sprite2D and a LightOccluder2D, the sprite itself is always occluded. The documentation states that this should be changeable based on its order in the scene hierarchy, yet I attempted every possible combination and always got the same, occluded result. (https://docs.godotengine.org/en/stable/tutorials/2d/2d_lights_and_shadows.html#occluder-draw-order).
I furthermore attempted to get the desired effect by fiddling around with the layer masks (occluder_light_mask, light_mask, range_item_cull_mask, shadow_item_cull_mask) yet I had no success with that either.
![image](https://github.com/godotengine/godot-docs/assets/56088109/00f25465-765d-48e1-8302-7a154404b349)

A related problem (which might be intended behaviour or actually just a symptom of this) is that shadows seem to be drawn at the highest z-level, as if the player (who casts a shadow) is behind an object, the shadow is still cast on top of that object, which is undesired.
![image](https://github.com/godotengine/godot-docs/assets/56088109/ab40ff98-181e-460e-a5bd-548fd7e52494)
Here, the shadow should be behind the large brazier, not in front of it. (Sorry if this is completely unrelated, I don't have a deep understanding of the subject matter)

The only way I got it to work is by setting `cull_mode = CounterClockWise` on the OccluderPolygon2D, yet this only work for convex shapes, which is also suboptimal.
![image](https://github.com/godotengine/godot-docs/assets/56088109/9b0a2ca5-ac77-458b-8b01-c4fff7d2045e)

Relevant Documentation: https://docs.godotengine.org/en/stable/tutorials/2d/2d_lights_and_shadows.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.