Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DimitriyPS |
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?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DimitriyPS |
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?
Reply From: | Zylann |
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.
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?
DimitriyPS | 2018-06-06 13:35
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.
Zylann | 2018-06-06 18:50
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.
Calinou | 2018-06-08 16:51
You can get rid of shadows if your game is Minecraft
Zylann | 2018-06-08 20:07