Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[Open Source] TC Particles: millions of GPU particles

Discussion in 'Assets and Asset Store' started by pvloon, Feb 28, 2013.

  1. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    any update on the patch? thanks
     
  2. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Sorry for the delay, ended up working through more feature requests and bug reports before submitting. Should be up on wednesday or thursday :) Full release notes now are:


    -A new sample scene demoing some awesome explosions.
    -A new offscreen render mode allowing you to do distortions with particles; Each particle is like a little bumpy surface distorting what's behind it. It can really add an extra dimension to a lot of particle effects.
    -Thanks to Lex-DRL: A new system that allows you to override specific parts of the TC Particles vertex shader. He has done some incredible effects with this system already, and it's simple to use. An example how to use it is included.
    -Emission no longer stutters and jitters - you can now emit smooth lines of particles.
    -Added new emission mode: PerUnit
    -Added new rendering mode Point
    -Added a new simulation space mode: true local. It's like the current local space, but also takes into account scale.
    -Reworked inspector a bit, better layout, better use of space, can scrub more values now, etc.
    -Removed a bunch of GC allocations - systems will now rarely allocate GC
    -Reworked parts of the code, so it's easier to understand and learn from
    -Emission now correctly respects scale for emission - allowing you to do 2D emission with a z scale of 0.
    -Fixed sprite sheet animations.
    -Fixed local space forces
    -Fixed local space rotations
    -Fixes when sharing materials between systems
    -Other bug fixes and optimization improvments.

    And I'll have some more exciting news to share... soon ;)
     
    Last edited: Jan 28, 2014
  3. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Patch 1.2 is online on the asset store now :)
     
  4. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Great, thanks! I updated and have been getting errors that I didnt have before...

    "Assets/Plugins/TCParticles/Samples/Standard Assets/Character Controllers/Sources/Scripts/PlatformInputController.js(5,21): BCE0018: The name 'CharacterMotor' does not denote a valid type ('not found'). Did you mean 'UnityEngine.CharacterJoint'?"

    "There are inconsistent line endings in the 'Assets/Plugins/TCParticles/Shaders/TCShaderAdditive.shader' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands."

    deleted the Character motor just to see what would happen...
    Assets/Plugins/Editor/TCParticles/TCOffscreenRendererEditor.cs(5,14): error CS0101: The namespace `global::' already contains a definition for `TCOffscreenRendererEditor'
     
    Last edited: Jan 30, 2014
  5. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    I'm playing with the new version and don't understand what the new emission mode: "PerUnit" means.

    @HeadTrip : did you deleted all TC related files before you updated? I realized that there are some changes in the folder structur (Plugins/Editor) . So I believe that there are floating two TCOffscreenRendererEditor.cs files in your project. The best is to delete the old TC stuff from Plugins/Editor and then import the latest TC patch.
     
  6. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Thanks sloopi :) That's indeed what you want to check @HeadTrip. Unity needs to update their update system!

    @sloopidoopi: Normally when you set the emission rate it means x particles per second. That is to say: emit x particles for every 1 second. Per unit changes this to: emit x particles, when the emitter has moved 1 unit.

    It's mostly useful to do smooth trail like effects.
     
  7. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Yeah, now I got it. But it only works when I change the simulation space to "World" or "Parent" .
     
  8. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    I deleted the TC folder , re-imported and still get this:

    Assets/Plugins/TCParticles/Samples/Standard Assets/Character Controllers/Sources/Scripts/PlatformInputController.js(5,21): BCE0018: The name 'CharacterMotor' does not denote a valid type ('not found'). Did you mean 'UnityEngine.CharacterJoint'?
     
  9. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Bump for help
     
  10. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Perhaps you imported the standard assets from unity in your project? TC comes with a couple of copies of the original unity assets. This is not optimal because a lot of projects use the standard assets already. So you could have some further duplicated stuff floating in your project and get the weired error messages.
     
  11. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Sorry to hear about your troubles HeadTrip :( Would indeed be good to check what sloopi doopi says. Additionally, that file isn't actually needed so you can try deleting just that file. If all of these don't work, you can delete the samples folder from TC Particles - might be good to try the samples in a clean project.
     
  12. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    Hmmm ... for some reason the TC Particle Emitter won't play in the editor - it works fine in play mode. Is there something I need to enable and I'm missing it ?
     
  13. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Good news! The Asset Store has gone mad again and so has TC Particles! If you were holding off on picking it up, now's the chance :) assetstore.unity3d.com/#/content/7326



    @klakwa: Unfortunately, TC Particles doesn't simulate in the editor as of now. I know it's unfortunate, as it's kinda nicer in Shuriken. It's quite some time investment to make that work though, so it wasn't high priority. However, if more people request this I'll be sure to take a look :)
     
  14. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    Wow. To be honest I don't know if I would buy it if I knew about it - I didn't pick that up from the video. For me this feature is a must for particle system :(

    Also I was playing with the attributes a bit, and I'm getting this error, while playing with forces.

    NullReferenceException: Object reference not set to an instance of an object
    TC.Internal.ParticleForceManager.Dispatch ()
    TC.Internal.ParticleManager.Dispatch (Boolean emit)
    TC.Internal.ParticleManager.UpdateParticles (Single deltTime)
    TC.Internal.ParticleManager.Update ()
    TCParticleSystem.Update ()
     
    Last edited: Feb 3, 2014
  15. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Thanks for the bug report, I will look into that ASAP. Do you know what actions you did specifically?

    Also, really sorry to hear about the miscommunication about the simulation in editor :( I will see if I can add it for the next update - I'm a little cramped on time but I will do my best.
     
  16. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    I was just playing around with the settings in inspector, but I think it was just after enabling boids in the simulation.

    I've been checking out the system today and I'm very happy about how it works. I managed to rewrite my particle scripts very quickly to handle the TCParticleSystem instead of Shuriken, and redid 50% of the effects that I would like to use with TCParticles. It performs and looks great! I really like how similiar the properties and methods in TCPS class are to Shuriken system, great work on that! Tho editor preview would make work much much faster.

    Also it would be great to know how this Offscreen renderer is supposed to work, because I couldn't figure that out.
     
  17. Tee_Pee

    Tee_Pee

    Joined:
    Aug 18, 2013
    Posts:
    54
    Heya,

    I just got a quick and simple question... I am trying to get glowing orbs flying in a direction in a spiral pattern. The way I have it set up is as follows:

    - Line emitter, shooting particles at a rate of 10 per second at a set speed and lifetime.
    - A parent object to the particle system, the local position of the particle system is 20,0,0.
    - The simulation space is set to parent.

    What happens is that the parent rotates (effectively rotating the particle system around it), but the particles are all emitted from the same initial point. If I set emission to world it works as intended, but I cannot do that as in the actual final version the effect will be hurtling through space at a non-trivial rate, distorting the effect.

    I hope I managed to be clear with that... thanks in advance.
     
  18. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I have no idea how but after I noticed this was half price I came to 5 mins later having bought it. No bad thing, this is useful stuff
     
  19. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    It would be nice to be able to control starting speed of the particles from code.
     
  20. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    @Klakwa: Glad to hear you're enjoying the system otherwise :) The API is indeed kept similair to be easily recognizable, and port over shuriken stuff. Also, when you're on a system with no DX11, the calls will automitically call the same calls on the shuriken fallback system.

    You should be able to access the starting speed as follows: GetComponent<TCParticleSystem>().Emitter.Speed.Value = 1.0f;

    Do note that since the starting speed is a MinMax type, you might need to set Min or Max instead of Value.


    @Tee_Pee: Hm, played around with it for a while, and it's indeed hard to do! I played around with it for a while, but it seems that even with some scripting, the parent mode is just not great at the moment to do this. Really sucks. I'll try some things, and send you the patch to test out as soon as I can.

    @Lazygunn: Excellent, welcome to the family :)
     
  21. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    117
    Hi this looks amazing, how accurate is it with collisions against a mesh?
     
  22. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    From my experience it's very accurate. I'm using it in a physics based game and it performs very well (but I'm using only one-two colliders at the time). It doesn't support the mesh collider which is a bit unfortunate, but it has few additional build in types you can use as a separate collider for particles only, and also it uses default Unity physix colliders such as box, sphere, capsule and so on.

    I would like to learn more about how offscreen renderer works tho, since there is nothing about it on the website.
     
  23. MSFX

    MSFX

    Joined:
    Sep 3, 2009
    Posts:
    117
    I have 4 letters that I want a particle system to surround, they're each a mesh so I guess this wouldn't work which is a shame :(
     
  24. Lex-DRL

    Lex-DRL

    Joined:
    Oct 10, 2011
    Posts:
    140
    You can approximate the mesh with built-in colliders. From my experience, box, sphere and capsule colliders are more then enough to define almost any shape. And usual setup made of them only is MUCH more performant and accurate than a single mesh collider with ~100-200 polygons... if we're talking about static objects, of course.
     
    Last edited: Feb 5, 2014
  25. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    For the upcoming tutorial videos we wanted to build some good content to go on, and while we're at it do some cross promotion. My good friend and collabrator Anton Hand made this elemental sword demo showcasing the Alloy shader set, Skyshop, amplify color and of course TC Particles!



    A tutorial about how this was set up and how to set up your own FX similair to this are in the makings :)
     
  26. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    @MSFX: No mesh colliders indeed :( Thanks for the helpful comments from Klakwa and Lex though! I think that in general compound (TC Particles has a lot of compound types) colliders are better for these types of FX. With normal physics it can be disturbing, but for FX it's barely noticable and indeed performs much better. Depends on what you're trying to accomplish though :)

    Also, performance would actually be the same if all those boxes were zipping around @Lex-DRL :)
     
  27. Klakwa

    Klakwa

    Joined:
    Dec 12, 2012
    Posts:
    8
    I've been playing around with the system and I see the TCParticleSystem.Stop() opposing to ParticleSystem.Stop() also clears out the living particles from the system. Is this what you wanted to achieve or is it a bug ?

    I know I can use TCParticleSystem.Emitter.DoEmit = false; to stop it and test for the emission instead, but I think this is a bit less intuitive.

    Also is there some info online about Offscreen emitter ? Since I've asked about it 2 times already and didn't get any answers about how it works ;p
     
    Last edited: Feb 6, 2014
  28. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    100
    What may be the cause of my display flickering and crashing unity when using TCParticles in either editor or build. To specify, using TCParticles on some gameobjects in a scene works just fine while testing and playing around with it, however when I instantiate them from a prefab things go awkward.
     
  29. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    @Klakwa: Hm, I see. Well, if Pause() freezes the particles, then to me it seems logical that Stop() clears them. But if it's not like that in Shuriken I might need to reconsider. In any case, if you're goal is just to stop emission, DoEmit is the cleanest I think :)

    About the offscreen emitter, follow these steps to get something basic running:

    -Create a TC Particle system, set the gameobject layer to something like "offscreenParticles"
    -Create a material, and use a TC Particles/Offset/... shader for it.
    -On your camera, add the TC Particle Offscreen Renderer to it. Set the layer to the one the system is on.
    -Set composite mode to gradient, make some nice gradient, set a gradient scale, just mess around with it until it looks good.

    The alpha blend mode will do something similair, but gradient is the most powerful option imo. Also, you can do distortion particles with the "Distort" composite mode. Hope that helps!


    @CaptainChristian: Display flickering and crashing? Well that doesn't sound like fun. I'm not entirely sure what you're trying to convey. This only happens when the system is in a prefab? Does this always happen, or only with some specific settings?
     
  30. Rico21745

    Rico21745

    Joined:
    Apr 25, 2012
    Posts:
    409
    This may be a dumb question on my end due to inexperience w Linux, but will this work on Mac/Linux? I'm looking to publish to these platforms and was wondering if TC particles was Windows only due to DX11 requirements.
     
  31. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Unfortunately, windows only yes :( I wish unity would have proper openCL integration for some cross platform GPU goodness
     
  32. LeoSalles

    LeoSalles

    Joined:
    Dec 22, 2012
    Posts:
    11
    I'm having a weird problem, just bought the asset and I was looking at the spooky scene. The particles movement doesn't seem anything like in the demo, don't know why, I haven't altered anything.

    $spookyscene.png

    I'm using unity indie, dx11 enabled, in a fresh new project.
     
  33. RayKatz

    RayKatz

    Joined:
    Oct 18, 2013
    Posts:
    13
    Have you activated DX11 in the unity properties? Otherwise it will try to use a normal shuriken particle system.
     
  34. LeoSalles

    LeoSalles

    Joined:
    Dec 22, 2012
    Posts:
    11
    Yes, yes I did. It is mainly on the demo scenes, if I create a scene of my own and new systems it works perfectly.
     
  35. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    THIS! along with no 64bit editor, my biggest bugbear. Havent got round to using this yet but without a doubt it's going into my 'show off all the pretty assets I have' showcase, where it will look terribly pretty
     
  36. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    100
    I just built and ran a clean project and it works fine, so I don't think it got anything to do with my computer. What could possibly interfere with TCParticles to create such bugs?
     
  37. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    @LeoSalles: It looks like the turbulence force isn't acting on the particle system. I think what might have happened is that I forgot that force when converting the demo scenes from pro->indie. The references get lost when changing from pro -> indie so I have to link them back up manually. Can you check if in that scene the world noise has a TC Force component?


    @lazygunn: If you'd be able to make a good openCL plugin fr unity, that'd be incredible. A 64 bit editor even more so, but well, dont expect a third plugin for that, haha.

    @CaptainChristian: You an try reimporting all the assets, though frankly I don't have huge hopes for that. I really don't know how this would happen, neither can I repro it. It sounds like something in your project is off from the default and messing with it.
     
  38. krautsourced

    krautsourced

    Joined:
    Dec 3, 2012
    Posts:
    4
    I'm trying to assign random, but then persistent and not animated, sprites from a sprite sheet to the particles. The way I see it, all I should need to modify is the int sprite = ... line in TCIncVert.cginc. Assigning a specific int does indeed work fine, however, the problem is that of course I want it to assign one randomly based on the particle Id. Is there any way to get the particles Id from within a shader? I can see position, rotation etc. are public, but I can't find an Id that I could then convert to an int. Or am I just overlooking something?
     
  39. krautsourced

    krautsourced

    Joined:
    Dec 3, 2012
    Posts:
    4
    Never mind, turns out I was overlooking the obvious ("inst").... it is actually rather straight forward (this is just looping through of course, without randomness)

    TCIncVert.cginc:
    Code (csharp):
    1.  
    2. #ifdef TC_UV_SPRITE_ANIM
    3.             half2 uv = bufPoints[id] + 0.5f;
    4.             int spriteMax = (int) (_SpriteAnimWidth * _SpriteAnimHeight);
    5.             int sprite = (int) (inst % spriteMax);
    6. ....
    7.  
     
  40. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Hi Krautsourced!

    Using inst is indeed the best solution. You do lose randomness, but what you could do is make a global int in your shader, and set that to some number in the startup of your system, and offset inst by that. That way it at least starts out differently each time. Also, you could hash that number to get "random" numbers, take a look at the random number generator in the massParticle.cginc, I also made some slides about how to generate random numbers on the GPU in my talk I did this year: http://tinycubestudio.com/portfolio-item/unite-2013-talk/ <- click download there


    Maybe that's overkill though, and inst will just work. Either way, cool to see the vertex shader extension system being used :)
     
  41. krautsourced

    krautsourced

    Joined:
    Dec 3, 2012
    Posts:
    4
    I'm just using one of the numerous variations of pseudo-randomness out there now, and that works well enough. Thanks for the tips though!

    Code (csharp):
    1.  
    2. float rand(float2 co){
    3.     return frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453);
    4. }
    5.  
    6. ...
    7.  
    8.         #ifdef TC_UV_SPRITE_ANIM
    9.             half2 uv = bufPoints[id] + 0.5f;
    10.             int spriteMax = (int) (_SpriteAnimWidth * _SpriteAnimHeight);
    11.             int sprite = (int) (abs(rand(float2(inst, inst))) * (inst % spriteMax));
    12.  
     
  42. LeoSalles

    LeoSalles

    Joined:
    Dec 22, 2012
    Posts:
    11
    Last edited: Feb 10, 2014
  43. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    100
    The strange thing is: I can perfectly play, build and run the demo scenes which heavily use prefabs - even in the complete project. Is there a limit of how many particle emitters may be active in a single scene? I am asking because I am instantiating a lot of particle effects to make the scene feel more alive.

    Edit:
    Alright, I started with manipulating newly added TCParticleSystems. The problem is: not all variables are exposed with setter methods. This is bad, because I cannot replicate the original designs at runtime. Do you plan to expose variables any further?
     
    Last edited: Feb 11, 2014
  44. SkermunkelStudios

    SkermunkelStudios

    Joined:
    Dec 29, 2012
    Posts:
    156
    What work around is there for Mac and Linux builds? As we need to have at least some basic particles for Mac and Linux.
     
  45. tomato_comet

    tomato_comet

    Joined:
    Oct 17, 2013
    Posts:
    18
    I am interested in this asset. Tried the demo. Looks great. Is it possible to make the particles emit light? Not necessarily each single particle, but somehow attach a new light source for each emission instance?
     
    Last edited: Feb 13, 2014
  46. Lex-DRL

    Lex-DRL

    Joined:
    Oct 10, 2011
    Posts:
    140
    @tomato_comet
    If you want to emit a cloud of particles which is close to the spherical shape, there should be no problem.
    Just position the light in the center of particles cloud (probably at the same position where emitter is). It should approximate the light from particles. If they don't intersect the floor. And have about the same color.

    But if you have quite a complex particle cloud, I don't see the way to emit light from it. You need to have some kind of realtime global illumination for this.
    I only saw it here in the "Voxel Cone Tracing" demo. And have no idea how exactly this voxel-cone-tracing thing works. I saw no implementation of this publicly available yet.

    Another solution would be applying "sun shafts" image effect, placing pivot point at the center of the cloud. It won't actually illuminate the scene, but... I don't know what exactly you're trying to accomplish. So maybe it will work for you.
     
    Last edited: Feb 13, 2014
  47. tomato_comet

    tomato_comet

    Joined:
    Oct 17, 2013
    Posts:
    18
    Thanks. I was just picturing "invisible light bulbs" objects, that emit light, flying around with the particles and making pretty shadow affects everywhere the particles fly and collide (walls, floors, etc.). The ratio could be for example 1 light to 1000 particles. The "light bulbs" would behave as the particles do and be considered a "particle" (though in name and behavior only).

    I'll purchase now on this sale and anticipating 2.0. Thanks.
     
  48. Lex-DRL

    Lex-DRL

    Joined:
    Oct 10, 2011
    Posts:
    140
    If you want 1 light source for every group of ~1000 particles, then... I don't know.

    Maybe, programmatically (at runtime) build a geometric representation (mesh) of the particle cloud's volume. And then split this volume into pieces (e.g., using Voronoi algorythm), find their centers, create light sources at that positions...
    So, it's a lot of coding. And I'm not sure if TC Particles plugin can output this volumetric representation.

    I guess, only plugin author (p v loon) can answer about this. I'm just a user.
     
  49. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    297
    When using the Boids Flocking setting, is there any way to set a target for the boids? (using the indie version)
     
  50. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Hi Just got the asset and when I try to play any of the sample scenes (except for the dusty moon) I get a hard driver crash.
    I've updated both Unity and AMD drivers to latest versions. Other unity projects work fine and I have no DX11 gaming issues, your webplayer works fine for example.
    Can you offer any advice?
    Thanks

    Unity free, Win 7 x64
     
    Last edited: Feb 14, 2014