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 "NO_SHADOWS" shader version to Mobile backend #82215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

darksylinc
Copy link
Contributor

Before this patch, if the dev disabled shadows on all lights Godot would avoid the shadow casting pass but it would still use a pixel shader that tried to sample an empty shadow map (i.e. it's always shadow = 1.0).

After this patch, we compile a variant that has samples no shadows.

The shader already had support for this (#define SHADOWS_DISABLED) but it was not being used for this purpose. It was only used if the material had specifically enabled a setting to not receive shadows.

This greatly improves performance on low end GPUs such as Adreno 505.

Note that low end mobile has multiple bottlenecks at the same time (we're everything-bound 🤣 ) and this is the first PR in a series of PRs to improve mobile performance.

Before this patch, if the dev disabled shadows on all lights Godot would
avoid the shadow casting pass but it would still use a pixel shader that
tried to sample an empty shadow map (i.e. it's always shadow = 1.0).

After this patch, we compile a variant that has samples no shadows.

The shader already had support for this (#define SHADOWS_DISABLED) but
it was not being used for this purpose. It was only used if the material
had specifically enabled a setting to not receive shadows.

This *greatly* improves performance on low end GPUs such as Adreno 505.
@darksylinc darksylinc requested a review from a team as a code owner September 23, 2023 23:38
@BastiaanOlij
Copy link
Contributor

I think we need to further improve on this, though possibly this can be finetuned with specialisation constants.

The most common scenario I can think of is where we only have shadows on directional lights and not on any omni/spot lights.

Or like a horror game where only a flashlight casts shadows and all other lights either have no shadows or are baked.

@Calinou
Copy link
Member

Calinou commented Sep 25, 2023

  • Related to Add a global enable/disable shadows godot-proposals#326.
    • Note that despite what's been said in the proposal, you can disable positional shadows globally by setting the shadow atlas size to 0 in the Viewport. The Project Settings won't allow you to do this due to its property hint though, but we can modify it to allow this.
    • There is no way to globally disable directional shadows though, but doing so affects visuals a lot more than disabling shadows for positional lights in most scenes. There are games which support this (e.g. Fortnite's Performance mode). It looks bad, but it can be the difference between an unplayable game and a playable game on a low-end device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants