J3o models ready for android

Hi again, guys.
Are there any j3o models ready for android?. I have some models which work fine in PC, but in Android, I get exceptions related to shaders, vertex, etc… Since I’m not a designer myfself, I don’t know how to fix them, so I wondered if there are any tested models ready to be used in Android. I’m not worried about licenses because I’m planning to share my code. If I have to pay for good models, I can do it.

Can you post the errors? Any model that works on desktop will work on Android. It’s most likely the material being used. If you could post the errors we could help with that.

Hi and thanks in advance for the help.
This is the error I found in emulators (6.0 and 7.2 android versions). I was able to fix it in a real device by setting hardware skinning to false and doing other things but the scene appears with weird colors. I’m thinking about trying to fix it in JMonkey code.

com.jme3.app.AndroidHarnessFragment: SEVERE Exception thrown in Thread[GLThread 151,5,main]
com.jme3.renderer.RendererException: Shader failed to link, shader:Shader[numSources=2, numUniforms=21, shaderSources=[ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment, language=GLSL100], ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex, language=GLSL100]]]
 Error: uniform m_Shininess specified with different precision in different shaders.
 at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1348)
2 Likes

Further investigation tells me the error may be related to a configuration problem in the Android part of the project. I’ll continue investigating and I’ll post my conclusions.

I do not know if it is same issue. I m sorry for posting again same stack trace. It will be great to explain what is the real problem and probably how you resolve it.

com.tech.gladiators E/com.jme3.app.AndroidHarness: SEVERE Exception thrown in Thread[GLThread 1438,5,main]
    com.jme3.renderer.RendererException: Shader failed to link, shader:Shader[numSources=2, numUniforms=22, shaderSources=[ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment, language=GLSL100], ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex, language=GLSL100]]]
    --From Vertex Shader:
    Error: uniform variables in vertex shader do not fit in 256 vectors.
    --From Fragment Shader:
    Error: uniform variables in vertex shader do not fit in 256 vectors.
    
        at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1348)
        at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1360)
        at com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:166)
        at com.jme3.material.Technique.render(Technique.java:166)
        at com.jme3.material.Material.render(Material.java:974)
        at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:614)
        at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:266)
        at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:305)
        at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:877)
        at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:779)
        at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1108)
        at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:497)
        at com.tech.gladiators.MainActivity.update(MainActivity.java:442)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:342)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

Try turning off hardware skinning.

That’s slightly different from my issue, but turning off hardware skinning should be enough to bypass the error.

Is your issue not the error posted above?
…the error that seems to be cause by hardware skinning on android.

How is that different than your issue, slightly or otherwise?

Edit: sorry… since the forum icons are messed up I have trouble keeping different people straight.

I was able to make it works (when I say “works” I mean without errors) but the colors are completely wrong. I’m still investigating (sorry, my real job eats a lot of time) but I’m afraid that something in my configuration on Android project make it fail. I installed exactly the same model (with my default configuration, so the master branch) on my phone and it works.

well this

selected.getControl(SkeletonControl.class).setHardwareSkinningPreferred(false);

does not change anything. Here are the params, Maybe there is something wrong with them.

Diffuse 0.8 0.8 0.8 1.0
UseMaterialColors true
ParallaxHeight 0.05
Ambient 1.0 1.0 1.0 1.0
BackfaceShadows false
NormalMap Flip WrapRepeat_S WrapRepeat_T MinNearestNoMipMaps MagNearest "Textures/Normal/muscle_guy_normal.png"
DiffuseMap Flip WrapRepeat_S WrapRepeat_T MinNearestNoMipMaps MagNearest "Textures/UV/MUSCLE-GUY-NAKED-UV.png"
Specular 0.5 0.5 0.5 1.0
Shininess 50.0

What’s “selected” in your code?. What’s your android version?. I guess your code works well in PC. Did you try it in a real device?

Also on some android devices.

Maybe you set it too late?

Hardware skinning adds a bunch of material parameters, I guess. One per bone or something.

Just loading node from j3o, disable hardware skinning and attaching it to root node.

But definitely there is something related with bones, after I removed SkeletonControl and AnimControl geometry loaded without crashes.

Interesting… If I load the wrong model and I don’t clean the AVD, the error still appears, even although I remove the model.

Well, sorry for the bullshits, little observation with and without SkeletonControl
when com.jme3.renderer.opengl.GLRenderer calls updateShaderData(Shader shader) (which is called when geometry get attached to scene ) difference
is numUniforms in Shader object

shader = (com.jme3.shader.Shader) Shader[numSources=2, numUniforms=22, shaderSources=[ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment, language=GLSL100], ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex, language=GLSL100]]]

and without

shader = (com.jme3.shader.Shader) Shader[numSources=2, numUniforms=20, shaderSources=[ShaderSource[name=Common/MatDefs/Light/Lighting.frag, defines, type=Fragment, language=GLSL100], ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex, language=GLSL100]]]

and this line

boolean linkOK = this.intBuf1.get(0) == 1;

which determines to throw runtime exception or not.

1 Like

My guess is that the first one has the hardware skinning uniforms and the second one doesn’t.

Here it is dirty and fragile workaround, (that seems to work at first look )

SkeletonControl control = selected.getControl(SkeletonControl.class);

        Method method;
        try {
            control.setHardwareSkinningPreferred(false);

            method = control.getClass().getDeclaredMethod("switchToSoftware");
            method.setAccessible(true);
            method.invoke(control);

        } catch (NoSuchMethodException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        }

If you set this before you attach the model to the scene (and it gets rendered) then you shouldn’t have to do all that.

Try it in a simple test app. Or you can look at the code here to confirm: