Effekseer Native for JME (wip)

Now it compiles! But with this code I don’t see the effect:

import com.jme.effekseer.EffekseerEmitterControl;
import com.jme.effekseer.EffekseerPostRenderer;
import com.jme3.app.SimpleApplication;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;


public class HelloJME3_2 extends SimpleApplication {

    public static void main(String[] args) {
        HelloJME3_2 app = new HelloJME3_2();
        app.setShowSettings(false);
        AppSettings settings = new AppSettings(true);
        app.setSettings(settings);
        app.start(); // start the game
    }

    @Override
    public void simpleInitApp() {

// Add a filter post processor to your viewPort
        FilterPostProcessor fpp=new FilterPostProcessor(getAssetManager());
        getGuiViewPort().addProcessor(fpp);

// Add Effekseer Renderer
        fpp.addFilter(new EffekseerPostRenderer(getAssetManager()));

// Load an effect
        EffekseerEmitterControl effekt=(EffekseerEmitterControl)getAssetManager().loadAsset("Effekts/prova.efkefc");

// Set a driver (optional)
//        effekt.setDriver(
//                new EmissionDriverGeneric()
//                        .emitFunction(EffekseerEmitterEmitFunctions.emitLoop(100,0,1f,2f))
//                        .shapeFunction(EffekseerEmitterShapeFunctions.pointFollowingSpatial())
//        );

// Attach to a spatial
        Node n=new Node();
        n.addControl(effekt);


        guiNode.attachChild(n);
    }
}

Please note that I attached the effect to the gui node

Yeah, i didn’t consider the usecase of an effect attached to a viewport without depth buffer, i am preparing a patch.

Done. This is the test code

import com.jme.effekseer.EffekseerEmitterControl;
import com.jme.effekseer.EffekseerPostRenderer;
import com.jme3.app.SimpleApplication;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;

public class EffekseerTestGUI extends SimpleApplication{

    public static void main(String[] args) {
        EffekseerTestGUI app=new EffekseerTestGUI();
        app.setShowSettings(false);
        AppSettings settings=new AppSettings(true);
        settings.setRenderer(AppSettings.LWJGL_OPENGL3);
        app.setSettings(settings);
        app.start(); // start the game
    }

    @Override
    public void simpleInitApp() {

        // Add a filter post processor to your viewPort
        FilterPostProcessor fpp=new FilterPostProcessor(getAssetManager());
        getGuiViewPort().addProcessor(fpp);

        // Add Effekseer Renderer
        fpp.addFilter(new EffekseerPostRenderer(getAssetManager(), false /*Disable depth test from the scene*/));

        // Load an effect
        EffekseerEmitterControl effekt=(EffekseerEmitterControl)assetManager.loadAsset("effekts/Pierre/Flame.efkefc");

        // Set a driver (optional)
        //        effekt.setDriver(
        //                new EmissionDriverGeneric()
        //                        .emitFunction(EffekseerEmitterEmitFunctions.emitLoop(100,0,1f,2f))
        //                        .shapeFunction(EffekseerEmitterShapeFunctions.pointFollowingSpatial())
        //        );

        // Attach to a spatial
        Node n=new Node();
        n.addControl(effekt);
        n.setLocalTranslation(cam.getWidth() / 2,cam.getHeight() / 2,0);
        n.setLocalScale(50f);

        guiNode.attachChild(n);
    }
}

Note: the renderer has to be initialized without depth test for the guiNode

new EffekseerPostRenderer(getAssetManager(), false /*Disable depth test from the scene*/)

The particles will still test against each other (if configured to do so in the effect editor) but not against the scene.

Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Effekseer/Composer.frag, defines, type=Fragment, language=GLSL150]
ERROR: 0:53: 'texture2D' : function is removed in Forward Compatibile context 
ERROR: 0:53: 'texture2D' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:57: 'texture2D' : function is removed in Forward Compatibile context 
ERROR: 0:57: 'texture2D' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:61: 'texture2D' : function is removed in Forward Compatibile context 
ERROR: 0:61: 'texture2D' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:65: 'texture2D' : function is removed in Forward Compatibile context 
ERROR: 0:65: 'texture2D' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:82: 'm_Texture' : undeclared identifier 
ERROR: 0:82: 'texCoord' : undeclared identifier 
ERROR: 0:82: 'getColor' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:82: '=' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:83: 'm_ParticlesColor' : undeclared identifier 
ERROR: 0:83: 'getColor' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:83: '=' :  cannot convert from 'const float' to '4-component vector of float'
ERROR: 0:85: 'outFragColor' : undeclared identifier 
ERROR: 0:85: 'assign' :  cannot convert from '4-component vector of float' to 'float'
ERROR: 0:87: 'rgb' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:87: 'rgb' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:87: 'mix' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:88: 'a' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:89: 'a' :  field selection requires structure, vector, or matrix on left hand side 
ERROR: 0:89: 'a' :  field selection requires structure, vector, or matrix on left hand side 

When i reduced the minimum gl version, i forgot to import GLSLCompat. It should be fine now.

Ok now it doesn’t crash :slight_smile:

I’ve uncommented the driver and

Cannot resolve symbol 'EmissionDriverGeneric'

Effect in editor vs Effect ingame:

Be sure to import the correct class
import com.jme.effekseer.driver.EffekseerEmissionDriverGeneric;

Can you send the effect?

https://we.tl/t-UQsIA26jLL

Cannot resolve symbol ‘driver’

I can’t reproduce the issue, however i am pretty sure it is caused by not clamping the alpha in the composer shader. I fixed that, i also refactored the render filter to be quicker and more robust.
Now it also fully support gamma corrected rendering (that might also contribute to some rendering discrepancies).

Regarding the missing symbol, i think you have something wrong in your classpath, please run gradle clean build --refresh-dependencies, because i am using the same artifacts and the class exists for me.

Done but didn’t help.

Also these don’t exist on github:

import com.jme.effekseer.EffekseerEmitterEmitFunctions;
import com.jme.effekseer.EffekseerEmitterShapeFunctions;

Check the new test code here:

i had to change some things to allow serialization

error: cannot find symbol
import com.jme.effekseer.EffekseerEmitterShapeFunctions;
^

As I said, these class aren’t part of jme-effekseerNative. See for yourself on github

Indeed, this class is not used in the new code

Ok now it worked, thanks! :slight_smile:

Now I’m adding the effect into my game. Previously I had:

  • OpenGL Version: 4.3.0
  • GLSL Version: 4.30
  • Profile: Compatibility
    Renderer: LWJGL-OpenGL2

Now I have

  • OpenGL Version: 3.2.0
  • GLSL Version: 1.50
  • Profile: Core
    Renderer LWJGL-OpenGL3

But most importantly:

Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=MatDefs/shockwave.frag, defines, type=Fragment, language=GLSL150]
ERROR: 0:8: 'varying' : not available in current GLSL version 4
ERROR: 0:14: 'texCoord' : undeclared identifier 
ERROR: 0:14: '=' :  cannot convert from 'float' to '2-component vector of float'
ERROR: 0:? : 'gl_FragColor' : variable is removed in Forward Compatibile context 
ERROR: 0:24: 'texture2D' : function is removed in Forward Compatibile context 
ERROR: 0:24: 'texture2D' : no matching overloaded function found (using implicit conversion) 
ERROR: 0:24: 'assign' :  cannot convert from 'const float' to 'FragColor 4-component vector of float'

So… I take that I moved from “compatibility” to “core” but not sure if I upgraded or downgraded the opengl :confounded:

The error of the shader code above means that there is a bug or am I trying to use a (no longer) available GLSL feature?

EDIT: Ah ok, core removes old API

you can include this library at the beginning of your shader

it will redefine old apis to the new syntax

Thanks! BTW, you might want to set this

setRenderer(AppSettings.LWJGL_OPENGL32);

because LWJGL_OPENGL3 is deprecated.

Yeah, i was involved in deprecating it :sweat_smile:, but I am not sure if it is deprecated in the old version of the engine used to compile the library. Actually i should probably update the dependencies to the latest stable, they are compileOnly anyway.