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

LightmapGI fails to bake on mobile devices #94297

Open
Saul2022 opened this issue Jul 13, 2024 · 8 comments
Open

LightmapGI fails to bake on mobile devices #94297

Saul2022 opened this issue Jul 13, 2024 · 8 comments

Comments

@Saul2022
Copy link

Saul2022 commented Jul 13, 2024

Tested versions

Reproducible in 4.3 beta 3- Godot 4.2.2 stable

System information

Qualcom adreno 740 Sansung s23+

Issue description

When i tried to bake the lightmap on the vulkan mobile backend, i i tried with the default primitive shapes, unwrapping the uv 2 and the common things when baking.

Then when i tried to bake, it resulted on an error where it says there's no lightmapper. I tried even on the forward + backend , but neither it worled.

And while this may be related to #77001 , in this case it isn't even trying to bake , it just throw an editor and doesn't bake light.

The error is this one
scene/3d/lightmap_gi.cpp:744 - Condition "lightmapper.is_null()" is true. Returning: BAKE_ERROR_NO_LIGHTMAPPER

Steps to reproduce

1 Open the project on your phone.

2 Try to bake the lightmap.

3 See the error in console.

Minimal reproduction project

Lightmap_mobile.zip

@Calinou
Copy link
Member

Calinou commented Jul 13, 2024

This is because the lightmapper module is disabled on the Android editor. Most mobile devices lack memory and reliable enough drivers to consistently bake lightmaps on the GPU. Even if it was possible, it would be extremely slow and prone to thermal throttling.

The editor should better signal this.

@Calinou Calinou changed the title Lightmqp GI fails to bake on mobile devices LightmapGI fails to bake on mobile devices Jul 13, 2024
@Saul2022
Copy link
Author

. Even if it was possible, it would be extremely slow and prone to thermal throttling.

Yea, even making small changes like removing a resource stalls the editor for over 20 seconds on a s23+, hopefully someday android decides to improve this, like this is supposed to be over 4 times faster than my bad igpu pc that died.

The editor should better signal this.

Prob this instead of saying no lightmapper, that was a confusing error that didn’t really help.

@Calinou
Copy link
Member

Calinou commented Jul 14, 2024

It turns out the lightmapper can actually work on on some Android devices! I built an APK with the lightmapper module and xatlas enabled: https://0x0.st/XLgd.zip

The visual output is the same as when baking on my PC. Note that I only expect this to be usable on high-end Android devices – preferably tablets or gaming phones, as they have superior cooling to standard phones.

It can successfully bake lightmaps on my Samsung Galaxy Tab S9 Ultra (16 GB RAM/1 TB storage version), although the progress dialog isn't displayed (so it appears to freeze during baking). It bakes the scene in about 6 seconds in Normal quality, but Ultra quality is much slower, clocking in at 1m21s. Remember that long durations will run into thermal throttling unless your device has active cooling. Keep in mind the battery life implications of baking lightmaps too.

The JNLM denoiser works as well (it's disabled by default in the MRP). OIDN can't be used as it doesn't have an Android port, and it would be quite slow when running on the CPU given it does not have a Vulkan compute implementation.

The editor APK size (arm64 debug) only grows by 137 KB when both the lightmapper_rd and xatlas_unwrap modules are enabled. Export template binary sizes are not affected, as these modules are only enabled in editor builds.

Testing project: test_lightmapper_android.zip

@m4gr3d What do you think about enabling the lightmapper modules at build-time for the Android editor? This will likely need documentation and/or different default settings to better cater to baking on a mobile device. For example, we can add overrides to the lightmapper project settings to reduce the default ray counts.

This will also need testing on more SoCs, as I expect some will have driver bugs that break lightmap baking. Device memory size also needs to be tested before baking, as you'll probably need a device with at least 8 GB of RAM to be able to bake scenes in a real world project.

@Saul2022
Copy link
Author

Saul2022 commented Jul 15, 2024

It turns out the lightmapper can actually work on on some Android devices! I built an APK with the lightmapper module and xatlas enabled: https://0x0.st/XLgd.zip

That great, tried ut too with the mrp and it works well on the s23+ (5-6 second bake on ultra and with my mrp, similar to my pc)

On your mrp with ultra and denoised it takes 2. minutes and 14 seconds without gen probes and didn"t look too hot ( i use the built in ram+ thing on sethings) and with gen probes 2.31 and some warnings from ray degrading.

– preferably tablets or gaming phones, as they have superior cooling to standard phones.

Would be gpod to document that for other users

storage version), although the progress dialog isn't displayed (so it appears to freeze during baking)

True, happens to when try to save scene, play game mode or prob build .net , along with not having a separate window for editor and game mode.

@m4gr3d
Copy link
Contributor

m4gr3d commented Jul 15, 2024

@m4gr3d What do you think about enabling the lightmapper modules at build-time for the Android editor? This will likely need documentation and/or different default settings to better cater to baking on a mobile device. For example, we can add overrides to the lightmapper project settings to reduce the default ray counts.

@Calinou Sounds like a good idea, let's go ahead and enable it!

Any ideas why the progress dialog is not rendering during baking?

@m4gr3d
Copy link
Contributor

m4gr3d commented Jul 15, 2024

along with not having a separate window for editor and game mode.

@Saul2022 That's a limitation due to your device screen size. On tablet the editor is able to open a separate window given the larger screen estate.

While not recommended, you can override whether the game window opens in the same or separate window via the run/window_placement/android_window editor setting.

@Calinou
Copy link
Member

Calinou commented Jul 15, 2024

I found a situation where lightmap baking doesn't work on a mobile device, but it does on desktop. When using the Compatibility rendering method, lightmaps can be baked by creating a local RenderingDevice that uses Vulkan and runs the GPU lightmapper. OpenGL then retrieves the generated texture and applies it to the scene. This process works fine on desktop, but when done on Android (on the same device as I mentioned above), I get:

drivers/gles3/storage/texture_storage.cpp:717 - Condition "t->is_render_target" is true.

The baking is occurring (bake time changes according to quality), but the results of the bake are not visible. Previous bake data is overridden by this empty, invalid bake data (so the lightmap is fully black).

Disabling the denoiser does not avoid this issue.

Curiously, I see the same error message on desktop after baking, but here I can see the results.

Edit: Issue opened: #94407

@Saul2022
Copy link
Author

Saul2022 commented Jul 16, 2024

While not recommended, you can override whether the game window opens in the same or separate window via the run/window_placement/android_window editor setting.

Great, It works 😄, thank you. Didn't find much issues with it

(edit: there are issues, mostly with set as editor sometimes not working unless set to by side with editor and then clicking on play and then turn on editor, though it only works one time and the constant loading timws of the issue i linked here )
and atleast this greatly improves editor ussability,though why is not recommended. Aside from this i noticed that editor is quite slow at removing files( taking like 1 minute), i opened a issue
#94416

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

4 participants