How can I get shaders to render on Android?
Asked Answered
P

17

0

I'm developing a game with Godot 3.5 GLES2 and running into the problem that shaders that work fine on desktop or web do not draw when I export my project to Android (I can't upgrade to Godot 4 because my project depend on a plugin which does not work for 4). No shader I've tried works - even very simple ones and even the SpatialMaterial when converted to a shader. VisualShaders don't work either. I've tried using GLES3, but I can't even get the program to run in that mode. Is there a way to get shaders to work on Android?

Propensity answered 2/2, 2023 at 0:8 Comment(0)
P
0

Frustration Looks like the solution was to reimport the texture map with the compress mode set to something other than Video RAM.

https://github.com/godotengine/godot/issues/72642

Propensity answered 3/2, 2023 at 1:18 Comment(0)
P
0

You have to enable 3D + effects in the project settings for GLES2, but not all features are supported.

Preindicate answered 2/2, 2023 at 2:4 Comment(0)
P
0

Preindicate Where are those settings located?

Propensity answered 2/2, 2023 at 4:51 Comment(0)
P
0

Preindicate Those settings don't seem to be present. At least I can't find them.

Propensity answered 2/2, 2023 at 6:28 Comment(0)
F
0

Under Rendering > Quality, find Intended Usage header and make sure Framebuffer Allocation.mobile is set to 3D and not 3D without effects or either of the 2D options I guess. Hovering over the Framebuffer Allocation should give a description elaborating further. Even with this tho, if the device hardware is not capable of supporting relevant GLES/glsl version then this might be in vain.

Frustration answered 2/2, 2023 at 10:32 Comment(0)
P
0

Frustration

I tried your suggestion, but it does not help. I would hope that my phone would be able to handle GLES2 shaders since it is fairly new. I'm not sure how I'd check for that. It also seems weird that the Framebuffer Allocation.mobile is greyed out in my editor. Does that indicate something?

Propensity answered 2/2, 2023 at 11:16 Comment(0)
F
0

Propensity It also seems weird that the Framebuffer Allocation.mobile is greyed out in my editor. Does that indicate something?

It's the same for me, think it's just meant to indicate that it's secondary/not relevant to the platform you are running the editor on. Like it only applies to mobile platforms you would export to. But I'm just speculating on that.

edit: btw, I assumed you already have read it in the docs (since it's the top result on google when making a search for it), but should have asked before if you had:

When using GLES2, some custom shaders may break when exporting to Android. This is caused by a lower shader precision being used by default to improve performance. You can force high precision on all shader computations by enabling rendering/gles2/compatibility/enable_high_float.Android project setting, but this has a significant performance cost and won't work on all devices.

Frustration answered 2/2, 2023 at 11:59 Comment(0)
P
0

Frustration There were a few lines like that. The first image I posted shows my GLES2 project settings, which I think is the same as enabling that flag.

Propensity answered 2/2, 2023 at 12:47 Comment(0)
F
0

Have you tried also disabling the half float in compatibility. That could very well be something many mobile devices don't support.

Frustration answered 2/2, 2023 at 14:12 Comment(0)
P
0

Frustration That didn't help either.

Propensity answered 2/2, 2023 at 17:0 Comment(0)
F
0

Have you tried other godot versions with perhaps a smaller sample project?

Frustration answered 2/2, 2023 at 18:46 Comment(0)
P
0

Frustration I just tried exporting a project using Godot 4.0 beta 17 and am getting nothing at all. Even a basic scene that contains just a MeshInstance with the default shader, a light and a camera is just giving me a black screen. My phone is a Samsung SM-A037W.

Propensity answered 2/2, 2023 at 19:53 Comment(0)
F
0

I meant other godot 3 versions, sorry. Should have been more specific. I was thinking along the lines, perhaps there's some bug at play that might have been introduced in the version you are using. And if not using the latest, perhaps it's been fixed in a later one.

Propensity My phone is a Samsung SM-A037W.

https://www.gsmarena.com/samsung_galaxy_a03s-10937.php
https://www.notebookcheck.net/PowerVR-GE8320-Graphics-Card-Benchmarks-and-Specs.372646.0.html

Claims OpenGL ES 3.0 and 3.2 support, I see no mention of 2.0 tho I have a hard time believing it doesn't support it. On the other hand, chipset announcement date is 2014, who knows how well they still support it with drivers...then again, gsm arena clearly indicates it's a 12nm chip, so probably just the gpu arch is ported over from the original 20nm hopefully it is still supported then too.

BTW, gsmarena.com and notebookcheck.net are great for finding out hw specs of phones(and laptops also for the latter). Def. recommend bookmarking them.

Frustration answered 2/2, 2023 at 20:18 Comment(0)
P
0

Frustration I tried again with Godot 3.5.2 rc2. Same problem.

I'm actually a bit more worried now about Godot 4 not being able to render at all. Has this not been implemented yet?

Propensity answered 2/2, 2023 at 22:6 Comment(0)
F
0

Propensity I'm actually a bit more worried now about Godot 4 not being able to render at all. Has this not been implemented yet?

I'm pretty sure it should work.

Frustration answered 2/2, 2023 at 22:35 Comment(0)
P
0

Frustration Looks like the solution was to reimport the texture map with the compress mode set to something other than Video RAM.

https://github.com/godotengine/godot/issues/72642

Propensity answered 3/2, 2023 at 1:18 Comment(0)
P
0

I'm glad you figured it out, but this seems like the sort of thing the texture importer/compressor should do automatically and not just fail with no error message.

Preindicate answered 3/2, 2023 at 5:54 Comment(0)
P
0

Preindicate I'd agree. Also, I got a solution to the Godot 4 display problem too. Since my system does not support Vulkan, I need to set my rendering_method.mobile project setting to gl_compatibility. No idea why that would affect deploying it to my android phone or why that wasn't selected by default because I created my project in Compatibility mode, but that fixed it.

https://github.com/godotengine/godot/issues/72630

Propensity answered 3/2, 2023 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.