Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D Light Occlusion appears broken in 3.5.2 and also 4.1 #79783

Open
Bat-Computer opened this issue Jul 22, 2023 · 8 comments
Open

2D Light Occlusion appears broken in 3.5.2 and also 4.1 #79783

Bat-Computer opened this issue Jul 22, 2023 · 8 comments

Comments

@Bat-Computer
Copy link

Godot version

3.5.2 and also 4.1

System information

Windows 11, GLES3 (3.5.2) & Mobile (4.1)

Issue description

2D Light Occlusion doesn't work as intended in both 3.5.2 and also 4.1.

Creating a simple scene with a tilemap, tiles set to occlude
(This also happens when using a Light Occluder2D on sprites)
Adding a PointLight2D with texture and shadows enabled.

In Godot 3.5.2 when you enable Shadow the texture turns to a block:
Screenshot 2023-07-21 175252
Screenshot 2023-07-21 175322

In Godot 4.1 shadows work until the Light2D moves over the occluded tile or sprite, then the object becomes lit, when it should stay dark.
Screenshot 2023-07-21 174006
Screenshot 2023-07-21 174051
Screenshot 2023-07-21 174124

Steps to reproduce

Creating a simple scene with a tilemap, tiles set to occlude
(This also happens when using a Light Occluder2D on sprites)
Adding a PointLight2D with texture and shadows enabled.

In 3.5.2 move enable shadow, the texture turns into a block.
In 4.1 shadows work until you move the 2D light over the sprite/tile, then it becomes illuminated when it should stay dark.

Minimal reproduction project

Test Occlusion Tilemap Shadow 3.5.2.zip
Test Occlusion Tilemap Shadow 4.1.zip

@kleonc
Copy link
Member

kleonc commented Jul 22, 2023

In Godot 3.5.2 when you enable Shadow the texture turns to a block:

In 3.5.2 it works as in 4.1, you just have an occluder on both tiles:
EqGszlKRCH

After removing it from one tile, saving, and somehow triggering a redraw (seems like this doesn't happen automatically on removing an occluder), e.g. by drawing another tile or reloading the scene, then it looks like this:
K2YVlrMpUa


In Godot 4.1 shadows work until the Light2D moves over the occluded tile or sprite, then the object becomes lit, when it should stay dark.

Not sure whether this is expected/intended or that's indeed a bug (hence marking as both bug/discussion 🙃).

@Bat-Computer
Copy link
Author

Bat-Computer commented Jul 22, 2023

In previous versions the light would not illuminate the occluded tile/sprite when the 2D light overlaps, at least it seems this way in this tutorial from 4 years ago (Godot 3.1). In the tutorial it is quite straight-forward to get it to work, nothing extra is done.

https://www.youtube.com/watch?v=QsCfx-jjS0U (edit: fixed the link)

Screenshot

@kleonc
Copy link
Member

kleonc commented Jul 23, 2023

In previous versions the light would not illuminate the occluded tile/sprite when the 2D light overlaps, at least it seems this way in this tutorial from 4 years ago (Godot 3.1). In the tutorial it is quite straight-forward to get it to work, nothing extra is done.

https://www.youtube.com/watch?v=QsCfx-jjS0U

Skimmed through that video, I haven't seen the light ovelapping an occluder at anytime.

Tested MRP in 3.1.stable.official, behaves the same as 3.5.2 but buggier on the edges:
fJHkpyif01
And with the occluder removed from one tile:
MMb3sEvrDX

So I'd assume the claim that in the previous versions lights were not affecting the overlapped occluders is false.

@Bat-Computer
Copy link
Author

Maybe something was lost in translation here?

The reason I 'claimed' that this worked as intended in 3.1 (4 years ago) was because the YouTube video was posted at that time and it says Godot v3.1 in the title. It obviously worked when the tutorial was created, you can see if you watch the video or look at the screenshot I provided from the tutorial (It looks like it was created in Ubuntu Linux).

Here's a time stamp on the video (5:38), when the shadow is enabled you can clearly see the tile is not illuminated by the light.

Screenshot 2023-07-23 at 11-39-59 Godot 3 1 - LIGHT on TILE MAPS - Tutorial very QUICK and EASY

In my humble test with v3.1 I wasn't able to get the light texture to appear once the shadow was enabled - it just turned into a block and didn't cast shadows, so I couldn't varify it working at all.

@Calinou
Copy link
Member

Calinou commented Jul 23, 2023

There's a known issue in Godot 4 where you have less control over light/shadow display compared to 3.x, but I can't find the link to that issue right now.

@ZigZaggh
Copy link

ZigZaggh commented Nov 9, 2023

Would love to see a fix for lights inside occlude shapes, I have scenes casting shadows, but as soon they move in front of a light hanging on the wall behind, the scene is lit up instead of the light just being completely blocked.

@Bat-Computer
Copy link
Author

I have a simple workaround for the light going through the tilemap occlusion, it might not me ideal for everyone, but you can just duplicate the tilemap and add it on top of the original tilemap - sort of like a mask. You'll should put it on a different collison layer, but it works well.

image

Screenshot 2023-11-09 140050

Screenshot 2023-11-09 140125

@ZigZaggh
Copy link

ZigZaggh commented Nov 9, 2023

Thank you, that works perfectly 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants