Failed to link lighting shaders on Android

Just trying to give some more light on this. GL and GLES have different version numbering. As far as I know:

GL ES 2.0 has GLSL ES 100 based on desktop GLSL 120-150 (not sure which one)
GL ES 3.0 has GLSL ES 300 based on desktop GLSL 330

That’s why that comparison of gles2+glsl100 is there

I started trying to add support for GLES 3.0 in my fork but it’s hard and a really big effort is required to properly upgrade shaders to GLSLES300, otherwise there’s nonsense in initializing gl context as 3.0.

A quick reference of porting to 300: http://www.shaderific.com/blog/2014/3/13/tutorial-how-to-update-a-shader-for-opengl-es-30

About the different issues here…

The sampler2DShadow may not be supported on GLESSL100 or depending on the extension, it was supposed to be addressed but the patch to shadows.glsllib was not correct. Se the post at Shadows and post processor filters issues and proposals - #7 by joliver82

The glsllib should be as follows:

#if __VERSION__ >= 130
    // Because gpu_shader5 is actually where those
    // gather functions are declared to work on shadowmaps
    #extension GL_ARB_gpu_shader5 : enable
    #define IVEC2 ivec2
    #if defined HARDWARE_SHADOWS
        #define SHADOWMAP sampler2DShadow
        #define SHADOWCOMPAREOFFSET(tex,coord,offset) textureProjOffset(tex, coord, offset)
        #define SHADOWCOMPARE(tex,coord) textureProj(tex, coord)
        #define SHADOWGATHER(tex,coord) textureGather(tex, coord.xy, coord.z)
    #else
        #define SHADOWMAP sampler2D
        #define SHADOWCOMPAREOFFSET(tex,coord,offset) step(coord.z, textureProjOffset(tex, coord, offset).r)
        #define SHADOWCOMPARE(tex,coord) step(coord.z, textureProj(tex, coord).r)
        #define SHADOWGATHER(tex,coord) step(coord.z, textureGather(tex, coord.xy))
    #endif

    #if FILTER_MODE == 10
        #define GETSHADOW Shadow_Nearest
        #define KERNEL 1.0
    #elif FILTER_MODE == 1
        #ifdef HARDWARE_SHADOWS
            #define GETSHADOW Shadow_Nearest
        #else
            #define GETSHADOW Shadow_DoBilinear_2x2
        #endif
        #define KERNEL 1.0
    #endif
#else
    #define IVEC2 vec2
    #if defined GL_ES
        #define SHADOWMAP sampler2D
        #define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
    #elif defined HARDWARE_SHADOWS
        #define SHADOWMAP sampler2DShadow
        #define SHADOWCOMPARE(tex,coord) shadow2DProj(tex, coord).r
    #else
        #define SHADOWMAP sampler2D
        #define SHADOWCOMPARE(tex,coord) step(coord.z, texture2DProj(tex, coord).r)
    #endif
...

I would like to get some spare time to get into this topic and finally get shadows to properly work on android (in adition to this quick fix)

About SSAOFilter, I was using SSAO in my project for android also and it worked (slow as hell) so I removed it.

The different precision issue, is weird, reading the code of Lighting.vert and Lighting.frag, there’s no precision specified in the code (at least nowadays at github). Maybe the issue is caused by the GLRenderer setting the precision only for fragment shaders at method updateShaderSourceData?

            if (gles2) {
                // request GLSL ES (1.00) when compiling under GLES2.
                stringBuf.append("#version 100\n");
                
                if (source.getType() == ShaderType.Fragment) {
                    // GLES2 requires precision qualifier.
                    insertPrecision = true;
                }
//... more code here...
        if(insertPrecision){
            // precision token is not a preprocessor dirrective therefore it must be placed after #extension tokens to avoid
            // Error P0001: Extension directive must occur before any non-preprocessor tokens
            int idx = stringBuf.lastIndexOf("#extension");
            idx = stringBuf.indexOf("\n", idx);
            stringBuf.insert(idx + 1, "precision mediump float;\n");
        }

Last but not least, I don’t think using the emulator for testing gl graphical apps is the best way to go. It’s been improved along the years but it’s not the same as a real device.

There’s also some openGLES emulators like qualcomm’s (https://developer.arm.com/tools-and-software/graphics-and-gaming/graphics-development-tools/opengl-es-emulator) that I’ve not used but look good