godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.56k stars 21.08k forks source link

Light3D's cull does not affect shadows #70556

Open Fabien2S opened 1 year ago

Fabien2S commented 1 year ago

Godot version

v4.0.beta10.mono.official [d0398f62f]

System information

Windows 11

Issue description

The Cull Mask option in the Light node does not affect/filter shadows.

In the following screenshot, you can see that the Box (on visual layer 2) does not receives light (cull mask excluding layer 2), but still cast shadows. image

Steps to reproduce

  1. Add a Plane to the scene with VisualInstance3D.layers sets to 2
  2. Add a Box to the scene with VisualInstance3D.layers sets to 1
  3. Add any type of 3D Light to the scene and uncheck layer 2 from Light.light_cull_mask
  4. Remark the lighting does not affect the Box, but still project its shadow

Minimal reproduction project

SampleProject.zip

timothyqiu commented 1 year ago

Possible duplicate of #58322

Calinou commented 1 year ago

Duplicate of https://github.com/godotengine/godot/issues/58322.

Fabien2S commented 1 year ago

I have downloaded both beta12 and the project I originally uploaded and the lights are all still casting shadows even tho none of them are lighting up the cube.

I checked with beta11 (in which the PR #70638 got merged), same result.

Am I missing something? #58322 seems to be fixed.

clayjohn commented 1 year ago

This behaviour is the same in Godot 3.x and is even highlighted in the documentation:

Cull Mask: Objects that are in the selected layers below will be affected by this light. Note that objects disabled via this cull mask will still cast shadows. If you don't want disabled objects to cast shadows, adjust the cast_shadow property on the GeometryInstance to the desired value.

I'm not saying that the way it works now is the way that it should work, but its clearly currently working as intended, so this is not a bug per se.

markusneg commented 1 year ago

This issue is different from bug #58322 which was about shadows not removed on an per-camera cull basis. Or more precisely: VisualInstances (VI) which were culled from a scene due to non-matching camera cull_mask and VI layers still left shadows in the scene. This issue, on the other hand, is about shadows of non-interacting lights and VI (due to non-matching light_cull_mask and VI layer). So no additional camera involved here. I know the docs announce this behavior but I still would call it a bug as it doesn't make sense, neither on a physical nor on an "intuitive" basis. Just as in #58322. To be honest, probably the docs were rather written around this behavior than the original implementation conformed to the docs.

lupuchard commented 5 months ago

This behaviour is the same in Godot 3.x and is even highlighted in the documentation:

Cull Mask: Objects that are in the selected layers below will be affected by this light. Note that objects disabled via this cull mask will still cast shadows. If you don't want disabled objects to cast shadows, adjust the cast_shadow property on the GeometryInstance to the desired value.

The documented solution doesn't work if you want an object to cast shadows for some light sources but not others.

Calinou commented 5 months ago

The documented solution doesn't work if you want an object to cast shadows for some light sources but not others.

This is being tracked in https://github.com/godotengine/godot-proposals/issues/3606, which has a pull request implementing it: https://github.com/godotengine/godot/pull/85338