Skip to content

Switch mobile renderer to use fixed PCF kernel.#114038

Open
DarioSamo wants to merge 1 commit into
godotengine:masterfrom
DarioSamo:mobile-shadow-filtering-change
Open

Switch mobile renderer to use fixed PCF kernel.#114038
DarioSamo wants to merge 1 commit into
godotengine:masterfrom
DarioSamo:mobile-shadow-filtering-change

Conversation

@DarioSamo

@DarioSamo DarioSamo commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

This PR changes the mobile renderer to use fixed kernels for shadow sampling, which can provide some pretty massive performance boosts on mobile devices when opting to use soft shadows. However, it currently breaks features such as soft shadow scaling, as the algorithm in use is not compatible with the concept of scaling as it is implemented.

As measured by @clayjohn on an Adreno 640...

Low Quality
Before: 20 mspf
After: 13 mspf

High Quality
Before: 44 mspf
After: 23 mspf

It is pretty clear that the use of a simpler kernel that doesn't rely on disk sampling can provide a pretty significant performance difference on lower end devices. However, since this PR breaks the aforementioned feature and changes the visual quality result, it is left as a draft until it is decided if the engine wants to take this approach going forward. Regardless, the PR can prove to be useful to developers who wish to use a simpler and more performant technique.

To my understanding, it was originally the intention for the mobile renderer to use techniques like these as the quality trade off is less visible on these platforms, but the implementation ended up being shared with Forward+ due to the code's structure, resulting in using a technique that might be a bit overkill depending on the developer's needs.

@akien-mga akien-mga added this to the 4.x milestone Dec 15, 2025
@DarioSamo DarioSamo force-pushed the mobile-shadow-filtering-change branch from 54d83c8 to f1af3eb Compare December 18, 2025 15:47
@DarioSamo DarioSamo marked this pull request as ready for review December 18, 2025 15:49
@DarioSamo DarioSamo requested a review from a team as a code owner December 18, 2025 15:49
@DarioSamo

Copy link
Copy Markdown
Contributor Author

I implemented what was necessary for omni lights to wrap around correctly on the atlas.

What remains now is mostly up for debate, as merging this would irreversibly change how the shadows look in mobile renderer projects, and adding a toggle for it might be complexity that most users won't deal with.

Use OptimizedPCF from the Witness. These kernels require fewer samples and are higher quality when compared to Godot 3.x's PCF.

Co-authored-by: Clay John <claynjohn@gmail.com>
@DarioSamo DarioSamo force-pushed the mobile-shadow-filtering-change branch from f1af3eb to 923fa06 Compare December 18, 2025 15:53
@clayjohn

Copy link
Copy Markdown
Member

Here is a quick comparison. I will make some more comparisons before we decide.

Ultra quality shadows before: 44 mspf
ULTRA

Ultra quality shadows after: 23 mspf
ULTRA-new

Importantly:

  1. You can't tell the difference on textured materials since they hide the artifacts in both cases
  2. You can't tell the difference unless you are zoomed in extremely close like this
  3. The new case doesn't support shadow scale

@clayjohn

clayjohn commented Jan 7, 2026

Copy link
Copy Markdown
Member

Discussed in the rendering meeting today. To get this into a mergable state, we should basically allow both paths, switchable with a project setting.

I.e. add something like use_fixed_pcf_kernel (false by default) and use_fixed_pcf_kernel.mobile (true by default) so that the fixed kernel is only used by default on actual mobile devices. This maintains compatibility, but makes it so switching to soft shadows becomes feasible on mobile devices and standalone VR

@KeyboardDanni

Copy link
Copy Markdown
Contributor

Agreed on making it a project setting, since the Mobile renderer has some use on desktop configs as well (slightly more FPS for games with just basic lighting). Players could have the option to turn it on or off via in-game settings for integrated graphics (which could help, as I noticed my laptop's integrated Radeon has had trouble with high-quality shadowmapping in the past).

@KeyboardDanni

KeyboardDanni commented Jan 15, 2026

Copy link
Copy Markdown
Contributor
  1. You can't tell the difference on textured materials since they hide the artifacts in both cases
  2. You can't tell the difference unless you are zoomed in extremely close like this

Could be an issue for filtered sharp (cel-style) shadows (they'd look a bit blockier). But some trade-offs are to be expected I think.

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.

Mobile renderer: Angular Distance (PCSS) does not work with DirectionalLight3D shadows

5 participants