[SOLVED] Can't import shape keys properly

Guys, hello. Why can’t i import my model with shape keys in gltf (from blender) properly. It’s always “RendererException: Cannot recompile shader source” or “RendererException: compile error in: ShaderSource”. But if I uncheck normals in gltf export settings, everything is fine, but the model becomes solid black and I can’t do anything.

https://ibb.co/cr378Lv

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/Lighting.vert, defines, type=Vertex, language=GLSL150]
0(459) : error C1111: non-lvalue actual parameter #2 cannot be out parameter (“norm.28”)

at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1476)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1503)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1567)
at com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:158)
at com.jme3.material.Technique.render(Technique.java:166)
at com.jme3.material.Material.render(Material.java:1026)
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:272)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.base/java.lang.Thread.run(Thread.java:834)

My simpleInitApp():
public void simpleInitApp() {
setTimer(new EraseTimer());

    viewPort.setBackgroundColor(ColorRGBA.LightGray);
    rootNode.addLight(new DirectionalLight(new Vector3f(-1, -1, -1).normalizeLocal()));

    Spatial model = assetManager.loadModel("Models/untitled.glb");

    File storageFolder = JmeSystem.getStorageFolder();
    file = new File(storageFolder.getPath() + File.separator + "g8m.j3o");
    BinaryExporter be = new BinaryExporter();
    try {
        be.save(model, file);
    } catch (IOException e) {
        e.printStackTrace();
    }

    assetManager.registerLocator(storageFolder.getPath(), FileLocator.class);
    model2 = assetManager.loadModel("g8m.j3o");
    model2.setLocalTranslation(0, 0, 0);
    model2.depthFirstTraversal(new SceneGraphVisitor() {
    @Override
    public void visit(Spatial spatial) {
        if (spatial instanceof Geometry) {
            if (((Geometry) spatial).getMesh().hasMorphTargets()) {
                System.out.println("Found morphs: " + ((Geometry) spatial).getMesh().getMorphTargets().length);
                myGeom = (Geometry)spatial;
                weights = new float[((Geometry) spatial).getMesh().getMorphTargets().length]; 
                myGeom.setMorphState(weights);
            }
        }
    }
});

    Material sphereMat = new Material(assetManager,
    "Common/MatDefs/Light/Lighting.j3md");
    sphereMat.setBoolean("UseMaterialColors",true);
    model2.setMaterial(sphereMat);
    model2.setLocalTranslation(0, 0, 8);
    rootNode.attachChild(model2);

}

After unchecking normals:

or i can get:
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: Cannot recompile shader source
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1363)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1503)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1567)
at com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:158)
at com.jme3.material.Technique.render(Technique.java:166)
at com.jme3.material.Material.render(Material.java:1026)
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:272)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.base/java.lang.Thread.run(Thread.java:834)

Hi

Shape keys are not supported in Lighting.j3md material, you should use PBRLighting.j3md.

Yeah, that’s because morph animation (shape key) is currently broken in JME 3.3.0-beta1. Please see this issue for details :

It’s already solved in master branch so you need to compile engine from the master branch or wait for 3.3.0-beta2 release.

Thank you for your answer.
I changed the material, but still have an exception:

com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Light/PBRLighting.vert, defines, type=Vertex, language=GLSL150]
0(417) : error C1111: non-lvalue actual parameter #2 cannot be out parameter (“norm.11”)

at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1476)

Please read my above post.

Oh, im sorry. Thanks for help

1 Like

was mentioned that need use GLTF exporter too?

Also please note shape keys can be used manually via code,
but i was unable to find a way how to use Blender shape keys animations.
(maybe it was fixed by GLTF/etc - i didnt check it last time)

Anyway you can do things like lipsync, my example:

Like Ali already said, you just need use 3.3-alpha5 or 3.3-beta2 version or above. In blender i dont remember, but i belive you also needed to have/remove “current shape key action selected” to make GLTF export them, but they might also already fix it (since it was long time ago). Same as i noticed they fixed GLTF exporter animation sampling, so no need bake IK animations manually no more.

Actually was inspired by your example a couple of days ago. It is a pity that it is not described in the documentation.

It does now.
https://wiki.jmonkeyengine.org/jme3/external/blender/blender_gltf.html#shape-keys

1 Like

here is full link that explain even more(about lipsync itself):

about shape keys, @mitm i see added nice documentation.
There are missing some subpoints like:

  • currently only manual usage of shape keys allowed (due to gltf or jme animation not export?)
  • shape keys can be selected by index(but there was commit to select them by name, idk if its in beta versions already)
1 Like

Manual as in how?

Again, how to do so?

I haven’t used gltf animations with shape keys before. I like the concept.

Manual as in how?

i mean you cant do animComposer.setCurrentAnimation(“shapeKeyAnimation”) but you need do something similar like morphs.get(i).setWeight(weight).

Again, how to do so?

I haven’t used gltf animations with shape keys before. I like the concept.

im not in work now, but it was like .get(i) just to get morph. There was commit for getting by Name, so it is also probably now available.

Of course, you can do it.

To get sure I made a simple test in Blender 2.81 and added two shape key animations to it. And I can play it in JME using animComposer.setCurrentAnimation() just fine.

I can upload the Gltf file with the example code in case you want to take a look.

Note I am using Gltf addon v1.2.33.

1 Like

oh, when i were playing arround i remember not only i was unable to play shape key animations.

Maybe it was fixed in later time.

Good to know! You could just show Blender configuration, maybe i also had something wrong there.

Yeah, probably.

I created a simple test based on this tutorial on YT:

and then:
DopeSheet → ShapeKeyEditor → PushDown

That’s it.

2 Likes

thanks! good to know it works.

Then i dont feel like GLTF / animation system have issues at all. It works fine, without issues now.
(earlier IK also needed to be baked, now GLTF “sample animations” works fine for IK animations thats nice)

Added the video. Nice.

1 Like

Thought to mention this just in case, I am not the author of video. It is done by someone else.

yeah, i noticed this, initially also thought its yours, but title definetly refer only to Blender.

But still, it would be nice have someone in JME who have good voice / courage to make YT video tutorial series too. (more like a advertisment of engine, not only just to help new people)

Sorry that my post was misleading, I edited my post.

1 Like