Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

2D Mesh Based Volumetric Lights

Discussion in 'Assets and Asset Store' started by reveriejake, Jul 5, 2012.

  1. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    2DVLS is currently unavailable. I am working on the next version right now, please keep an eye on this thread for further information!

    Jake
    10/16/2015
     

    Attached Files:

    Last edited: Oct 16, 2015
  2. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    303
    Looks Ace!
     
  3. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Thanks! The events the lights give off will hopefully make for some useful gameplay. If anything this is a fun toy to play with!

    Jake
     
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,153
    That really is very nice indeed.
     
  5. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    lol hey thanks. Still not at the caliper of some of your amazing mega-fiers stuff!

    Jake
     
  6. copenhagenjazz

    copenhagenjazz

    Joined:
    Oct 2, 2005
    Posts:
    45
    Hey

    This looks really great! Can I just ask, would this work in a 3d environment? I am not thinking about using this for volume light but instead as a viewcone for an npc.
     
  7. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,180
    Looks awesome!
     
  8. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    It kinda sorta does. The only issue with using it in a different plane is the UV mapping wasn't made to support that so it will be a bit funky. Right now the only UV mapping that is supported is x-y plane.

    If you want to use this as a view cone using the Events then as long as your using an invisible view cone I don't think there would be a problem.

    I attached a pic of it in 3D on the X-Z Plane.
    http://www.reverieinteractive.com/Light2DSamples/xzplane.png

    If you are interested in multiple UV mapping planes then let me know and I can implement it in the next release.

    Jake :)
     
    Last edited: Jul 6, 2012
  9. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
  10. copenhagenjazz

    copenhagenjazz

    Joined:
    Oct 2, 2005
    Posts:
    45
    Thanks for the reply :)

    Well what I am thinking of using it for is an isometric stealth game with only a single height level... a little like the old Commandos games if you played that but with a 3d camera that you can pan around the characters. As long as I only have one height level then you current system should work fine right?.

    If its not a big hassle for you to add support for multiple uv mapping planes then of course that would be a great addition to your product :)

    Cheers
     
  11. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Actually its not a big hassle at all to add that type of support.

    As I said, it will work for your use but the UV mapping will be kinda messy. So as long as you don't immediately expect the UV mapping to be correct then there is no problem. In the mean time I will get the UV mapping implemented in multiple axis'.

    Jake
     
  12. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,729
    nice. do your scripts generate any runtime garbage collection? And suitable for mobile?
     
  13. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Does this play nice with the likes of 2D Toolkit or SM2?
     
  14. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    I have not tested on Mobile but I can implement IDisposible and you can dispose of the object properly as needed. I am also putting in the feature that turns the lights off when they are not in view of the camera. Is this what you mean?

    I am still kinda new to the whole usefulness and when to implement the IDisposible thing and was actually recently stumped on it during an interview ;). Sense I am self-taught, there are these things that I have missed because they never became an issue for me! lol

    Any advice or help would be useful I want to make this as versatile as possible!

    It plays nicely with any sort of collider. I believe the 2D toolkit has the built in colliders so it should work no problem. I can test it out and make sure for you though.
     
    Last edited: Jul 6, 2012
  15. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Really nice!!!!
     
  16. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,729
    No I mean, do you do any allocations at run time or do you preallocate everything including arrays? The former would cause spikes while running an app, and lead to mobiles crying.
     
  17. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Hey I sent you a PM. I try not to allocate much of anything during run-time unless its necessary.

    Jake
     
  18. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    2DVLS Is now only $15! As I mentioned in my first post I wanted feedback on pricing and due to the interest I decided it would be best to lower the price to $15 which will make this super affordable.

    Enjoy,
    Jake
     
  19. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114
    Looks very cool, I´m assuming it works with Free and Pro versions.

    Thus this require any specific shader to be used? Or is independent...

    You could add some kind of tutorial/ docs. Even if its very simple it would allow us to see the workflow in a familiar place --> the UnityEditor :)
     
  20. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    I was wondering if this worked for Free as it doesn't seem to be explicitly stated anywhere - I would also be interested to know if it works well with 2Dtoolkit. Looks very good though and pending these answers I'll certainly pick it up for this new price!

    //EDIT: Additionally I am wondering if there is any way to edit the masking style? Could it support transparency for softened edges, and what about fall off for the mask - so instead of infinitely stopping the light behind the object it would eventually ... fade back to light (surely that doesn't make as much sense as I want it to)?
     
    Last edited: Jul 12, 2012
  21. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Since the script is using the GL class it will not work on versions below the upcoming Unity 4 (according to the license comparison HERE) But I am working to switch from using the GL class to actually building a mesh so that it will work on free and pro versions. The update should also include some updates to performance.

    If you are interested in the script and have Unity FREE please stay tuned for the next update. I will post when the update is live on this thread.

    Jake

    Works with Unity FREE versions
     
    Last edited: Aug 22, 2012
  22. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    Excellent. I'll be interested in that (The version which will function in Unity Free). Will it be considered the same asset - I only ask because I'll purchase it now to support its/this further development.
     
  23. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    It will be released as V 1.1 so yes it should be considered the same asset. If you do purchase it and find out that you can in fact use it in your version of unity please let me know! I was just going by the guidelines on the license comparison page ;).

    Thanks,
    Jake
     
  24. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    Just purchased it - it works just fine on my Mac in the latest version of Unity (3.5.3f3) and I assume it will also work on my main Win machine. As a side test I also slapped it into a testbed scene with 2D Toolkit and it worked flawlessly. This is excellent stuff, I'll be playing around with it all night now.

    My earlier questions about drop off and blending for the edge rendering still stand.
     
  25. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Cool! I am glad to hear its working on free versions of Unity :). I am still going to move all the code away from the GL class though but there shouldnt be anything visually different. Just need to improve some things performance wise and allow for 3D manipulations.

    Thanks for trying it out and let me know if you have any questions.

    Jake
     
  26. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114
    So confirmed working on Unity Free 3.5.3, great
    Can you comment on performance?
     
  27. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @Threeli as requested by Uttpd could you let us know how the performance is. It test pretty well on my system but it would be nice to know the evaluation of other systems.(Unless of course you have a light set at full detail of (50k rays) ;))

    PS: Performance optimizations in the future update will include switching non-visible lights off so they are not rendered.
     
    Last edited: Jul 13, 2012
  28. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    On my MacBook Pro (I am not at home right now so I cannot test out my more powerful machine) with :

    4 Separate size 100 radial lights at 600 detail interacting with 25 onscreen meshes ( of various shapes) I run at 50 FPS
    I tried the same test with 300 detail instead of 600, and I was able to raise the number of onscreen meshes to 100 and the frame-rate wouldn't drop below 80.
    (Even with countless physics interactions taking place) The noticeable quality between the two is minimal.

    Finally I dropped the detail of each light to the default setting of 200 and was able to get 16 huge radial lights to run at 45 - 50 FPS.

    When this happens :
    There should be no issue with having a huge number of lights at high detail so long as you have a reasonable number on screen.
     
  29. Threeli

    Threeli

    Joined:
    Jul 9, 2012
    Posts:
    12
    Quick question, instead of cutting off the rays at collision to generate a void of "light" would it be possible to shoot out secondary rays to "shadow" the space behind the object. (Quick question, not such a quick concept.)
     
  30. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    It would be defiantly be possible to do this.

    Jake
     
  31. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114
    Everything is working as advertised :)

    almost a Bug; When you chose cameras it only puts a check in front of the first Camera, the others while selected do not get the check, The label on top is updated correctly

    suggestion:: You could send a copy to hutongames (Playmaker) and get them to support your tool with some actions --> mainly the sending Events. It should get you some "free" attention
     
  32. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    This seems to work on my end. Could you provide me with a way to recreate this error?

    Thanks,
    Jake
     
  33. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114


    Win7 Unity Free. I´m using 2dToolkit cameras. Only the one on top gets the check.
    No biggie.

    Also, On the first install, got a yellow error saying some conflict OS X / Win, went in to game mode and back cleaned the error and never saw it again.
     
  34. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Okay, so it seems to be the naming convention used on the camera. If you change the name of "tk2dCamera" to "tk2dCamera_main" then it should fix your problem. I am not sure why that happens yet as I havnt looked through the code.

    As for the warning message you get, its due to line endings in the code. I try to clean that stuff up before shipping but the warning can be safely ignored for the time being.

    Jake
     
  35. trothmaster

    trothmaster

    Joined:
    Jun 8, 2012
    Posts:
    73
    Hi!
    Does this support cookies?
     
  36. krakov

    krakov

    Joined:
    Jul 23, 2012
    Posts:
    11
    I really hope you keep improving this stuff, heres some hopefully useful results feedback:

    Performance:
    (i5 2500k, 560ti, 8gb, Unity Free 3.5.3f3).
    NB: Only tested in editor so far its impact seems pretty heavy.
    - it normally takes quite a lot of stuff going on to drop below 100fps on my pc (angry bot demo stays around 250-300 fps in editor) but the 'sunny day' demo runs around 40ish fps.

    Visuals:
    Can look fantastic! its pretty easy to use...but also pretty easy to...

    How to make it look bad:
    Take up to much screen space with too low a detail setting the 'shadows' start jumping large gaps glitching between their next previous positions, even with stationary objects. Its especially apparent on slow moving objects.

    Feedback:
    Currently i'd see this as a useful spot effect, but I'm hoping there will be more to this system in the future. If you have a moving zooming camera you have to be super careful with light size detail settings which impacts on the design, look time spent.

    Suggestions:
    I want the detail setting gone completely, i'm beginning to hate that thing! I don't want to have to worry about how detailed a light needs to be to look ok - I want the lights to know how much of the screen they're taking up and adjust themselves accordingly. I should be able to have atleast some lights taking up rather more than the full size of the screen running at the same time I doubt I can do that currently with acceptable performance.

    Good Luck
    Unitys own lights shadows have yet to really blow me away - especially for the price, which is why I'm sticking to Unity free for now (because I doubt I could do it) why I'm very interested in your 2d solution.

    You've probably come across the phrase 'painting with light'. I would like to paint with these lights so i'll be happy to help testing out new stuff you come up with I have a bunch more suggestions.

    Watching how 'The Swapper' has gone from this to this is pretty inspiring.
     
  37. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Yeah I do plan to continue support for this. Currently its updating the lights every update but I would like to start making it so that the light only updates when an object that has the same tag as the shadow tag has entered the light radius. I hope this alone will drop the frame rate of multiple lights way down. As for the DETAIL setting. It might not be as useful once I get the above improvement done but the idea of that was for use with static lights that do not move. You could set your detail really low for directional lights and use it in the background for scene lighting without the performance needed for one with a ton of detail.

    I will post any updates on here!

    Jake
     
  38. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    71
    You should make the mesh update at a user-configurable rate, and rip everything out of Update entirely. Retool it to run the function at a set interval, but an adjustable one. Running on Update is probably neutering performance, when we could add so many more lights to the scene by allowing it to only update 60 or 30 (or etc.) times per second. Could gain a huge amount of performance. As it is, I can get in about 3 moving lights at an acceptable detail level before the game grinds down to about 40 FPS on my gaming PC.

    These sort of performance fixes are absolutely necessary in my opinion, especially since Detail values below, say, 400, look very "chunky" when the light is in motion.
     
  39. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Yeah as I said performance issues are being taken care of right now. Give me your Skype Jason and I can send you the current state of lights.

    Jake
     
  40. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Okay the newest version of the 2d lights system is coming VERY soon. I have done some pretty significant optimizations on the system and it runs at a minimum of 2 times faster!

    Here are a few optimizations that were done:
    1) lights now use 1/2 to 1/3 the amount of Physics.Raycast calls
    2) lights now only update when there is an object on the shadow layer within range of the light
    3) lights now only update if they are on screen and visible by the camera
    4) You can now specify which objects are "Static" which allows you to render the shadows on static objects without updating the mesh.

    Tid-bits:
    1) The new version uses the "Mesh" class and no longer uses the "GL" class.
    2) UV's are fixed on the mesh when rotated in any direction
    3) lights can now be infinitely deep in a hierarchy without glitching the light
    4) Meshes still work when rotated for top down cases
    5) The mesh detail variable is now an enumeration limiting it to 5 selections of "Low, Normal, Medium, High, Very High" mesh detail.

    WARNING:
    This update is an overhaul update so please expect to have to setup your scenes again. This is a trade off that had to be done in order to incorporate some of the new optimizations. Sorry for the inconvenience!

    ETA: 08/21/12

    Jake
     
    Last edited: Aug 20, 2012
  41. Matkins

    Matkins

    Joined:
    Aug 24, 2009
    Posts:
    151
    Hey,

    Thanks for putting out this plugin at such a good price, it's going to be really useful for my game. I do have a request though, hopefully it's an easy one. It appears that I can't instantiate lights from a prefab in runtime. It produces this error continuously:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. Light2DMesh.SubmitForRender (.Light2DRenderer light2DRenderer, UnityEngine.Material material) (at Assets/Light2D/Core/Light2DRenderer.cs:21)
    4. Light2DEmitter.GenerateRadialMesh () (at Assets/Light2D/Core/Light2DEmitter.cs:334)
    5. Light2DEmitter.Update () (at Assets/Light2D/Core/Light2DEmitter.cs:161)
    6.  
    It would be handy to be able to do this, for example; spawning players/enemies who have flashlights.

    Cheers.
     
  42. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815

    Issue Was Fixed in V2.0

    Below is an image of the lights playing well with 2D Toolkit...


    I suggest you contact me for a sample of the new version which I am finishing up today.
    Email: jake@reverieinteractive.com
    Skype: reveriejake


    Jake
     

    Attached Files:

    Last edited: Aug 22, 2012
  43. thunderstorm

    thunderstorm

    Joined:
    Jun 25, 2012
    Posts:
    10
    This is fantastic work! Thanks.
     
  44. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Still working on the new version. I am thinking that I am going to drop the directional light type.

    If anyone has any thoughts on that let me know.

    Jake
     
  45. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Update Screenshot :)

    2500 lights with about 15 on screen with static meshes casting shadows. Runs at 71 FPS in editor displayed by the statistics window.



    Now has ability to use in multiple directions.


    Now has cleaner and better event system. This system is powerful and can also be used for things such as FOV systems!


    Simplified editor so you no longer have to assign cameras via a cumbersome system. Now it works just like the layer mask system throughout Unity.



    Easier to use via code as well!

    Code (csharp):
    1.  
    2. // 4 static functions available to create the light at runtime. All return the Light2D object that was created.
    3. Light2D.Create(Position, Material, Color);
    4. Light2D.Create(Position, Material, Color, Radius);
    5. Light2D.Create(Position, Material, Color, Radius, SweepStart, SweepSize);
    6. Light2D.Create(Position, Material, Color, Radius, SweepStart, SweepSize, DetailSetting);
    7.  
    8.  
    9. // LightEnabled property allows you to disable the light without destroying it.
    10. // This can also be done by disabling the gameobject via gameobject.active = false;
    11. myLight.LightEnabled = false; // light disabled
    12. myLight.LightEnabled = true;  // light enabled
    13.  
    14.  
    15. // The following enumeration is used for the detail settings
    16. public enum LightDetailSetting
    17. {
    18.     Low          =   250,          // Means there are 251 Physics.Raycast calls from the light
    19.     Normal      =   500,         // Means there are 501 Physics.Raycast calls from the light
    20.     Medium     =   1000,       // Means there are 1001 Physics.Raycast calls from the light
    21.     High          =   2000,       // Means there are 2001 Physics.Raycast calls from the light
    22.     VeryHigh   =   3000,       // Means there are 3001 Physics.Raycast calls from the light
    23.     Extreme    =   5000        // Means there are 5001 Physics.Raycast calls from the light
    24. }
    25.  
    This is the next version which should be out very soon.
     
    Last edited: Aug 20, 2012
  46. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Okay I am about to update the 2DVLS. To see a sample of improvements go HERE

    Update was submitted and should be available 8/21 unless there is a problem in review!
     
    Last edited: Aug 21, 2012
  47. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    580
    Hi,

    in your last update there is Rotate.cs which has the same name as a class inside the Playmaker package. Playmaker is already used by many, it is fine to change the name of this class for moment but if you can change it inside the next update would be best. Some other people might just see an error and dont understand how to fix it.

    Playmaker and other should avoid using such common names for classes :p

    Anyway i like your package and hope you will keep supporting it.

    See ya
     
  48. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Yeah I sometimes forget I must play nicely with others and forget that Rotate.cs might be a bit generic ;). I would say if your not using the sample projects then go ahead and delete the script completely.

    I will push a minor update with this fix in it along with some stuff for Playmaker and uScript as I have been asked to do that as well!

    Thanks for pointing it out!
    Jake


    PS: Would be really cool to see what some of you have done with this system via this forum. I have already been shown some really neat concepts that make use of the Event System!
     
    Last edited: Aug 22, 2012
  49. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    580
    there is another small error since the last update :

    Assets/Light2D/Core/Light2DEmitter.cs(6,22): error CS0101: The namespace `global::' already contains a definition for `Light2DEvent'

    If you could suggest a way to fix it,

    thanks !
     
  50. Uttpd

    Uttpd

    Joined:
    Feb 27, 2010
    Posts:
    114
    Looking forward
    Playmaker actions would be great :)



    with 2 (radial) ligts
     
unityunity