Prism - A New Particle Effects System

  I’m the creator of CBE, a popular particle effects engine that’s been around for quite a while. Recently, though, I got an urge for some good ol’ particle coding. Good ol’ new particle coding, that is. CBE is pretty much complete, so there’s not much to do in the new stuff section of it: just bug fixes and upkeep. Thus, depressingly, I just had to do some random coding on swarm behaviors instead of real particles. Then it hit me: Who says I can’t make a new particle effects library? Then the answer hit me: Nobody. Then it hit me again: I could make a new particle effects library based on my experience with CBE. Then it hit me: That would be pretty awesome.

  After I had recovered from my dizziness due to so many things hitting me, I started coding on a new particle effects engine. The end result is that, after a long time of coding the frame, followed by hundreds of tweaks and modifications, I came up with Prism. Prism is CBE’s alternate-universe cousin. It’s based on my experience with CBE - there are some things I’d change if I had to rewrite CBE, and some things I’d like to try in a different way. Prism is based on the fundamentals of CBE - parameter lists and an OOP approach - but is a completely separate entity with its own unique features. Give it a whirl and see what you think.

TL;DR: Hurrah, a new particle effects engine!

https://www.github.com/GymbylCoding/Prism

Some videos of Prism at work:

https://www.dropbox.com/s/mql98p4e0rfpw1p/particle1.mov?dl=0

https://www.dropbox.com/s/uca5md2fxcb09ly/particle2.mov?dl=0

https://www.dropbox.com/s/iry4c1r4e66exu7/particle3.mov?dl=0

  • Caleb

P.S. Prism is mostly a side project, so I won’t be able to give a lot of tech support for it. Most things should be self-explanatory, though.

Thanks! Any chance of a video? No time to install and test code today :slight_smile:

Congrats Caleb.  I like the idea of a single file.  Very cool.  I’ll be giving this a test drive soon.

-Ed

@thomas6: Yep. Just updated with a few videos.

@roaminggamer: I’m getting a strange case of déjà vu here… :smiley:

  • Caleb

Looks really good and the code is clean and well readable.  However my only question is how does this relate to the native emitter stuff that is already built in to Corona.  As a dev looking to get into creating some simple games, what advantages does this library offer over the built in library given that the built in system is probably more efficient.

Note - this is NOT attempting to start a flame war, I think there is a lot of benefit from learning to create these things for yourself (or reading other peoples code), I was just wondering where the library fit’s in from an external developers perspective.

@techdojo:

Good question. Corona’s particles are great, and they’re probably faster, as you say, but here are some reasons to use Prism or CBE instead.

  • Particle Designer

Particle Designer is Mac-only, $80, and it seems that the only alternative is this. Using the “official” one is fairly expensive, and using the free clone makes for a bad workflow (what with having to re-export each time). If that works for you, great. However, the bottom line is that Corona’s chosen editor is fairly exclusive.

  • More power

Prism (and definitely CBE) is more powerful and more flexible than Corona’s particle systems. You get better custom effects with a specially made particle engine. This should be multiple bullet points - making particles interact with objects 'cause they’re display objects, adding tweakable Box2D physics, having multiple textures (or simple vector particles), adjusting different settings for each different particle, better color options, etc. This is probably the biggest reason to use Prism over Particle Designer - you trade off speed for power.

  • Workflow

With Corona’s particle systems, you get a GUI and you tweak it until it looks good. Then you export a JSON file with options in it, and load it up by reading the file into your program and using JSON to decode it. Every time you want to edit an effect, you have to have your editor open. There’s something in being able just to open your text editor and your simulator and edit right from there. You use Prism or CBE by creating an emitter with a property table. That’s all.

Compare:

local path = system.pathForFile("emitterData.json") local f = io.open(path, "r") local jsonContents = f:read("\*a") f:close() local data = json.decode(jsonContents) local emitter = display.newEmitter(data)

Versus:

local emitter = prism.newEmitter({...})
  • Code

This is probably just me being a nerd, but I like to fine-tune my particle effects with code rather than drag sliders until the effect looks good. I’ve never cared for GUIs of any sort (I like code editing - even if it’s more verbose - rather than a drag-and-drop IDE, for example), and I know I’m not alone.

Finally, if you like Corona’s particle support, you have Particle Designer, the things I outlined don’t bother you, and everything’s tickety-boo, that’s great. Stay with that. For people who aren’t so happy with that, Prism is perfect :).

  • Caleb

Hi Caleb,

Thanks for the quick response, as far as editing particle effects goes - I’m actually using the Roaming Gamer template (https://sellfy.com/p/bWcY/) which works a treat both on the simulator and my iPad.

To be honest I prefer to use sliders etc to tweak the emitter settings as there are just too many settings and it can be difficult to know (especially in the early stages) which field to change.

I agree with you about customisation, I’m sure there’s lot’s of ways that a custom engine can be tweaked to - especially for things like having objects you can collide / interact with (eg. bullets etc) and in this case your solution could probably end up being more efficient (especially if you limit the number of particles)

Anyway - thanks again for answering my question and for sharing your code, it’s a real benefit to the community. :slight_smile:

On a side note, with respect to the “Tiled” importer that forms part of the Dusk engine - have you thought about creating a tile-map shader so that you can just draw a single rect and have the graphics 2.0 shader actually render the tilemap.  I’ve done a bit of research and I understand it should be possible - although my experience with creating shaders is still very limited.

Cool! I wasn’t aware of Ed’s editor. In that case, editing looks like it should be a lot easier. Does it export to the terminal or a file or something?

Also, I haven’t looked into Corona’s shaders! I’ve done some graphics coding, but the idea of using shaders to make a tilemap never occurred to me… Sometime soon, you might see ultra-fast tile layers of some sort (maybe a “trigger property”) in Dusk!

  • Caleb

An interesting suggestion from TechDojo. I used to do my tile based game programming in Adobe Director and made the switch from separate tile sprites to copying textures into one single sprite just like he suggests. The speed gains were huge!

Here are the links I was reading up on when first researching the idea.

http://blog.tojicode.com/2012/07/sprite-tile-maps-on-gpu.html

http://connorhollis.com/fast-tilemap-shader/

And I think Ed’s editor actually send’s the settings via email

I opened a new topic for the tilemap shader here, if anyone here wants to give some input.

  • Caleb

Thanks Caleb, that’s an excellent start - hopefully the shader will be a benefit for the community :slight_smile:

Great news ! Keep going Caleb

Thanks! Any chance of a video? No time to install and test code today :slight_smile:

Congrats Caleb.  I like the idea of a single file.  Very cool.  I’ll be giving this a test drive soon.

-Ed

@thomas6: Yep. Just updated with a few videos.

@roaminggamer: I’m getting a strange case of déjà vu here… :smiley:

  • Caleb

Looks really good and the code is clean and well readable.  However my only question is how does this relate to the native emitter stuff that is already built in to Corona.  As a dev looking to get into creating some simple games, what advantages does this library offer over the built in library given that the built in system is probably more efficient.

Note - this is NOT attempting to start a flame war, I think there is a lot of benefit from learning to create these things for yourself (or reading other peoples code), I was just wondering where the library fit’s in from an external developers perspective.

@techdojo:

Good question. Corona’s particles are great, and they’re probably faster, as you say, but here are some reasons to use Prism or CBE instead.

  • Particle Designer

Particle Designer is Mac-only, $80, and it seems that the only alternative is this. Using the “official” one is fairly expensive, and using the free clone makes for a bad workflow (what with having to re-export each time). If that works for you, great. However, the bottom line is that Corona’s chosen editor is fairly exclusive.

  • More power

Prism (and definitely CBE) is more powerful and more flexible than Corona’s particle systems. You get better custom effects with a specially made particle engine. This should be multiple bullet points - making particles interact with objects 'cause they’re display objects, adding tweakable Box2D physics, having multiple textures (or simple vector particles), adjusting different settings for each different particle, better color options, etc. This is probably the biggest reason to use Prism over Particle Designer - you trade off speed for power.

  • Workflow

With Corona’s particle systems, you get a GUI and you tweak it until it looks good. Then you export a JSON file with options in it, and load it up by reading the file into your program and using JSON to decode it. Every time you want to edit an effect, you have to have your editor open. There’s something in being able just to open your text editor and your simulator and edit right from there. You use Prism or CBE by creating an emitter with a property table. That’s all.

Compare:

local path = system.pathForFile("emitterData.json") local f = io.open(path, "r") local jsonContents = f:read("\*a") f:close() local data = json.decode(jsonContents) local emitter = display.newEmitter(data)

Versus:

local emitter = prism.newEmitter({...})
  • Code

This is probably just me being a nerd, but I like to fine-tune my particle effects with code rather than drag sliders until the effect looks good. I’ve never cared for GUIs of any sort (I like code editing - even if it’s more verbose - rather than a drag-and-drop IDE, for example), and I know I’m not alone.

Finally, if you like Corona’s particle support, you have Particle Designer, the things I outlined don’t bother you, and everything’s tickety-boo, that’s great. Stay with that. For people who aren’t so happy with that, Prism is perfect :).

  • Caleb

Hi Caleb,

Thanks for the quick response, as far as editing particle effects goes - I’m actually using the Roaming Gamer template (https://sellfy.com/p/bWcY/) which works a treat both on the simulator and my iPad.

To be honest I prefer to use sliders etc to tweak the emitter settings as there are just too many settings and it can be difficult to know (especially in the early stages) which field to change.

I agree with you about customisation, I’m sure there’s lot’s of ways that a custom engine can be tweaked to - especially for things like having objects you can collide / interact with (eg. bullets etc) and in this case your solution could probably end up being more efficient (especially if you limit the number of particles)

Anyway - thanks again for answering my question and for sharing your code, it’s a real benefit to the community. :slight_smile:

On a side note, with respect to the “Tiled” importer that forms part of the Dusk engine - have you thought about creating a tile-map shader so that you can just draw a single rect and have the graphics 2.0 shader actually render the tilemap.  I’ve done a bit of research and I understand it should be possible - although my experience with creating shaders is still very limited.

Cool! I wasn’t aware of Ed’s editor. In that case, editing looks like it should be a lot easier. Does it export to the terminal or a file or something?

Also, I haven’t looked into Corona’s shaders! I’ve done some graphics coding, but the idea of using shaders to make a tilemap never occurred to me… Sometime soon, you might see ultra-fast tile layers of some sort (maybe a “trigger property”) in Dusk!

  • Caleb