Particle Effects Are Not Rendering In Front Of Terrain

Hello JME3! I am currently working on an FPS to get better at JME3 in order to make the games that I might eventually publish. I tried to use the SDK but it is simply too buggy for me (I assume this is at least, in part, due to the fact that I am running Fedora 21 Linux and the developers based on screenshots appear to be running a Mac of some sort) so I decided to use JME3 in my favorite IDE, IntelliJ Idea in combination with Blender to create terrain and other 3d models. The terrain is a very large .obj (I can’t convert to .j3o since I am not using the SDK) that is loaded, among other things, with the following code:

Spatial terrain = assetManager.loadModel("/assets/models/terrain.obj");
Material boxMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
boxMaterial.setBoolean("UseMaterialColors", true);
boxMaterial.setColor("Ambient", ColorRGBA.Brown);
boxMaterial.setColor("Diffuse", ColorRGBA.Brown);
getPhysicsManager().initInPhysicsSpace(terrain, 0f);

AmbientLight ambientLight = new AmbientLight();

DirectionalLight sun = new DirectionalLight();

FilterPostProcessor filterPostProcessor = new FilterPostProcessor(assetManager);
SSAOFilter ssaoFilter = new SSAOFilter(/*12.94f, 43.924f, 0.44f, 0.61f*/);

rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/", false));

When the user clicks their mouse, a separate class creates a projectile (a node with a box and a particle emitter as children) and adds it to both the physics space and the rootNode then sets the correct position and velocity. This is done in the following code:

public void launch(){
    Node rocket = new Node("rocket");

    Geometry rocketGeometry = new Geometry("rocket-geom", new Box(0.25f, 0.25f, 0.25f));
    Material geometryMaterial = new Material(fps.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
    geometryMaterial.setColor("Diffuse", ColorRGBA.LightGray);
    geometryMaterial.setColor("Ambient", ColorRGBA.LightGray);

    ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
    Material matRed = new Material(fps.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
    matRed.setTexture("Texture", fps.getAssetManager().loadTexture("Effects/Explosion/flame.png"));
    fire.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));
    fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f));
    fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 2, 0));
    fire.setGravity(0, 0, 0);

    RigidBodyControl rigidBodyControl = fps.getPhysicsManager().initInPhysicsSpace(rocket, 0.5f);
    rigidBodyControl.setGravity(new Vector3f(0, -0.5f, 0));

Here’s an image of the issue with some overlays to further elaborate on it (apparently new users can’t embed images, so I had to shorten the link so that it was not automatically treated as an embedded image).

Thanks for reading! I hope you can and will help! BTW, this is my first post on this forum (and with this unique forum software) so please forgive me if I did something wrong :stuck_out_tongue:.

Most likely cause is that your terrain is in the transparent bucket.

1 Like

Thanks! I changed the terrain code to include terrain.setQueueBucket(RenderQueue.Bucket.Opaque); and the particles overlay correctly now. However, whenever any particles are on-screen, the terrain appears significantly darker.

EDIT: Here are some examples of the issue,aQq9KCY#0

Non proper normals and tangets?
those are the usual causes for strange lighting effects.

I am not using HDRFilter and I’m not sure what you mean by “normals” and "tangents

These are normals, does the obj include them?

I assume you are referring to the data in the model to allow for a texture to correctly map? If that is what you are asking, then no, it doesn’t have them but I wouldn’t think they are necessary because the entire model is just one color (set in Diffuse and Ambient in the material).

Well, if you are using a lit material then you must have normals. Logically, lighting requires knowing “how much does this face the light” and the only way to know that is with normals.

So either you must have normals or you must use an unshaded material.