0 votes

I can turn on/off shadows to light sources. But I need to do it globally for the whole game. How can this be done using GDScript?

in Engine by (354 points)

1 Answer

+1 vote

I don't think there is a global setting for this. You have to get all lights in your scene and turn their shadows off. If you are only using a directional light, it would be as simple as getting it and disable its shadows.

by (27,774 points)

Shadows have a very strong effect on performance. So I want to add on / off to the settings in game - the user decides to use or not to use the shadows. In my game there will be a lot of locations, and it is to each location (map, level). Each of them need to write a script to select light sources and on /off shadows. It's definitely uncomfortable and clogs the scripts of the project.

Can write on Github a proposal to add such a parameter? Or it won't be relevant?

That could be a feature request yes...

In the meantime I would simply add an instance of the same script on every light, and have the script check game settings in _ready and turn off shadows if needed.
Or have a single script which parses the scene when a level is loaded so no need to modify every scene.

You don't want to disable shadows from all lights; it would look really ugly if one were to disable all shadows from all lights. Some scenes could even be rendered unplayable simply because they're too bright.

You could add a group such as optional_shadow to lights which can have their shadows disabled without resulting in a broken look, loop over nodes in that group and disable shadows if the player turned off shadows in the game settings.

You can get rid of shadows if your game is Minecraft :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.