Tiny Space Debris


I am playing around with the jMonkeyEngine a little bit and wanted to try simulating starship movement.

Besides having a sky map to see where I am facing, I would love to have these tiny Space Debris dots you know from all these games, showing you how fast and in which direction you are moving.

My first thought was using something like a “local” particle emitter through which you are moving, but that would mean you need to set a new one once you leave the area of the first.

Has someone done something like this in the past, and if so, how did you achieve the effect?

Thanks in advance,

Could you find any gifs/vids as examples?

If you take for example this video of the old X-Wing from 1993 (around 15:00), there are these tiny pieces flying towards the cockpit:

Tagging @MoffKalast since he wrote this effect for Lightspeed Frontier

in this case it would need know the speed factor and depend on it too.

local particle emitter sounds almost fine(if particles would appear in random places arround x-wing), but i see one issue with it.

lets say x-wing would be able to stay in one place, then debris would have lifetime and suddenly disappear after time. i think it require this particle emitter to be user distance depend, rather than lifetime.

You could also have a point cloud with a custom vert shader that just wraps their position relative to the camera or something.

@oxplay2: If I understand correctly, some sphere particle emitter would move with the player camera, whilst the particles “stay behind” in the world coordinates. That doesn’ sound so bad. For the problem of a stationary ship: I will try out how bad this looks or if I can live with it.

@pspeed: I honestly did not understand anything, could you give me more insight?

Yeah in LSF there is basically just a particle emitter in the scene origin to handle this, but you could also just attach it to the ship and keep updating it with an inverse rotation to the ship’s so it stays rotated correctly.

Then just check for ship velocity and scale the particle amounts/velocity with the ship’s, just inverted since they need to be moving in the opposite direction. I think we also move the emitter itself a bit into the direction of velocity so the particles don’t fly away too rapidly (since they spawn uniformly in a large space around the ship).

I found that it looks best if you don’t have any particles around when the ship is at a dead stop since you may notice the particles fading in and out in that case.

Probably best to use tiny opaque quads for performance.

could a post-process filter be used for an effect like this?
if the view never leaves the cockpit, maybe a modified sparse dot noise filter could be used.

This is how it looks like (with the test debris from jme), you can use the mouse to turn around. The trick seems to be to move the particle generator in front of the moving camera, not around it.

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.effect.shapes.EmitterSphereShape;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;

 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
public class Main extends SimpleApplication {
    private Node camNode;

    public static void main(String[] args) {
        Main app = new Main();

    public void simpleInitApp() {
        camNode=new Node("CameraNode");
        ParticleEmitter debris = new ParticleEmitter("Debris", ParticleMesh.Type.Triangle, 10);
        Material debris_mat = new Material(assetManager,"Common/MatDefs/Misc/Particle.j3md");
        debris_mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/Debris.png"));
        debris.setShape(new EmitterSphereShape(Vector3f.ZERO,30f) );
        debris.setImagesY(3); // 3x3 texture animation
        debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
        debris.setGravity(0, 0, 0);
        cam.setLocation(new Vector3f(0,0,0));

    public void simpleUpdate(float tpf) {
        Vector3f move=new Vector3f(0,0,-tpf*5f);
        Vector3f location=cam.getLocation().add(move);

    public void simpleRender(RenderManager rm) {
        //TODO: add render code

This looks OK without anything in the scene, but as soon as I add some mesh, the translucent particles seem to ignore the zbuffer. Can I do somethign about both (translucency and zbuffer)?


why using translucent? you should use transparent.

material.getAdditionalRenderState().setDepthWrite(false) material.getAdditionalRenderState().setDepthTest(true)

I think.

…and as oxplay2 says, don’t put it in the translucent buffer. The translucent buffer says “draw this after everything else and totally ignore the z-buffer.”

1 Like