jPCT-AE - a 3d engine for Android > Support

Particle system problem

(1/2) > >>

Zyphuris55:
I've been working on making a 3D particle system for a class project. It's been going well so far....except for the speed.

At first, I was trying to do 3D objects (cubes), but half of the sides wouldn't be visible (plus, the particles would be small majority of the time unless they were near the camera). So I decided on doing them all in 2D with billboarding, and each object has only 2 triangles to worry about.
With this current setup, I'm getting around 30 fps with 100 objects and 5 fps with 400 objects. Which isn't the most appealing thing, since the game is supposed to have more particles (about 2k).

After checking out the Rajawali's implementation (http://www.rozengain.com/blog/2012/05/03/rajawali-tutorial-22-more-optimisation/) of a large particle system, I tried to do the same with jPCT (see, I'm not abandoning this engine).

First I was having problems changing the vertices (using the vertexController, still haven't completely got it working :-/) Then I found out that the code to change each particle's transparency/ color would no longer work in this method (because of how vertices share color with each other)

So, what would be the best way to do this system?
Requirements:
- particles which move in 3D space
- each particle has its own position/velocity/color/transparency/life
- many particles (around 2k) with a smooth frame rate
- dynamic creation of particles

Note: The particles don't need any high-quality stuff or collision. Although eventual gravity would be nice, it's on the far back burner.

EgonOlsen:
Using a single object for each particle isn't particularly fast but it's actually not that slow either. For example, An3DBenchXL's particle test uses the same approach and renders 500 particles @30fps on a Galaxy Nexus and @45fps on a Samsung S3. If you are interested, you can get the sources from this thread: http://www.jpct.net/forum2/index.php?topic=2784.0

If you really need something more sophisticated, using the IVertexController approach might work somehow, but it won't be a fast as it gets either because it requires to upload the updated geometry to gpu, which takes its time.

If you really need performance, you can do what the rajawali example does: Write your own shaders to do it, i.e. create a single object with all the particles in it and do the animation in your shader's code. You have to enable OpenGL ES 2.0 for that and you have to come up with some clever idea to suppress the rendering of unused particles...or if you have everything up and running apart from that, we could try to add some hook into the engine's render pipeline to limit the number of drawn vertices.

Zyphuris55:
After being hung up with other projects, I'm finally able get back to this project.
In what you said about writing up my own shader and vertex arrays...is there a way I can piggyback the stuff on a Object3D? Or would it be easier to just skip the Object3D and do the whole thing from scratch?

I ask that because I like the features of camera/world classes and I'm not sure how to begin with writing up new classes to replicate those which are already made.

EgonOlsen:

--- Quote from: Zyphuris55 on February 16, 2013, 12:48:31 pm ---In what you said about writing up my own shader and vertex arrays...is there a way I can piggyback the stuff on a Object3D?

--- End quote ---
Sure. You can create an Object3D that contains the data and assign your shader to it. There's a constructor for Object3D that takes raw data as input.

Zyphuris55:
Would this be as fast as the rajawali method?

If it is, can you provide some example code? I tried doing something with the mesh and polygon manager....and I ended up having no clue what I was doing.  :P

Additionally, how can I change the color of each triangle in this array? I'm looking at the included document of the engine under the shader stuff, and I don't see anything about loading in an array of vertex colors...or an array of alpha values for the vertex points.

Navigation

[0] Message Index

[#] Next page

Go to full version