-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Visual layers are ignored for DirectionalLight #74545
Comments
I needed this for hiding directional lights on other side of portals and for my purposes made this one line fix here in RenderingServer's RendererSceneCull::_render_scene: https://www.youtube.com/watch?v=trNFxV6KRMs Although I'm not sure if this is the right solution. Right above that function we have _scene_cull where it does a whole list of checks which are also not accounted for for DirectionalLight3D's:
as they are not handled in this function but rather right afterwards and added to the cull with the result from the above for loop: godot/servers/rendering/renderer_scene_cull.cpp Line 3323 in 2ababdc
It looks like they are not considered in the _scene_cull function. It looks like the relevant checks would be the layer mask one and the visibility parent one, which it also doesn't work for. If we want to keep this separate we could do add a visibility parent check and that layer_mask check I added above in the for loop for directional lights. For that we would need to rearrange _render_scene a bit to have the cull_data available to call _visibility_parent_check(cull_data, E) as well. I can make a PR if this is sufficient or I can edit it a bit if needed. |
Ran into this issue as well. Any reason this shouldn't become a PR? (In the meantime, I can compile a version with the patch for myself.) Do directional lights need to be culled? They are, by design, pretty omnipresent, and I can't think of a situation off the top of my head where you would have a directional light and not know for certain that it can be culled until the shadowmap has already been rendered. |
Godot version
4.0 stable
System information
ArchLinux
Issue description
Changing visual layers on directional lights has no effect; the directional light is always rendered. This differs from OmniLights and SpotLights, which are only rendered if they have overlapping layers as the Camera's cull layers.
Steps to reproduce
Ensure the renderer is Forward+. Add a directional light to the scene, a mesh and a camera. Set the visual layers of the DirectialLight and the cull mask on the camera to have no common flags. The DirectionalLight is still rendered.
Minimal reproduction project
directional_light_layers.zip
The text was updated successfully, but these errors were encountered: