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

Shadows are sometimes cast by not visible objects and always cast by cull_masked objects #43827

Closed
goatchurchprime opened this issue Nov 24, 2020 · 9 comments

Comments

@goatchurchprime
Copy link

Godot version:
3.2.3.stable

OS/device including version:
Windows

Issue description:
I have been using layers and camera culling to turn on and off large sections of my scene instead of controlling the visibility flag on each one individually. It also allows me to make some objects big enough to see in the overhead plan camera but not appear in the main game play window. Unfortunately even though they are invisible, they still cast shadows.

When making this minimal reproduction project I discovered the second problem that the shadows do not always respect the visibility flag.

image

Steps to reproduce:
Run the example. The camera has a cull_mask against layer 2.
Use the H and S key to toggle visibility on CubeLeft and layer on CubeRight.
Both cubes disappear but their shadows remain.
If you "touch" the cubes by using the 1 key to rotate them by 10 degrees the CubeLeft shadow disappears, but the CubeRight always remains.

Minimal reproduction project:
layershadow.zip

@Calinou
Copy link
Member

Calinou commented Nov 24, 2020

Related to #19438 (which is fixed in master).

Edit: Also related to #29856.

@lawnjelly
Copy link
Member

Also #32475 was merged after 3.2.3. May affect your project (haven't tested).

@goatchurchprime
Copy link
Author

Apologies for not doing an adequate bug database search before drafting this. Must do better. Hope I've not wasted too much time. Please mark as duplicate, archive as appropriate. I don't want to further mess up the system.

@akien-mga
Copy link
Member

@goatchurchprime No worry, it's not expected of users to know the bug tracker by heart :) A potential duplicate issue does not disrupt anything, at most it confirms the validity of a bug in the currently supported release.

@lawnjelly
Copy link
Member

@goatchurchprime can you try this in 3.2.4 and confirm or say whether any of these bugs are still present so we can either close or action?

@goatchurchprime
Copy link
Author

Changing the visible flag does now update shadows in the next frame for 3.2.4

Changing the cull_mask in the camera still leaves the shadows in place. To be fair, this is different to the issue #19438 which is the cull_mask applied to the light and looks like it will be a won't fix. This bug/feature could be handled in the documents at https://docs.godotengine.org/en/stable/classes/class_camera.html?highlight=cull_mask#class-camera-property-cull-mask with a note that it doesn't apply to shadows. So if you're applying it to non-shadowed objects it will look just fine.

@tavurth
Copy link
Contributor

tavurth commented Feb 9, 2022

Confirmed, just ran across this in v3.4.3.rc1.official [894b6d5]

Screenshot 2022-02-09 at 11 05 54

Far box is:
Screenshot 2022-02-09 at 11 06 33

Close box is:
Screenshot 2022-02-09 at 11 06 52

Directional light is:
Screenshot 2022-02-09 at 11 07 15

Sample project:
godot-light-test.zip

Lighting appears to be working, but shadows are still cast.
This was a problem for me because I was trying to improve my Light Cookie (flashlight), but the light cookie also draws shadows from the sun.

tavurth added a commit to tavurth/awesome-godot that referenced this issue Feb 9, 2022
Due to godotengine/godot#43827 I was unable to
implement my light cookie as I wanted.

The shadow from the directional light (sun) caused the light cookie to
be visible from different angles 😢
@Calinou Calinou added this to the 3.5 milestone Feb 9, 2022
@akien-mga akien-mga modified the milestones: 3.5, 3.6 Sep 23, 2022
@akien-mga
Copy link
Member

Fixed by #61841.

@markusneg
Copy link
Contributor

markusneg commented Oct 7, 2022

Confirmed, just ran across this in v3.4.3.rc1.official [894b6d5]

Your example probably points to an open issue different from the one mentioned above and fixed in my PR. Indeed the docs say:

light_cull_mask
The light will affect objects in the selected layers.

which (in my opinion) suggests that the non-affected objects (caused by mismatching light_cull_mask and visual instance layer) neither cast shadows. Should we create a new issue for that or is that wanted behavior?

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

6 participants