Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Particle System Implementation  (Read 2683 times)
0 Members and 1 Guest are viewing this topic.
Offline Slyth2727
« Posted 2014-04-23 00:15:30 »

To start this out:
I know all the math and stuff needed to create a particle system. It isn't very complicated and it isn't part of the question, so I'm just verifying that.

I plan to add a simple particle system to my (3D) engine that supports texturing, transformation, and additive blending, however I am not quite sure on how exactly to implement it graphics wise.
I have a mesh class that simply holds a vbo and an ibo which get drawn to the screen. The mesh class also holds an array of Vertex (one of my classes. Contains the position, texCoord, normal, and tangent) and integers.

So should I use this class with a shader in order to draw everything somehow, or should I render them some other way, completely different from my mesh class?
Offline StrideColossus
« Reply #1 - Posted 2014-04-23 09:13:25 »

I think the question should be whether to use point sprites or not:

1. Bill-board approach:

Sort array of vertices by distance from the camera (for correct blending), generate bill-board quads from your array of vertices, buffer the data into a dynamic VBO, render each sprite as a quad or two triangles.  Your mesh would consist of VBOs for texture coordinates (and colours if required) as well as the quad vertices (or one inter-leaved VBO).

- re-uses your existing mesh code.

- over-head of having to orientate the quads to the camera.
- need to provide texture coordinates but these are usually the same for every sprite hence redundant data.

2. Point-sprites:

As #1 but use point sprites rather than billboard quads.

- re-uses your existing mesh code.
- no need to calculate billboard orientation or texture coordinates.
- usually faster rendering.
- supported by most (all) modern graphics cards (including OpenGL-ES).

- point sprites have some limitations (e.g. large sprites are culled if the centre point is outside the view frustum) but these are usually not relevant or can be worked around.

Either approach can be enhanced by using a vertex/fragment shader:
- more flexible rendering
- faster than fixed-function pipeline

Note sure why you would need an IBO for a particle system though, or is it just an optional part of your mesh class?

- stride
Offline Slyth2727
« Reply #2 - Posted 2014-04-24 01:05:51 »

The ibo is used so there aren't as many vertices needed overall but it would be trivial to make it optional.
Thanks for the reply, I'll do a bit more research on it now.
Also, when you say I can improve it using glsl you mean just rendering it with glsl correct? Because everything is rendered with shaders by default.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2014-04-24 02:23:08 »

If you're okay with delving a bit deeper into graphics, you could look into using geometry shaders. That way you can get the best of both worlds.

Offline Slyth2727
« Reply #4 - Posted 2014-04-24 02:32:51 »

I've researched them before and they seem intriguing. What I got from it was that they give the ability to change the primitive rendering type OpenGL uses as well as edit certain other attributes of.. and yeah that's where my knowledge ends.

Google, here I come. If you have any good resources feel free to post them here too.
Offline theagentd
« Reply #5 - Posted 2014-04-24 02:42:42 »

The information is out there, but what you can do with them is a bit harder to find. Basically you can draw your particles as "points" which have the attributes that you need: for example position, size, rotation and color. Then you can use a geometry shader to output 4 new vertices to form a quad, allowing you to do proper billboarding without transforming on the CPU (transform by view matrix first, expand to screen aligned quad, transform by projection matrix). You can also apply stuff like rotation and generate texture coordinates for each corner. Without geometry shaders you'd be forced to render the particles as quads with 4 vertices each, but a lot of this information is just data that's shared by all 4 vertices. For example there's no need to supply 4 positions when one position and a size is enough.

Offline Slyth2727
« Reply #6 - Posted 2014-04-24 02:51:53 »

That's mind blowing. Wow that really is cool, thanks for elaborating!
When you say transform by view matrix, then expand to screen aligned quad, the screen aligned part refers to bill boarding part right?
Pages: [1]
  ignore  |  Print  

EgonOlsen (1668 views)
2018-06-10 19:43:48

EgonOlsen (1705 views)
2018-06-10 19:43:44

EgonOlsen (1156 views)
2018-06-10 19:43:20

DesertCoockie (1584 views)
2018-05-13 18:23:11

nelsongames (1184 views)
2018-04-24 18:15:36

nelsongames (1708 views)
2018-04-24 18:14:32

ivj94 (2532 views)
2018-03-24 14:47:39

ivj94 (1757 views)
2018-03-24 14:46:31

ivj94 (2834 views)
2018-03-24 14:43:53

Solater (970 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!