How to create a custom dynamic Z-Buffer

Is there a limit for particles? It seems to draw only some of them… blue is the complete point cloud, green and yellow the quadratic particles

There shouldn’t be. But I don’t see how you setup your buffers so I can’t comment further. For example, if you are using the default particle shaders then if you don’t specify enough size elements then you might see this. (Size would probably be wasteful in your case and might be better to just fork the shaders and use a fixed size.)

Well, there might be something else wrong there. If I move the camera only a little bit, the particles disappear, moving back brings them back. But it’s not the frustum. The near clipping plane is at 0.1 and the particles should be at a distance of min. 0.5. And the blue dots stay. To your question of the setup for my buffers - both (blue dots and green particles) use the same buffer setup, the one shown in my code snippet a few posts earlier.

Cheers,
Gem

Then if you haven’t modified the shaders… you will need to set a size buffer or you just get random garbage for size I guess.

I’m just stabbing in the dark though. Particles have always worked fine for me.

looks like your testing on the android emulator, what results do get outside the emulator ?

@pspeed
Sorry, I guess my knowledge is just too limited. What do you mean with setting a size buffer?

@thetoucher
Not on the emulator - but on the Google Tango via ADB. Can’t really test outside the Tango, because I need the point clouds. But with a few example points on the PC I get exactly what I want.

With mat.getAdditionalRenderState().setColorWrite(true); :

and with mat.getAdditionalRenderState().setColorWrite(false); :

That looks pretty good.

Hi,
finally solved this problem by setting the size buffer as well:

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ OCCLUDING
        Mesh mesh2 = new Mesh();
        mesh2.setMode(Mesh.Mode.Points);
        // 3 Components: XYZ
        Vector3f[] vertices2 = new Vector3f[vertices.length];
        for(int i=0; i<vertices.length;i++) vertices2[i] = new Vector3f(
            vertices[i].x,
            vertices[i].y,
            vertices[i].z
        );
        mesh2.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices2));
        mesh2.updateBound();
        mesh2.updateCounts();
        
        float[] sizes = new float[vertices.length];
        for(int i=0;i<sizes.length;i++) {
            sizes[i]=5;
        }
        mesh2.setBuffer(Type.Size, 1, BufferUtils.createFloatBuffer(sizes));

        Material mat2 = new Material(assets, "Common/MatDefs/Misc/Particle.j3md");
        mat2.setBoolean("PointSprite", true);
        mat2.setFloat("Quadratic", 3f);
        mat.getAdditionalRenderState().setColorWrite(false);
        mat2.getAdditionalRenderState().setDepthWrite(true);

        Geometry meshGeo2 = new Geometry("PointCloud2", mesh2);
        meshGeo2.setMaterial(mat2);
        meshGeo2.updateModelBound();
        meshNode.attachChild(meshGeo2);

Last Post: here is what I did with it :slight_smile: Laggged a bit, thats why position is not a 100 percent correct

2 Likes