Search Unity

Particle Playground (Framework for controlling particles)

Discussion in 'Works In Progress - Archive' started by save, Oct 2, 2013.

  1. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    I changed the technique for collision detection, moving away from OverlapSphere which gives an unnecessary array of colliders and instead using SphereCasting. It currently gives a much better result but I'm struggling with some leakage (shown in picture). Added a collision sleep velocity as well which will set a particle at rest below velocity magnitude.
    I'll be looking into the leaking and hopefully be able to eliminate before release.

     
  2. will_jones

    will_jones

    Joined:
    Dec 20, 2011
    Posts:
    80
    When is a release date? We can use this for interactive installations as soon as possible.
     
  3. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hi Will! I'm happy to hear that. I'm aiming to upload to the Asset Store in late November (less than a month from now).
    I'll also be looking for continuative feedback right after release from users where I'm hoping to improve the framework on demand - would be perfect to have industry experience to talk to at that point.
     
  4. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Here's the collision abilities the first version will ship with!


    Affect Rigidbodies will initiate an AddForceAtPosition, if the RaycastHit contains a rigidbody, with the current velocity and mass from the particle before it reflects its direction.
    Next up is some bug fixing and tweaking.
     
    Last edited: Oct 31, 2013
  5. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    The framework is now running in editor mode (previously only in play mode). I had a lot of issues to resolve regarding updating the scene without having to select the component and optimizations during editing. The custom inspector also comes with a separate editor window (shown in image below), this is due to performance where a heavy object in Inspector can cause lag.

    I'm also working on emitting from transforms and making the custom inspector / editor window intuitive regarding selected values. I can honestly say now that this is becoming a strong visual tool now where you don't have to know scripting - which was one of my more important milestones in the project.

    Next update I'm hoping to show a more intuitive way to work with manipulators as well.

     
    Last edited: Nov 2, 2013
  6. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Any news? Still in anticipation of this.
     
  7. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thanks for asking Nixter, I appreciate that! And I'm sorry for the somewhat late answer, I've been slammed with preparing for a couple of Unity workshops I'll have at a school. No news lately I'm sorry, I'm hoping to show some new features in the beginning of next week - it depends how well things work out. Creating a visual tool out of this was really time-consuming.

    I would want to have a couple of "easy to use" transitions between states at first release, where you can choose what type of transition you want when changing state. However I have some more tweaking and bug fixing to do before I start up another module to the project! I really want to be able to release this as soon as possible as well. :)
     
  8. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    As promised here's an update. This weekend has been all about getting the Inspector tools to cooperate with the user. A lot of bug fixing and some restructuring has been on the agenda. Had some issues to resolve regarding whether the user was in Play Mode or not and how the particle system was updating which was more of an architectural problem.

    The good news I'm able to bring today,
    • Creating and editing states are now implemented visually, along with depth map settings, scaling and offset.
    • Manipulators can now be added and edited visually.
    • Transitions are added now when switching between states, currently available is None, Lerp and Fade.
    • Made the whole creation of the Playground Manager and Playground Particle System available from a single button click in an EditorWindow, making it easy to get the user started immediately.

    Lately I've been thinking a lot of the future updates and features. One thing I'd really want to do is to add a sprite system to let the particles be able to stench on collision (stick a texture onto the collided surface), preferably with a projection on the actual surface (to bend around corners). I'll probably extend the framework with certain events it can throw on some typical conditions (such as OnCollision, OnRebirth, OnDeath).
    My goal is to make this into an actual playground which is open to do some insane particle action. But that's a future update, I have to make sure that this is released really soon. Still looking good for the deadline with this uploading in late November (couple of days). :)

     
  9. gshape

    gshape

    Joined:
    Aug 8, 2012
    Posts:
    104
    Looks great! I hope to use skinned mesh emitter of your assert in my mobile project later. How's the performance like running on iPhone 4S+?
    I would like to simulate the motion blur(?) effect while the ninja jumping in this video with particles. Not sure if your assert helps?

    http://www.youtube.com/watch?v=_Vmfd2Ku3r8&app=desktop

    Thanks.
     
  10. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    I'm so excited about this! Can't wait to get my hands on it.
     
  11. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Nice! I understand what you aim for. I'm afraid the operation for that particular feature is a bit heavy for a 4S at the moment. I'm in luck as I'm sitting on a 4S and a dev license so I've been able to test a bit tonight.
    I've added an update rate for iterating through the matrix of skinned meshes as well as a the previous update rate for the particle system as a first optimization which do make a great difference for the fps on a 4S. There are a couple of key components to optimizations for mobile devices but the main thing is your mesh and how many vertices it has in this case.



    I'm thinking about alternative routes for mobiles, perhaps being able to paint several emitter positions which gets childed to the mesh instead of accessing the actual skinned mesh vertices - would make a huge difference for performance. I'll look into the possibilities for next update after release.

    Thanks man! Not far away now! :)
     
  12. gshape

    gshape

    Joined:
    Aug 8, 2012
    Posts:
    104
    Looking forward to the release date! :D
     
  13. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thanks man! Hopefully you'll find use for it regardless current skinned mesh solution. I've started planning for the updated version where source painting can solve this issue. More about that later! :)

    Update

    Meshes
    Meshes are now able to be added visually into a state. One of the great advantages is that you can now lerp between an image and mesh, and let a mesh be the source for emission inside a state (not to be confused with a mesh world object - a state is static positions calculated with scale and offset).
    If a texture is used the particles will be colored along with the uv-mapping for the mesh, if no texture is used the lifetime color will kick in instead.
    I've been able to get some amazing results lately, where moving through states can be used for countless effects. I'm really happy this worked out... :)

    Intuitive Material switching
    I've also added (kinda late in production you might think) the possibility to switch material directly in Inspector inside the Playground Particles object. Previously this was switched in script or on the Shuriken object.

    Clean and Rebuild
    Previously lack of controls in Editor to wipe out and rebuild the particles, buttons added!

    GUI structure
    Just a matter of moving around things a bit to make the tool structure more semantical. Moved Update Rate to Advanced. Moved out Minimum- and Maximum Size outside of Calculate Particles as this will also be calculated at particle birth.



    Next up is some fine-tuning and profiling. This weekend will be all about writing documentation!
     
  14. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Took some time to write a couple of helper functions. One particular for setting lifetime color from the sorting of particles which was handy at first initiation when the particles isn't calculated over time. Also added a sorting type by name Scrambled Linear which creates a linear list from particle birth to particle death and then scrambles it. This ensures that no particle will spawn at the same time even though the spawn appears to be randomly distributed.

    Not only did it solve an annoying bug when building up the particles without calculating them but turned out it could be used to get some interestingly weird results. :p



    The colors in the image is created from the lifetime color gradient then determined by the sorting how to distribute over the vertices on the world object.
    I'm quite sure now that this will be a handy tool for creating some really unusual content. I'm planing on evolving it greatly during 2014, so make sure you come with requests as well if you have ideas on features!
     
    Last edited: Nov 20, 2013
  15. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Along with some bug fixing today I've added support for offsetting the overflow remainder from a source point count towards the particle count, calling it Overcount Offset. Depending on the lifetime sorting you'll get different results, but what it basically does is to repeat the source with an offset. All sources and transitions are supported by this feature. For instance when using a single point (such as Transform) and having 100 particles with an overcount offset of Vector3(0,0,1) a line will be drawn over lifetime in Z-axis 100 units.

    This can be used for a lot of things, blinking lights along a runway for instance at a fair price on the CPU.



    Other than that I'm finishing up the code today to begin the documentation and create some examples that'll tag along the unitypackage. Fun stuff! :)
     
  16. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Great! I'm sure we'll have lots of feedback when it's released.
     
  17. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    A website with a demo is up describing and showing most of the features. You can try it out here www.polyfied.com/products/playground.php
    That's the demo the package will ship with showing how you can script towards the framework as well. I've tried to keep the left panel as close to the Inspector layout as possible. Feedback is greatly appreciated and please let me know if you find any anomalies.

    Release is closing in! :)
     
    Last edited: Nov 26, 2013
  18. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Yeah!!. December (and winter) is coming. :D
     
  19. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Indeed! This winter will be all about particles instead of snow. :D
     
  20. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Awesome work
     
  21. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thank you Play_Edu, I really like how your avatar empowers the message haha. :)
     
  22. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Save,

    Looking good! But I'm having trouble finding the right settings to recreate the original examples where the particles form an image.

    What settings would you suggest for a State source to view as an image?
     
  23. Gorlog

    Gorlog

    Joined:
    Jan 20, 2011
    Posts:
    201
    wow awsome work!
     
  24. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Thanks! First set state (image) as your source at the top. You can either untick Calculate and select an image or remove all forces. Use Vertex as material, which will be a square non-blended color from the image's pixels. Don't use a manipulator as this will alter the position over time. Is it working like you excpected when doing so? What happens is that all particles have their original position from the image's pixels but are calculated over time and is only in its original position for a fragment of time. Using an image with a depthmap (later two images) will give you a slider of z-depth as well. Hope it works out otherwise let me know! :)
     
  25. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    I can get the image to halt by removing the Calculate and switching the state. The Vertex setting gives me square pixels, but they are not lined up in an orderly fashion. This is what I see:

    $ParticlePlayground.jpg
     
  26. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Ah I see! That is because of the size, I built the positions with a unit scale of .1 from the images, so the exact pixel ratio would be minimum- and maximum size of 0.10. The sliders however can be a bit tricky to get into position. I've also noticed that a small amount of oversizing will make a better result, not leaving any borders around pixels when viewing the particles from an angle. Does that solve the issue? Editing this in the tool is of course a bit easier where you see the scale from the state and can enter exact float values into the sliders. :)

    Edit: You just gave me an idea for the source painting tool, where you would be able to paint the source scale as well... thanks man. :) Much to be done for updates to this tool hehe, I think my working project for entire 2014 is set.

    Edit2: I should also mention that I've updated the state construction leaving zero alpha pixels behind, I don't know how I missed that optimization from the beginning but that'll be in first version.
     
    Last edited: Nov 28, 2013
  27. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    OK, that is working better. I set Min to 0.11 and Max to 0.13. They look pixilated, but solid.

    Glad that got your creative drive in gear. I always look forward to what you work on.
     
  28. Adrianis

    Adrianis

    Joined:
    Apr 20, 2013
    Posts:
    109
    Those effects are stunning, nice work save!
     
  29. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Ok great! They appear pixelated because of the resolution, they're only 32x32 so the pixels are quite blown up. Thanks inspiring words!


    Thanks man! Let's see how far we can evolve this. :)
     
  30. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    +1 for the GPU particles idea.
    The bottle neck of the particles systems is its heavy performance consumption on CPU if there are a lot. If it could be moved to GPU side, then it feels more reasonable. Given that Mac OS now supports Open GL 4 if unity could get improved on their side, it'll open up some new opportunities for GPU staff.
     
  31. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Totally agree! I'll also have a look into threading this for the non Dx11 (and future OpenGL4). Much to be done, good stuff! :)
     
  32. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    This last week was insane, day and night in the Editor and I'm so insanely tired, but now the package has been submitted to the Asset Store for review! :)
    I've updated the demo a bit as well (nothing super new except the choice to emit or not). Also made a first draft of the manual, something to be improved as well.
    Thanks so far for all support, inspiring words and requests!

    This is how you hopefully will recognize the playground,
    $Skärmavbild 2013-11-29 kl. 23.58.52.png

    And some first product screens!

    $screen01.jpg
    $screen02.jpg
    $screen03.jpg
    $screen04.jpg
     
  33. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Re-yeah !!!!. You did it, and before december as promised. Good job. :cool:
     
  34. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Haha thank you! :) Hopefully it'll get approved and go public next week. I'll start exploring new features during next week as well but prioritize some "how to" videos in the nearest. I've gotten some questions already how certain things work and I would want newcomers to be able to just jump right in and get started by watching some short tutorials.
     
  35. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Just checked the Asset Store. No news.
     
  36. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Nothing yet, sorry. I'll let you know! :)
    I've added some more information about how to get started and a Reference Manual here if you want to start by reading about the different possibilities.
     
  37. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Five minutes after replying I got an e-mail about that it has been accepted. :)

    Particle Playground on the Asset Store: http://u3d.as/5ZJ
     
  38. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  39. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Last edited: Dec 4, 2013
  40. detomato

    detomato

    Joined:
    Aug 16, 2013
    Posts:
    54
    Hi save,
    I wonder if theres a feature to change the colors of the particle base on the scale of the object. What I'm trying to achieve is something like audio/music visualizer. An object which emit particle, and the scale of the object is base on the audio/music. Is it possible?

    Thanks in advance.
     
  41. save

    save

    Joined:
    Nov 21, 2008
    Posts:
    744
    Hi detomato!
    I'm really sorry for the late answer, this is a thread I'm not following too closely - here's a better place for quicker answers: http://forum.unity3d.com/threads/215154-Particle-Playground

    It's a really good question. You could connect the scale of your object to the evaluation of a gradient and apply into the particles color. Evaluation of colors is done by a normalized value (from .0 to 1.0). Currently you would need to loop through particles every frame, I'll have a look into being able to disconnect certain parts of what happens in the calculation loop so you can inject stuff more optimized in the future.

    Here's an example of how to control color by scale from selected axis:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. [ExecuteInEditMode()]
    6. public class EvaluateScaleColor : MonoBehaviour {
    7.  
    8.     public PlaygroundParticlesC particles;
    9.     public Transform scaleTransform;
    10.     public ScaleAxis axis;
    11.     public float maxScale = 1.0f;
    12.     public Gradient scaleGradient;
    13.     private Color32 evaluatedColor;
    14.     private float scale;
    15.     private float previousScale;
    16.  
    17.     void Update () {
    18.  
    19.         // Early out if you haven't assigned the objects
    20.         if (scaleTransform==null || particles==null) return;
    21.  
    22.         // Get color from axis
    23.         Evaluate ();
    24.  
    25.         // Set color for all particles
    26.         for (int i = 0; i<particles.particleCount; i++)
    27.             particles.particleCache.particles[i].color = evaluatedColor;
    28.     }
    29.  
    30.     void Evaluate () {
    31.         switch (axis) {
    32.             case ScaleAxis.x: scale = scaleTransform.localScale.x; break;
    33.             case ScaleAxis.y: scale = scaleTransform.localScale.y; break;
    34.             case ScaleAxis.z: scale = scaleTransform.localScale.z; break;
    35.         }
    36.  
    37.         if (previousScale!=scale) {
    38.             evaluatedColor = scaleGradient.Evaluate (Mathf.Clamp01(scale/maxScale));
    39.             previousScale = scale;
    40.         }
    41.     }
    42.  
    43.     public enum ScaleAxis {
    44.         x,y,z
    45.     }
    46. }
    47.  
    48.