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

Add an option to disable shadows or allow shadow resolution to be set to 0 #6612

Closed
xxSeys1 opened this issue Apr 2, 2023 · 6 comments
Closed

Comments

@xxSeys1
Copy link

xxSeys1 commented Apr 2, 2023

Describe the project you are working on

I and people I know are working on 3D games and everyone seems to be looking for an option to entirely disable shadows at runtime

Describe the problem or limitation you are having in your project

There currently is no way (as far as I know) to disable shadow rendering without some kind of weird workaround (like keeping a reference to every light somewhere or rendering through a viewport).
Shadows are expensive even at low resolutions, so they are an easy way to speed up rendering and allow players with lower end hardware to still play a game.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

An option to disable shadow rendering at all or at least allowing the shadow resolution to be 0 would help. This would help because you don't need some weird workarounds. There should be an option for directional and positional shadows, they should be toggle able independently.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the Lights and Shadows section in the project settings, add a checkbox called render shadows or disable shadow rendering. When this box is ticked (depending on the chosen name) it would enable/ disable rendering of shadows. There should be an option for directional and positional shadows, they should be toggle able independently.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can not be worked around with a few lines of script, since keeping a reference to every light and saving the default state (whether the light should not render shadows even if shadows are enabled for example) would result in a big mess of code.

Is there a reason why this should be core and not an add-on in the asset library?

It affects the renderer.

@mieldepoche
Copy link

viewports have this positional_shadow_atlas_size property, so you could set it on the root. (this is from godot 4 but it exists too in 3.x) (name was changed though)
image
like this:

get_tree().root.positional_shadow_atlas_size = 0 # in 4.0

also the docs are lying, I tested and the directional shadows were still visible... although it's easier to work around those than positional ones since you typically have one per scene.

@Calinou
Copy link
Member

Calinou commented Apr 3, 2023

This is already supported for positional lights. https://github.com/godotengine/godot-demo-projects/tree/master/3d/graphics_settings also showcases the ability to disable omni/spot shadows entirely using @mieldepoche's approach (use the Minimal shadow resolution setting in the menu).

godotengine/godot#57610 exposed this ability in the Project Settings dialog for positional lights, but it wasn't merged in time for 4.0. It would need to be redone in a backwards-compatible way to be merged.

It would be possible to add a new boolean project setting that enables/disables shadows globally, but I feel we should simplify the existing project settings rather than make them more complex. Replacing an integer value that was rounded to the next power to 2 with an enum is the best way to do this.

Regarding directional lights, it makes sense to have a separate setting but the same issue as godotengine/godot#57610 applies. We ought to simplify its configuration as well, as the "value is rounded up unintuitively" issue also applies to the directional shadow size project setting and RenderingServer setter.

also the docs are lying, I tested and the directional shadows were still visible... although it's easier to work around those than positional ones since you typically have one per scene.

This behavior was likely accidental in Godot 3 and ended up changing in Godot 4 🙂

@xxSeys1
Copy link
Author

xxSeys1 commented Apr 3, 2023

The enum approach looks really good, I think it would be the perfect middle ground between simplifying the settings and allowing shadows to be disabled.

@clayjohn
Copy link
Member

clayjohn commented Apr 5, 2023

With respect to the "enum" approach. The shadow resolution project settings only apply to the root Viewport. They don't change the resolution of SubViewports. If we want to have a setting that force disables lights for performance reasons, it will have to apply to all viewports.

Personally, I feel like option is relevant for a lot of performance-sensitive effects that may vary from scene-to-scene (see also #5229)

@Zireael07
Copy link

This wasn't completed - why close?

@AThousandShips
Copy link
Member

Op has closed all of his proposals

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