Can't get spatial materials to work in Android GLES 2

lawnjellylawnjelly Posts: 27Member

I've been having great success with Godot on Linux and Windows, but so far I haven't been able to get the graphics on any of my Android builds to work. I'm working in 3d with Godot 3.1 stable although I have tried a recent nightly of 3.2 development and had the same problem.

The issue is that even with a new project OpenGLES 2, creating a 3d box with no material, that works and shows up in my android emulator (I have android studio installed). However once I assign a default spatial material to an object with a simple albedo colour, the glsl shader no longer compiles, and the object no longer shows up. :neutral:

I know this from looking at the adb logcat output, It is something like this:

04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: ERROR: SceneShaderGLES2: Program linking failed:

Error: uniform m_albedo specified with different precision in different shaders.

04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: At: drivers/gles2/shader_gles2.cpp:129:_display_error_with_code() - SceneShaderGLES2: Program linking failed:

Error: uniform m_albedo specified with different precision in different shaders.

04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: ERROR: Method/Function Failed, returning: __null
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: At: drivers/gles2/shader_gles2.cpp:414:get_current_version() - Method/Function Failed, returning: __null
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: **ERROR**: Condition ' !version ' is true. returned: false
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: At: drivers/gles2/shader_gles2.cpp:88:bind() - Condition ' !version ' is true. returned: false
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: **ERROR**: Condition ' !version ' is true. returned: -1
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: At: drivers/gles2/shader_gles2.h:254:_get_uniform() - Condition ' !version ' is true. returned: -1
04-19 10:00:24.802 3153-3169/com.lawnjelly.minimalandroidtest E/godot: **ERROR**: Condition ' !version ' is true. returned: -1

This is on linux mint 18.2, Intel i5-7500T, Intel HD graphics 630
The android emulator is API 21, but same thing happened on later API and also on my Nexus 7 2012 tablet.

I know from experience different devices can be very finicky about shaders particularly precision, but this is even on the stock emulator. Should this be happening? Or is there a way around this? Is anyone using spatial materials in 3d successfully in GLES 2 on android?


Tags :

Comments

  • lawnjellylawnjelly Posts: 27Member

    Ok done a bit more research, I suspect this is an issue I should add to github. If I convert the default spatial material to a shader, I can comment out line by line and find which is causing the glsl shader compilation error.

    It turns out it is almost any of the uniforms, I can get basic texture mapping with just:

    uniform sampler2D texture_albedo : hint_albedo;
    void fragment() {
    vec2 base_uv = UV;
    vec4 albedo_tex = texture(texture_albedo, base_uv);
    ALBEDO = albedo_tex.rgb;
    }

    However specular, uv1_scale, uv1_offset and probably most of the others are causing this error:

    Error: uniform m_albedo specified with different precision in different shaders.

    It may be that some hardware / android versions are tolerant and workaround this error, but given that it doesn't even work on the emulator, it suggests it is something that should be fixed.

  • wombatstampedewombatstampede Posts: 122Member
    edited April 19

    Interesting. Are you using a custom build of Godot 3.1 or just the standard download version?

    I've tested my Android project (GLES2) with two different devices so far without any severe problems (other than my own programming errors).

    I might be able to get access to a Nexus 7 during the next days to try that out.
    Tried my app on a Nexus 7. Maybe a 2014er edition though. Worked ok so far. Also with Albedo only materials.

  • lawnjellylawnjelly Posts: 27Member
    edited April 20

    Just the standard 3.1 stable it happens with, as well as both a nightly build of development 3.2 and also I've compiled the master from source and the same thing. I will try and do some more testing on devices to pin it down better.

    Unfortunately I've found GLES 2 support on android in general to be very flaky, what works on one device may not on another, there are bugs in some drivers and some are more lax with letting errors through. I've had lots of precision issues doing my own non-godot stuff.

    From the adb log, it sounds like this may be a genuine error for something that is not meant to be allowed (the user specifying the same uniform with different precision values). So the behaviour is undefined, perhaps it just uses the highest precision in some drivers and in others it throws an error.

    I created an issue in the issue tracker:
    https://github.com/godotengine/godot/issues/28199

    It may be related to this:
    https://github.com/godotengine/godot/issues/22631

    Latest Info:
    After further testing (getting logcat to work in android studio seems a case of praying to the gods!) it turns out that the failure on Nexus 7 tablet was due to another issue : the exported APK was for some reason trying to load s3tc textures which weren't included in the package, only the etc textures. I was able to force it produce an APK that loaded the etc textures by removing the s3tc textures in project settings. This breaks the desktop build for now but I'll see if there is a way around this. It is a separate issue and less of an immediate problem.

    It turned out it likely doesn't work at all on CatB15 phone because the android version is too early (before API 18).

    So as of now it is just an issue which is occurring in the android studio emulator for me. I have no idea how the GLES works in the emulator, whether it just passes it straight to the desktop driver or if it does some error checking in between so I'm not sure if the uniform error is coming from the emulator or graphics driver.

Sign In or Register to comment.