OpenGL ES 3.0 and newer on android

Hi all,

I’ve been working on adding support for OpenGL ES 3.0, GLSL 300 and newer to jme3. Nowadays it includes the following:

  • Initialize the proper opengl context (2.0, 3.0, 3.1…)
  • Added Caps for all of the new supported features
  • Added Instancing as core feature of GLES30 and newer
  • Properly adding versioning to shaders (#version xxx es) to shaders
  • Added GLSL320,GLSL310 and/or GLSL300 to most materials depending on the required level for them to work properly
  • Added depth24 texture usage if hardware supports it
  • Enabled Geometry shaders and tessellation (3.2 core feature and 3.1 as extension) and fixed compilation errors on the examples
  • Enabled glBlitFramebuffer
  • Added GLSL300 to filters not able to work with GLSL100.
  • Created Glsl300ShaderGenerator to support GLSL300 in shadernodes
  • Fixed most shader compilation issues (strict type checking, adding OpenGL ES specific extensions, function usage depending on version and some other)
  • Set default precision to highp solving most filter issues although maybe a little slower. Added specific sampler precision definition for gles300 or newer
  • Make use of GL_TEXTURE_MAX_LEVEL in GLES300 to avoid black rendering of non complete mipmapped textures
  • Changed some assets from compressed formats not supported in android to RGB/RGBA depending on the needs so all effects and tests can run also on android
  • updated precompiled android.jar to have access to newest android API
  • enabled some other core features of GLES300, GLES310 and GLES320
  • Fixed build issues in jme3-android-examples
  • Added 3D texture and texture array support
  • Added float texture formats, fixed rgb8 format if having cap rgb8 and fixed glTexImage2D call on AndroidGL
  • PBRLighting works and any other effect requiring HDR texture formats should work also
  • Effects and postprocessing
  • Multisampling


  • Fixed most issues with shadow rendering in android (GLES 2.0 and GLES 3.0 or better) although some glitches still apear depending on ShadowMode of the nodes
  • Fixed water filter. Still some rendering glitches in my old redmi3 (gles3.0). The water renders properly but the rest of the scene is overwritten in red


  • Finish the previous half-done work… :smile:

If you feel there’s something interesting I’m missing please comment and I’ll add it to the list although may not be in the first PR

You can find it in branch android-gl3 at my fork: GitHub - joliver82/jmonkeyengine at android-gl3

Please feel free to try it and give me feedback :wink:

I’m not creating a PR still as I don’t think it’s mature enough but at least nowadays it’s stable

I hope you like it :wink:

EDIT: re-written post with all stuff done, half-working and pending


im not android developer, but i think a lot of them should be happy :slight_smile: i heard a lot issues related to shaders on phones.

Good job, thanks :slightly_smiling_face:

Thank you greatly @joliver82 for your hard work and contribution to the android side of jME.
I am a huge Android fan and have a few apps out on the play store.

I however have one question to you, what is your development cycle for android apps?
In other words how do you develop? Do you use jMonkeyPlatform, gradle or android studio?

Any feedback would be appreciated.

@joliver82 have you also tried PBRLighting in android?

Sadly my development cycle for jme3 based android apps is unconfortable as hell. :confused:

As I started with really old versions of jme3 (alpha2) and my project was not defined only for android, I’m using jmonkey sdk + a slightly modified android studio project from GitHub - noncom/jme-android-example

I have NBandroid installed and enabled android build so the mobile path is created. I used that as base for the project I linked (adding symbolic links for libraries, code, assets and so).

The cycle is like:

  • Work on the game itself in jmonkey
  • Make a full build, so although android compilation fails it generates all libs, assets and so in the destination folder used by the android studio project
  • Add android specific functionality in android studio and generate the apk

Probably there are plenty of better options, like just using the linked project or any other similar as starting point for your development but if using android studio or any other IDE you’ll loose the functionality jmonkey SDK has…

If anyone knows a better approach I’ll be happy to hear from you :wink:

1 Like

Not still. I’m adding stuff day by day and now I’m focused on getting shadows working 100% which is taking me more time than expected. It’s a complex topic for me :sweat_smile:

1 Like

Not an android developer, but hopefully this might be helpful, I was able to create my ever first android hello world app in JME easily using this Gradle template.


After build it generates two apks, one inside debug directory an one in the release directory. The debug one can be easily installed on smartphone, but I guess the release one needs to be signed with Java Keystore which unfortunately I couldn’t figure it how.

Thanks @joliver82 for sharing.

Well my approach is a bit different.
I am also using the jMonkeyEngine SDK except the difference is I actually build android using the old sdk ant build as documented in the wiki.

I have to make my own build of the SDK because in order for the NBAndroid plugin to work in the jME sdk you need version 8.1 of netbeans.

After that I also need an old version of Android SDK manager but I install the latest versions of android platform tools and sdk tools.
I use this version:

Then it is a matter of setting up my custom jME SDK to point to that android sdk.

So far this works for me very good and has been for years now.

Hope it helps a bit if you want to go into that route.

I can’t wait to see the shadow work you are doing.
If you want I can also test the code by creating some sample test projects for the test cases.

I could have used the gradle scripts from the android studio project I used as reference instead of fully install android studio but I think for my use case it’s better to have it, specially if you develop other android apps not jme based and/or to be able to debug android apps more or less easily.

I miss the good old times when eclipse was de default IDE for android… :stuck_out_tongue:

On the other hand, it’s a good manual :wink: I would have loved to have it when I started trying to compile my app for android with multidex (that’s the reason I moved to android-studio and gradle)

It’s a good aproach. I didn’t realize the issue with nbandroid was that newest jmonkey sdk is based on a newer netbeans release. Anyway, I would prefer to have NBandroid updated but it seems that the developer stoped mantaining it :frowning:

There’s a project called nbandroid-v2 (GitHub - NBANDROIDTEAM/NBANDROID-V2: Netbeans Android support plugin) that I’ve not tried still but seems to be less stable / finished than original nbandroid was in its time. Have any of you had time to check it?

Hi, hopefully you can help me with this…

I’m calling some methods of the GLES31 class ( but I cannot get it to compile:

       GLES31.glGetMultisamplefv(pname, index, val);
 symbol:   variable GLES31
 location: class AndroidGL

The build.gradle is the default of jme3:

if (!hasProperty('mainClass')) {
ext.mainClass = ''

dependencies {
    compile project(':jme3-core')
    compile project(':jme3-plugins')
    compileOnly 'android:android'

The "compileOnly ‘android:android’ is supposed to get the android dependencies but it’s failing for this class.

This class was included in API level 21, so maybe I should add something to the gradle file that I’m not aware of…

Thanks :wink:

There are quite a few more gradle settings to configure. Not sure if you’re aware since you didn’t specify them in your post.

There’s a target and min version, etc.

1 Like

Thanks for your comment @jayfella but it’s the whole build.gradle file. What I’m trying to compile is the jme3-android library, not an application, so all other settings related to android are not accesible :

  • What went wrong:
    A problem occurred evaluating project ‘:jme3-android’.
    > Could not find method android() for arguments [build_akah3vddwdy7zw5ofwuoggqvr$_run_closure1@a96f79e] on project ‘:jme3-android’ of type org.gradle.api.Project.

I could try to change it from regular java to android library (apply plugin: ‘’) and setting all stuff there but I think there should be other method.

OK, I found out… it’s the library at /jmonkeyengine/lib/android.jar the one having the android classes. Just updating it to a newer version including GLES31 and GLES32 will suffice


Sorry, I missed the part of your comment about properly signing the apk. I use a small shell script as follows:

cp android-studio-project/app/release/app-release.apk app.apk 
jarsigner -verbose -keystore ./keystore_file -storepass store_password -keypass key_password -sigalg SHA1withRSA -digestalg SHA1 app.apk key_name
rm app-align.apk
zipalign 4 app.apk app-align.apk

basically it’s removing bad signature information, sign it again and align the zip :wink:

1 Like

Hi there!

I’m working trying to get shadows to android gles3 but I’m facing a weird issue, depending on the device I’m getting the shadows rendered or just overriding the scene in grey:


And I don’t understand why. The depth map is properly generated in all devices tested and I’ve simplified the rendering by creating a new material based on the unshaded.j3md but instead of using the default PostShadow.frag I’m using a simplified version that’s just rendering depth over the scene:

#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Shadows.glsllib"

varying vec4 projCoord0;
varying vec4 projCoord1;
varying vec4 projCoord2;
varying vec4 projCoord3;
    varying float nDotL;

    varying vec4 projCoord4;
    varying vec4 projCoord5;
    uniform vec3 m_LightPos;
    varying vec4 worldPos;
    #ifndef PSSM        
        varying float lightDot;

void main(){   

        if(nDotL > 0.0){

            shadow = 1.0f;
            shadow = texture(m_ShadowMap0,;

    shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
    gl_FragColor = vec4(shadow, shadow, shadow, 1.0);


Everything is defined to use GLSL300 ( #version 300 es) added to the header dynamically to the shader by new jme code I added.

I hope there’s any shader expert over here to help with this :wink:

It’s been one week focused on shadows and finally I got them working rendering on both GLES2.0 and GLES3.0:


I’ve tested it on all my devices with good results. It would be nice if you have time to test it and give me some feedback :wink:

Now I’m into PBR ligthing which at least the shaders compile properly now (but don’t render any effect)


Great job @joliver82

I hope you have success with PBR too. :slightly_smiling_face:

btw, it is recommended to use to upload your screenshots, then you won’t have a limit on image size.