Search Unity

Better Trails - Unity3D Trail Replacement (Trails, smoke plumes, skid marks, etc!)

Discussion in 'Assets and Asset Store' started by Pigeon Coop, Mar 19, 2014.

  1. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Nice.. :p
     
    Pigeon Coop likes this.
  2. varfare

    varfare

    Joined:
    Feb 12, 2013
    Posts:
    227
    Velocity handles. It's all in the sucker punch papers.
     
  3. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Nice, I flicked through the links you provided on the previous page while I was at work but didn't get a chance to look in to it properly. I'm reading through it now :)
     
  4. SnakeTheRipper

    SnakeTheRipper

    Joined:
    Dec 31, 2014
    Posts:
    136
  5. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Thanks Snake!

    So when I left Better Trails on the asset store, I was sure it was working just fine..! And I did some tests tonight and on my end it is working perfectly fine.

    Better Trails was still using some outdated API in the example scripts ('.rigidbody' and '.animation' for example), and I had a piece of editor code that was generating a shader code via string which is now marked as obsolete. I have corrected these issues, but I couldn't find any other problems..! I was able to build successfully to PC and Android. All demo scenes worked fine.

    My suggestion, for those having trouble migrating to U5, is to FIRST back up your project, then delete the PigeonCoopToolkit/_Effects (Trails) Examples folder and the PigeonCooptoolkit/Effects folder. Then reimport BetterTrails, fresh from the asset store. Any trail scripts you may have attached to objects should still be retained after you do this, even though you deleted the entire plugin and reimported it. :) (If you run into issues, restore your backup and post here for some help).

    I've submitted an update to the store (1.5) and now I will start work on 2.0.
     
  6. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Hey ya'll!

    So I did a bit of work tonight and rewrite a lot of code! I am at a point where I have the standard trail renderer working with the new system. :)

    In the current system, the rendering and batching process is very awkward. It only works with the camera marked as main and there are some sorting issues with the batching that I am having trouble fixing because I am not using a 'real' 'renderer' to render the trail.

    This is all changed in the new system. :) Internally, it is rendering the trail with a Mesh Renderer/Mesh filter, so this means Unity can handle the sorting and even batch particles together if you have dynamic batching enabled. Super awesome! I don't have to manually stitch together meshes to batch them together. This approach feels a lot more 'native' to Unity.

    The trail renderers will now work 'per camera', including the scene view camera, so you can pause the game and fly around the scene view and the trail will continue to align itself to you correctly. (See the gif bellow).

    Oh, also, there was some code that I could not get rid of in the current system, and that code was generating a small amount of garbage. In the new system, now that I am leveraging a mesh renderer, I was able to cut out some of this code. I managed to remove the last bit of code that was generating garbage. Yay :) The 18 trail renderers in the GIF bellow do not generate any garbage.

    So, check out the GIF, and here is a TLDR:
    1. Unity itself will now handle the mesh batching (Dynamic batching must be enabled), resolving sorting problems and upping the performance a little.
    2. The trails align with the camera on a per-camera basis, so the trails in the scene view visually look correct and as do the ones in the game view from a different camera/camera angle.
    3. So far, with a simple trail system, no garbage is being generated by the trail renderers


    Next, I am going to see if I can improve performance.
     
    hopeful likes this.
  7. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    More info! This time a little more technical..

    Here is an image of what those trails above look like in the inspector:



    • BetterTrail script manages the trail effect on this game object.
    • 'PointSpawner' scripts spawn new trail points.
      • My NewTrailPointEachFrame script is a PointSpawner. It spawns a point every frame.
      • I could easily make it spawn a point every X seconds, or after the trail renderer moves X units, or I can even make it spawn multiple points at once (for example, Smooth Trails)
    • 'PointModifier' script modifies the properties of each point of the trail
      • My BoringPropertySetter script is a PointModifier. It sets the color/size of the trail, and sets the UV value (UV.x) of the point to whatever percentage of lifetime the point has remaining, which effectively means the image being mapped on the trail mesh will stretch from start to finish.
      • I could easily do things like color gradients, UV tiling, size fluctuations. I can modify most properties of the point which includes its position so I could implement various 'noise' modifiers.
    What do you guys think so far?

    The idea is to expose as much of the trail generation as possible! Better trails will ship with a whole bunch of modifiers and spawners, so you won't need any programming knowledge to use it! The idea is that these modifiers and spawners are like building blocks to construct a cool trail effect, and the bonus is that you can write you need a certain kind of special effect. :)
     
    IndieAner3d likes this.
  8. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Yes. 13ms.... a lot... :D
     
  9. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Oh wow, nah, my script does not show up as 12ms in the profile haha! Pretty sure the value in that stats box includes everything, even vsync wait! :) I just had it open to show the batch count.
     
    Last edited: Jul 30, 2015
    ZJP likes this.
  10. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    We are now halfway to being fully multithreaded ;) The trail data updating is all multithreaded now. Slowly the foundation is coming together. :) Mesh generation next.
     
    ZJP likes this.
  11. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I like where this is heading! We had some Performance-Issues with BetterTrails. At least we think BetterTrails was the problem and not our code :p
    Looking forward to those updates.
     
  12. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    :) It should be a fair bit faster now. What platform where you guys/gals developing on?

    I have the mesh multithreading working. All of my 'proof of concept' work is done and it is looking pretty good!


     
    overthere, Fab4, ZJP and 2 others like this.
  13. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Dem effects! :D

    We're developing for PS Vita (native, with DevKits, not PSM!)
     
  14. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Thats awesome. :) I have never developed on a PS Vita but I have heard that it can be a battle to get a decent frame rate, I can imagine why Better Trails in its current state might cause some issues. Hopefully, the fact that I've patched up the wasteful GC allocations and introduced multithreading will help in your future projects.

    Here is another screenshot with profile included. I can hit 300 trails before I fall bellow 60 FPS (of course that doesnt really mean anything since our machines are different :p ), no garbage is generated. The trails are all fairly long too. I can't imagine a game having much more than 50 trails let alone 300 haha.

     
    ZJP and BTStone like this.
  15. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Uh, very nice! Well I don't now how BetterTrails performs on mobile devices, but I'd say one can compare a PS Vita with an the Power of something about iPhone 5 to iPhone 6, should be pretty ok I guess. and we only use trails at specific points and there are few of them (under 10)
     
    Pigeon Coop likes this.
  16. varfare

    varfare

    Joined:
    Feb 12, 2013
    Posts:
    227
    Nice. I like the way you handle trail bending. It is horrible in built-in trail renderer. It seems that you are pushing the limits of trail renderer :)

    There is another feature that I would like to request - bent normals. Current problem -> normals of trail are flat. Any shader without normal map will result in flat looking trail. What I'd like to request is a ability to generate cylindrical normals for whole trail. You can check out Shuriken "normal direction" parameter for reference. Having possibility to bend normals would allow me to create lit trail shader without any normal mapping inside shader.
     
    Pigeon Coop likes this.
  17. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    That should be fairly simple, I'll play around with it tonight. :)
     
  18. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    cool thing the normals.. and for information.. it will be possible have only normal map? I explain: suppose that the trails are on a gravel terrain, will be cool that the result was the same texture under the trails, but with the normals seems that are 'escaved'
     
  19. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186




    @ghiboz I am not sure if that is possible, but you are free to use any material/shader you like, even the ones you like. Your sky (or, well, your shader knowledge) is the limit! :)
     
    hippocoder, varfare and BTStone like this.
  20. varfare

    varfare

    Joined:
    Feb 12, 2013
    Posts:
    227
    Nice. That what I was talking about.
     
    Pigeon Coop likes this.
  21. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Version 1.5 is out! Nothing exciting this time, I am sorry!

    Change log
    • Did a pass on the asset to ensure that it is ready for Unity 5
    Update Notes:
    If you are experiencing any issues in your project, it might be worth reinstalling Better Trails. I've had reports of people who are experiencing difficulties that I just couldn't recreate in a fresh project. My thinking is that something broke along the way when updating..

    Anyway, first, back up your project. Next, delete thePigeonCoopToolkit/_Effects (Trails) Examples folder and the PigeonCooptoolkit/Effects folder. Then reimport BetterTrails, fresh from the asset store. Any trail scripts you may have attached to objects should still be retained after you do this, even though you deleted the entire plugin and reimported it. (If you run into issues, restore your backup and post here for some help).
     
  22. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Does anyone want to alpha/beta test 2.0? Wouldn't hurt to get a fresh pair of eyes on this!
     
  23. varfare

    varfare

    Joined:
    Feb 12, 2013
    Posts:
    227
    I can check it out but I'm off on vacations till August 9th.
     
    Pigeon Coop likes this.
  24. Attwell

    Attwell

    Joined:
    Feb 11, 2015
    Posts:
    1
    Hi Pigeon Coop, I'm new here but willing and able to test 2.0. Currently using 1.5 with a range of trails, smoke plumes, smoke trails dozens at a time and all performing "acceptably" on ipad. Would be interested see any performance gains from your updates :)
     
  25. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Sounds good @varfare + @Attwell, I need to put a scene together to help you guys profile the performance on your devices first, once I have it all ready I'll let ya'll know.
     
  26. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Multithreading is hard. Nothing new to update! Just fixing some bugs. :)

    Should have something this weekend ready for testing.
     
  27. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Wow, never seen this thread before. Just randomly discovered it today and realized it was years old. Read through everything and seems a lot has been happening in the last few days. :p

    I'm surely getting this. There's a lot of assets on the asset store I may need, but this is one I definitely need. I use trails for everything. Anything with a trail is just better than anything without a trail.

    As long as it doesn't impact those of us who prefer to do things through code. :D
     
  28. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Well I only said that to make the non-coders comfortable, since it was so sounding pretty technical!

    It shouldn't impact you at all, you are going to have a lot of control writing your own point modifiers and spawners, especially when you consider the fact that I'll be reimplementing the Smooth trails, smoke trails and smoke plume trails using the same code you'll have access to :)
     
  29. vidjo

    vidjo

    Joined:
    Sep 8, 2013
    Posts:
    97
    If you could remove garbage collection I would love you forever. ;)

    But seriously, I'd be willing to pay again /bribe
     
  30. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Never did get around to buying this. Or did I? I really can't remember. Anyway, looks brilliant, glad to see the final performance hogs are dead :)
     
    hopeful likes this.
  31. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Hey bud! So far there is 0 garbage collection required because no garbage is generated. Once the trail has spawned it is garbage free till it dies :)

    @hippocoder Thanks man. I am glad too!

    I've fixed one of the major multithreading bugs that had stumped me for a few days. Turns out animation curves are not threadsafe!

    Working on a way to disable threading, mobile devices don't seem to like it.
     
    hopeful likes this.
  32. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Better Trails, Better Unity integration! I am replacing the pop up preview window with an actual preview area in the inspector, just like the ones you see for Materials! :)

    Here is an early screenshot, getting there! ;)

     
    IndieAner3d, hopeful and hippocoder like this.
  33. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
  34. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Quick question: Version 2, is it going to be an update for this product or a whole new product?

    Seeing this asset made me want to work on a project I haven't worked on in a while so I was going to buy this when I get home on Sunday. It's not exactly expensive so it's not a big deal, I was just curious.
     
  35. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    It'll be the same asset. I am still thinking about it, so nothing is confirmed..but I am considering new price. I plan on bumping it up to $20 for version 2, with no upgrade fee for those who have version 1.
     
    overthere and ZJP like this.
  36. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
  37. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    BTW, V2 still works on Unity 4?.
     
  38. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    That's a good point to mention. I am making use of some U5 features, and since it is a complete rewrite I am just going full U5 support.
     
    Last edited: Aug 10, 2015
    hippocoder likes this.
  39. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Oh.... Just keep/include the last V1 for those will stay on Unity 4 in the Asset Store package.
     
  40. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    For sure. The idea is that since BT2 is not backwards compatible, you'll probably only use it in newer projects. (Which you'd hopefully be using U5 for!)
     
    Last edited: Aug 9, 2015
  41. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Yes. Some projects stay on U4. :p
     
  42. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah, the minority or people so far along with a project they can't risk it. These guys will drop off. Reason being is you can't ignore the improvements of 5, it's just way, way better performance wise for a lot of things, not least multithreaded physics upgrade and the multithreaded rendering to come.
     
    Pigeon Coop likes this.
  43. derp_bot

    derp_bot

    Joined:
    Nov 21, 2012
    Posts:
    8
    Hello,

    I recently purchased this asset..

    Looks good, except I am getting an exception when I try to clear a system.

    I have simply attached a SmoothTrail to an object, in OnEnable set trail.Emit to true, and then when I despawn the object call trail.ClearSystem(false).

    Stack trace below. Any thoughts at as to what the issue may be?

    Thanks in advance


    PigeonCoopToolkit.Effects.Trails.TrailRenderer_Base.CheckEmitChange () (at Assets/PigeonCoopToolkit/Effects/Trails/TrailRenderer_Base.cs:401)
    PigeonCoopToolkit.Effects.Trails.TrailRenderer_Base.ClearSystem (Boolean emitState) (at Assets/PigeonCoopToolkit/Effects/Trails/TrailRenderer_Base.cs:533)
     
  44. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Hey! That doesn't look like fun.

    I am away from my computer right now but will check soon as I get home. Get back to you in an hour or so bud.
     
  45. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    @adam_dicker Not sure how this one snuck through - its a bug! I'll submit a fix, but in the mean time, here is a fix:

    On Line 412 in TrailRenderer_Base.cs, replace:
    Code (CSharp):
    1. OnStopEmit();
    2. _activeTrail.IsActiveTrail = false;
    3. _fadingTrails.Add(_activeTrail);
    4. _activeTrail = null;
    with

    Code (CSharp):
    1. OnStopEmit();
    2.  
    3. if (_activeTrail != null)
    4. {
    5.     _activeTrail.IsActiveTrail = false;
    6.     _fadingTrails.Add(_activeTrail);
    7.     _activeTrail = null;
    8. }

    The following code was used to reproduce your issue:
    Code (CSharp):
    1. public class BugRepo : MonoBehaviour {
    2.  
    3.     public PigeonCoopToolkit.Effects.Trails.Trail t;
    4.  
    5.     public void OnEnable()
    6.     {
    7.         t.Emit = true;
    8.     }
    9.  
    10.     public void OnDisable()
    11.     {
    12.         t.ClearSystem(false);
    13.     }
    14. }
     
  46. derp_bot

    derp_bot

    Joined:
    Nov 21, 2012
    Posts:
    8
    Thanks for the fast reply!
    That fix is exactly what I ended up doing.
    Looking forward to v2. Those screen shots above look mighty fine.
     
  47. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Just keep in mind BT2 will have a Unity 5 requirement and won't be backwards compatible with BT1. You'll have access to the same functionality but you'll need to replace your components.

    I am looking at a way to automate part of the upgrade process but there is no way to make it a seamless transition unfortunately. :(

    If you like you can PM me your invoice number and I can send you the beta version, though be warned there are lots of features still missing.
     
  48. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    That applies to anyone with an invoice number, send me your number and once verified I'll be happy to send you the current beta as well as any updates up until release. Again, it is beta, so stability and consistency is not garunteed..!
     
  49. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    nice v2 example, definitely looks sweet
     
  50. Pigeon Coop

    Pigeon Coop

    Joined:
    Jan 17, 2014
    Posts:
    186
    Thanks, @GCat !

    Progress update.. Slowly coming along! Mainly working on the code side of things, but I finally got @varfare's suggestion in to the system in a more 'polished' way, so that's working now, which is nice. Also, made the grid toggle-able.

     
    overthere and GCatz like this.