1
\$\begingroup\$

I am a bit confused about how to achieve this. What I want is to "draw with flames". I have achieved this with textures successfully, but now my concern is about doing this with particles to achieve the flaming effect. Am I supposed to create a path along which I should add many particle emitters that will be emitting flame particles? I understand the concept for 2D, but for 3D are the particles always supposed to be facing the user?

Something else I'm worried about is the performance hit that will occur by having that many particle emitters, because there can be many letters and drawings at the same time, and each of these elements will have many particle emitters.

Update 1:

A more detailed explanation:

I have a path of points, which is my model. Imagine a dotted letter "S" for example. I want make the "S" be on fire. The "S" is just an example it can be a circle, triangle, a line, pretty much any path described by my set of points.

For achieving this fire effect I thought about using particles. So I am using a program called "Particle Designer" to create a fire style particle emitter. This emitter looks perfect on 2D on the iphone screen dimensions. So then I thought that I could probably draw an S or any other figure if i place many particle emitters next to each other following the path described.

To move from the 2D version to the 3D version I thought about, scaling the emitter (with a scale matrix multiplication in its model matrix) and then moving it to a point in my 3D world. I did this and it works. So now I have 1 particle emitter in the 3D world.

My question is, is this how you would achieve a flaming letter? Is this too inefficient if i expect to have many flaming paths on my world? Am i supposed to rotate the particle's quad so that its always looking at the user? (the last one is because i noticed that if u look at it from the side the particles start to flatten out)

Update 2:

I tested this, by having multiple particle emitters and altho they look reasonably well the more particles i have the worst the FPS get. A common scenario will be having at lest around 50 different lines/letters at the same time.

Currently the particle emitter is on the cpu. It calculates the position of each of the particle's vertices and feeds the new vertices to the gpu. This works well for a few emitters, but not for enough to have "flaming" letters all around.

I was considering about moving the calculations performed by the particle emitter to the GPU in a shader but this seems a bit complicated since each particle has its own state and is modified with a time delta. In the CPU it is simply an object that changes its value with the previous value as reference, but the GPU shader is just run once per draw call isn't it?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's not very clear what you're asking for here. Are you looking for ways to read a font so that you may place particle emitters to draw letters? Or perhaps how to billboard the particles? Or maybe how to do what you want to do efficiently? Try adding more detail to your question to hone in exactly what problem you're having, and explain what you've tried to do to solve it. \$\endgroup\$ Jun 11, 2014 at 4:25
  • 1
    \$\begingroup\$ Everything here sounds totally reasonable. Have you tried it? \$\endgroup\$
    – Anko
    Jun 12, 2014 at 13:42

1 Answer 1

1
\$\begingroup\$

Yes, it is possible, and it has been done before many times.

What you want are called Billboards, they are simple planes that are transformed to always look at the camera. There is an implementation of it on GLSL Programming Wikibook.

You would want emitters which emits particles (which are billboards), there is no need for moving anything to the GPU, emitting particles is not that expensive, what is expensive is drawing hundreds or even thousands of particles on the screen, also, make sure to use a very light particle class and re-use old ones with the Object Pool design pattern, since garbage collection should hit you hard otherwise.

For your shaders, make the billboard calculation on the vertex shader, it should move some work to the GPU, make sure you only do not over-engineer the shaders, since they will be called to a lot of particles!

This should already leave you with performance to draw thousands of particles on the screen and still have performance for other game stuff. Even if it ends up eating all your mobile precious CPU, then make the emitters emit less particles. Most of the time you can still obtain a good effect with half the particles, be wise, spend performance only where it's necessary.

Your bigger problem will be arranging the emitters to make them feel like real text. Here are some options on the top of my head:

  • Get a bitmap texture of low resolution, like 10px tall characters, for every gliph, scan the pixels, for each pixel set, record it's coordinates. Save all the coordinates is saved for all the gliphs. Scale them up later, use them as offsets when placing emitters on the world later.
  • Get a vector font library, get the paths of each glyph, record even-spaced points for each path of the glyph. Use the points as offsets when placing emitters on the world later.
  • Design a set of emitters on some software, or even with pencil and paper, write their values on some file or even hard code on arrays, use the points as offsets...
  • Mix the last option with any of the two first. Generate then tweak it.

This should give you a very good start, good luck!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .