Search Unity

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:
    819
    Okay demo scene #1 showing cone light and radial light.. You can drag the boxes around the scene and the light will follow it...

    Let me know of any issues!

    http://picogames.com/VLS2D/Demo1

     
    PTrefall and AMO_Noot like this.
  2. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    Looks awesome! I get a null exception when clicking the ground though :)

    Looking forward to the 4.0 update!
     
  3. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Yeah it was a thrown together demo ;) so no checking for if floor is valid draggable object lol.
     
  4. cg_destro

    cg_destro

    Joined:
    Aug 13, 2013
    Posts:
    142
    nice demo! I like it :) 4.0 gonna be great :)
     
  5. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
  6. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Getting close guys!

    Performance test with lots of circle colliders... Supporting Particles & Static lights (VLS2D 4 Pro)

    Also I would like to note that 4.0 no longer has that bug where you must save the scene even if there are no changes made.

    http://picogames.com/VLS2D/PerformanceTest/
     
    Last edited: Jan 3, 2015
    PTrefall and AMO_Noot like this.
  7. cg_destro

    cg_destro

    Joined:
    Aug 13, 2013
    Posts:
    142
    I have some errors look at this video http://www60.zippyshare.com/v/69113322/file.html there is more lagg and freeze because of recording but normally afters couple seconds it gets unstable and blinking like there is two layers of spheres, and sometimes spheres when move blend, motion blur with bloom or something like this, hard to describe

    my spec win 8.1, geeforce 780, i7 4770k
     
  8. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    I think it looks better like that ;).

    I will look into why its doing this...

    Jake
     
  9. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @cg_destro

    Try again.. Let me know if it works any better...
     
  10. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Im wondering if anyone else is having the same issue...
     
  11. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Working fine on my end! Looking good.
     
  12. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    :cool: Hey guys!

    I keep saying "I'm almost done" and I realized it was a bit vague so here is a list of things I have ready to ship, a list of things I need to finish before I will ship, and an unofficial list of things I would like to add in the next update.

    Here is what I am going for and honestly this is probably the look you can get with Unity Pro and VLS2D at this point in development. FROM Rayman Legends (NOT VLS2D 4.0)


    Hopefully this clears up some questions about how close VLS2D is to being released!

    Ready To Go v4.0:
    1. Unity Pro shader [Done (In Beta)]
      • Allows overlay textures
      • Photoshop like layer system
      • Blur and Overlay can be applied to each light layer as well as each physical layer
      • Light intensity can be set per layer
    2. Basic Radial Light [Done (In Beta)]
      • You can now adjust the transform to distort the shape
      • Reimplemented the cone angle setting
    3. Radial CS Light [Done (In Beta)]
      • Same as Radial light except you can adjust the emission point
    4. Debug Tools [Done (In Beta)]
      • A window that allows you to toggle where rays are being cast and how the bounding volumes are interacting with each other (This was requested).
      • This also allows you to set default values like light layers
    5. Customizable obstructions that are not reliant on unity colliders [Done (In Beta)]
      • They include a variable to reference Collider2D types so the shape will match the collider
      • You can have multiple obstructors on one object
    6. VLSViewer class to improve performance (I hope) [Done (In Beta)]
      • Helps manage the scene and only keeps lights and obstructors that are being used active

    ToDo v4.0:
    1. Add directional lighting (linear falloff in shadows?) [Conceptualized]
    2. Add area lighting (Basically a triangulated mesh that you can customize the shape of) [In-Production]
    3. Support Unity free version? [Conceptualized]
    4. Add event system [Planning]
    5. DOCUMENTATION :confused: [Planning]

    ToDo v4.1: [All in Planning]
    1. Add reflectivity
    2. Add Laser type?
    3. Optimize More...
    4. Add shaped lighting (Basically a triangulated mesh for customizable fill lighting)
     
    Last edited: Jan 7, 2015
    Zilk and mimminito like this.
  13. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Looks great!
    Does this (hopefully) include 3D Colliders as well?
     
  14. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @Kirbychwan - Not at the moment but you can add obstructors to objects with 3D colliders on them. From there you could manually edit the obstructor's vertices to match the 3D colliders vertices. But who knows... Maybe I will add it in for you ;).

    Jake
     
  15. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Okay @Kirbychwan, I have added support for BoxCollider's and SphereCollider's.. I might add Mesh Collider support if I get around to it.

    Jake
     
    AMO_Noot likes this.
  16. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Thanks! That would be perfect if you could, as 2D Toolkit's tilemapping (and a few other tilemappers for Unity, I think) uses Mesh Colliders in general.
     
  17. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Good point. I will add it too then ;)
     
    AMO_Noot likes this.
  18. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Fantastic. Also, reflectivity and lightbeam/lasers sound amazing for hooking up some of those classic mirror and lightbeam puzzles.
     
  19. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    I downloaded the Unity 2D Tutorial project: https://www.assetstore.unity3d.com/en/#!/content/11228

    I added a Directional Light into the scene.

    How do I put the Directional Light in front of the background so only the hero (bean man) will affect the light?

    There is no Sorting Layer property on the light.

    Thanks!
     
  20. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @TobiasP - Yeah the sorting layer things is a bug from the older version of 2DVLS. All the lights are on layer 0 by default though so the easiest way to fix that would be to just move everything back to the negative layer. I also have a discontinued Beta that includes the sorting layer parameter if you would like to try that out.

    You can email me if you like. reveriejake87@gmail.com

    Jake
     
  21. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    So do I get this right that in 4.0 you'll add new Shaders?
    I really like the tool but I don't use it because of the Cutout-Shader I need to use to get it to work with my sprites. It makes the assets of our game look so terrible, even after tweakin the cutoff. Or maybe I'm using it wrong.
     
  22. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @BTStone - Yes the cutout shaders did look terrible. I tried really hard when I first released 2DVLS to find a solution for semi-transparent shaders but I kept getting told that what I wanted was impossible to make without Unity Pro ;).

    The 4.0 version will have all the necessary shaders you need for scenes that match what I have posted above as long as you have Unity Pro. For Unity Free I am still working on a solution but the most likely solution will be to just use depth mask to mask off an overlay which might look ugly but it will get you buy until you can pick up a Unity Pro license unless of course that cutout look is the look your going for.

    With that said, the Unity Free version of VLS2D will be sold for free on the Asset Store. But since you already own a copy of VLS2D, you will automatically get the Pro version.

    Hope that answers your questions,
    Jake
     
    BTStone likes this.
  23. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Ah I see! I thought it doesn't matter if I have Unity Pro or not. Well that suits me fine, in the next couple of weeks I'll get a Unity Pro License.
     
  24. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    It wasn't too big of an issue back before sprites were introduced. You just had to unfortunately deal with the cutout shaders. The issue is that I need render-textures to apply the proper lighting effect to the scene and the Free version of Unity does not allow that. So instead, I had a shader programer write up shaders that mimic the final result as best as he could. But there were takeaways to that. You couldn't have semi-transparency, the shaders were fixed, and they didn't deal with layers well due to how they worked. This is why I have basically decided to just stop claiming compatibility with Unity Free and move on to something that is a bit less hacky. But for the Unity free users I still want to offer something they can use that might not be as pretty as Pro can achieve.

    Jake
     
  25. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    That spotlight demo above is awesome, can't wait for 4.0! :)

    And that video you posted of Rayman, comparing it to the spotlight demo, you're already on their level. Great work, man!
     
    reveriejake likes this.
  26. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Question for anyone who is willing to answer. I am still wondering how you guys want to see the event system. Should it be made like the previous version where the light calls the method and passes its self plus the object it has hit? Or should it be made differently?
     
  27. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    Personally I would prefer it done differently, but I don't know how that stuff works behind the scenes so I couldn't offer a better suggestion.

    I just have concerns with the current method because it seems like it could be a performance issue if you have a ton of lights and a ton of events being called -- which my game does, with enemy vision using Light2D and each enemy needing to process a variety of objects in its vision. It would be ideal if the lights worked like normal OnTriggerEnter calls and only called its own function instead of every single light's function. But, again, I have no knowledge on how that works!
     
  28. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Well if I do it the same way I will be changing how its handled in the background. The plan now is to manage everything from a singleton class (VLSManager) that way you have only 2 lists of objects in the entire scene to call events on instead of 2 lists per light that has "isEvent" ticked. The singleton class might have a bit more work as far as filtering through the list but at least it will only do it once.

    I am just concerned about what I am passing. I have been asked why I called "OnLightEnter" and passed "GameObject" and "Light2D" forcing the user to have to do their own comparison when they use the event. I just thought that was the easiest way to do it but I could be wrong.

    So I guess my question is do you like the way the events are sent now or would you prefer me to say "OnLightEnter" every time a light enters the object and only pass the light that is calling the event to the object?

    Hope that makes sense.
     
  29. fiote

    fiote

    Joined:
    Jan 8, 2015
    Posts:
    7
    Hello! I just bought this asset and I'm loving it so far.

    I'm pretty new at Unity so i'm sorry if this is a silly question but: how can I make everything that's not hit by light be hidden?

    Like the selected item in the image below. The wall correctly blocks the light, but the selected item is still visible.

    light.png
     
  30. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    If your using Unity Pro then go ahead and send me an email and I will give you a copy of the ProShader which I am working on right now.

    reveriejake87@gmail.com
     
  31. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    My only concern is performance, so if there's a negligible performance difference then whatever's easiest for you! I don't mind having the extra comparison.
     
  32. fiote

    fiote

    Joined:
    Jan 8, 2015
    Posts:
    7
    Was this a reply to me? The only way to do what I want is using unity Pro? =\
     
  33. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Hi,
    The developer has tried to get a decent solution on Unity free, but its pretty much impossible right now because of the limitations. If you have Pro, you will be able to do much more advanced things. If you read through this thread you will see talks on what Pro/Free can achieve.
     
  34. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Thanks mimminito! The misunderstanding is really my fault though. I should make it absolutely clear on the product page what is possible with the free version of Unity so there is no misunderstanding. I will most likely be updating that product page tonight.

    For future reference, the current plan for Unity basic is to use a depth shader to cut away at an overlay plane. This effect should allow you to hide items that are unlit but you will be limited to hard edges on your lights.

    On a side note, the older version of 2DVLS did not support Unity's sprite system as it was pre Unity 4.2. The method used in those shaders worked but it was very hacky and limited you in a lot of ways. There have been attempts at solving the issue but so far no luck. It is pretty much impossible to achieve the look you would get with Unity Pro using Unity free.

    Jake
     
  35. fiote

    fiote

    Joined:
    Jan 8, 2015
    Posts:
    7
    @mimminito I kinda read about those limitations but since I'm REALLY new to all this 3d stuff I was a bit lost (my fault, don't worry, sorry lol).

    @reveriejake All good :) I just sent you an e-mail. Keep up the good work!
     
  36. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Any progress updates? Still super psyched to get lights in, but am waiting for 4.0 before setting up anything. :D
     
  37. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Okay some good news for some and some bad news for others. This beast is taking up WAY to much time for the amount of return I get on it these days so I have decided to make the old version FREE (once approved by the asset store) and the future versions available to all through the GNU license. I will still continue to work on finishing up the 4.0 update but I could definitely use some help from those who are interested. Not only will it benefit the project but it will benefit the entire community who are interested in seeing a professional grade 2D lighting system in Unity!

    Visit the project here at GitHub!

    Hope to see you guys there,
    - Jake

    EDIT: I also wanted to say a BIG THANK YOU to those who have helped push me in the right direction and who stood beside me even during long delays. It shows that most of you understand how hard it can be to try and balance something I am passionate about (like programming) with the mundane day-to-day job and having fun in life. So again, thank you so much for your support!
     
    Last edited: Jan 20, 2015
    mimminito and PTrefall like this.
  38. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    I understand the decision; but it does bum me out a bit as I'm not knowledgeable enough to contribute much to the code and I really wanted to implement soon. How far along was the current build uploaded?
     
  39. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I don't get it right now. Is the plugin now for free/open source?
    Will there be another plugin?
     
  40. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @Kirbychwan - Don't worry, the idea isn't for me to give up on the plugin. The idea is to invite people to help out and make it better with me and I hope that that is going to be the case. I still plan to head the project and push out my own code, documentation, and demo material.

    @BTStone - More details about the license will be coming out soon. Right now I have it under the GNU license but that might not be the right one. I want it to be open for anyone to use without having to pay but I also want to prevent others from selling it in their own packages on the Asset Store. So one thing should be clear, you cannot use the source code in your own asset store products nor can you sell the source code. If you use the code in a project for something like a game-jam where you give out the source, you provide a link it to its GitHub page.

    Jake
     
  41. vasyatko

    vasyatko

    Joined:
    Jan 21, 2015
    Posts:
    4

    Hi! Is it possible to achieve such an effect without complicated tricks?
     
  42. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    That looks 3D, not 2D?
     
  43. vasyatko

    vasyatko

    Joined:
    Jan 21, 2015
    Posts:
    4
  44. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    I'm going to assume that Lume was lit in 3D space, not 2D.
     
  45. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Ah okay, that's good. What does this mean for the ETA for 4.0 though? I originally scoped for having 4.0 at the beginning of January. Is the current build okay to start using? It was looking pretty good the last time I saw it, minus some missing light types/static lights/3D Mesh collider stuff. (I guess I should probably wait for Directional light instead of lighting up outdoor scenes with a ton of radials though.)

    Edit: I checked out the current build, for the obstructor I saw the 3D/2D collider stuff; but attempting to use it on my mesh collider tilemaps resulted in a bunch of errors sadly. The basic functionality/shader works though! Performance took a fairly big dip with just three lights (two static) though.

    Also currently in the project, creating a light brings up a big pink mesh because the materials haven't been assigned an appropriate shader, I think.
     
    Last edited: Jan 23, 2015
  46. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @Kirbychwan - Performance is bad? What exactly do your obstructors look like?

    There are bugs with the ProShader stuff and there is no support for the Mesh Collider type. I dont think that I will be able to add that either since the colliders generated for the 2D tile maps seem overly complex. The best method for that would be to just attach an obstructor to your object and add points to it yourself.

    Also a rule for using obstructors is that its best to use a bunch of little obstructors with only 10 edges than it would be to use one large obstructor with 1000 edges. This is especially true if the object your obstructing with hangs outside of the culling rectangle (light red rectangle gizmo).

    Once I get some documentation in there it will be a bit more clear as to how you should use VLS2D 4.0 but there should defiantly not be much of a performance hit with just 3 lights! (might even be some bug or other issue...)

    Jake
     
  47. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @vasyatko - I definitely agree that this is 3D not 2D. I think you would be better off looking into Unity's built in lighting rather than 2D stuff. And no support for Z-Axis in VLS2D. It assumes your on a flat XY plane and cannot see depth in Z-Axis (other than scrolling effects using the non-orthographic view of course).
     
  48. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    @reveriejake Fair enough! Using the obstructors will be more work to deal with (especially with huge scenes), but if they have better performance I'm okay with them. Although in this case I had a single obstructor with I think around only 8 points, with around a 300-400 FPS drop, I think. I'll skype you some details later tonight or this weekend.
     
  49. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    @Kirbychwan - Interesting. I have never seen that kind of performance hit in my testing with just 8 points. I am wondering if I introduced a bug into the viewer object. Its a bit shady right now how it works (its magical lol) so there might be an issue there where its not deleting obstructors causing it to have more than it should? I dont know... But that's definitely not right.

    Edit: @Kirbychwan The only thing that does is iterates through the list of points (8 of them), checks to see if the edges of those points are facing the light (QuickDot not precision Dot product), and then does a line overlap check on the casted line from the center of the light to the edge's starting point. It does also consider the light itself as a non-obstructing obstructor (sort of). So how many edges does your light have in itself?

    I might actually look into going back to Unity's built-in raycasting and just trying to bull-doze through the points and see if it increases performance. The algorithm I used for my line-vs-line function is a well known one and is supposedly highly optimized so I dont know lol. I will have to think about this one :)
     
    Last edited: Jan 24, 2015
  50. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    @reveriejake Actually upon second look and fiddling around with the profiler, it's a much more modest drop, around 70FPS with 3 lights with an extra layer pass (to get everything else to appear extremely dark except the lit areas.) I will do some additional testing today.