Search Unity

2D Mesh Based Volumetric Lights

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

  1. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @reveriejake Attempting to test stuff by prepping a debug room but workflow wise: 10 points as a recommended per obstructor is pretty low; even a fairly simple room of debug tilemapping has at least 25~ unless I want to have 5 obstructors per tilemap chunk, and some tilemaps depending on the scene can have up to 20 chunks! It begins to get a little unmanageable without the mesh collider option, as every time I want to do a minor change to the level I'd need to find and edit the obstructor as well.

    Maybe a small tool for refreshing the obstructor's shape and points to somewhat match the colliders of the mesh object that they're connected to would be a good idea, so each point doesn't need to be painstakingly placed by hand. Further down the road, that is.

    I seem to remember tests with 3.0 working okay with mesh colliders; was the performance simply too low/incompatible with the new culling?

    (I do like the normals showing up on the obstructor lines)

    I'll toss you a video on skype of how I'm applying all the effects. It's looking pretty sweet. :D
     
    Last edited: Jan 25, 2015
  2. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    well in 3.x I was just using Unity's raycasting. In this version I was attempting to just test line intersections at every vertex point to save on calls and on top of that I wanted to cache the points when the mesh's were not being moved so I didn't have to constantly convert points from one space to another. So in theory the VLSObstructor class was supposed to solve those problems.

    But after coding to practical use, it seems like I still have to convert between local and world spaces, write my own culling system, iterate through shapes multiple times, and do more expensive line-vs-line checks than originally intended (extras to try and solve unique but common cases). And because of using that custom class, it become a bit more difficult to solve where the edge of your mesh collider is to pin out the shape. If you have a lightweight algorithm for finding the edge of a shape from a list of vertices I can look at though I would be happy to see it.

    So the solution might just be to nix the entire idea of Obstructors and go back to the simpler method of finding the collider's vertices in real-time and converting them to local space.

    Hopefully the ProShader is working okay for you. There were some bugs with the editor that I have still not solved.
    Jake
     
    Kirbychwan likes this.
  3. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Oh and a quick FYI. I am looking to move back to my home-town (cheaper) and start coding freelance again. So my hope is to be able to spend a lot more time on this stuff. The work on VLS2D 4.0 that came at the end of December was due to me being able to focus on code full-time instead of the 4-8 hours a week I can currently give. So yeah I hope that happens sometime in March or April.

    Jake
     
  4. GilbertoBitt

    GilbertoBitt

    Joined:
    May 27, 2013
    Posts:
    77
    @reveriejake i'm working with ferr2D on my game i downloaded your light system but working amazing well with shader_buped defuse but not working with the shaders of light effect of Ferr2D can u help me or explain me why?
     
  5. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @GilbertoBitt I am not sure I would have to get a copy of Ferr2D and look into it.

    Jake
     
    GilbertoBitt likes this.
  6. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,117
    +1 for Ferr2D Support :D
     
    GilbertoBitt likes this.
  7. vividhelix

    vividhelix

    Joined:
    Mar 20, 2013
    Posts:
    78
    First of all, great asset!

    I'm running into an issue where having radial lights in a scene keeps it marked as dirty (saving does not remove the *). Once I remove the lights, saving works fine. I was using an older version I bought a few months ago, but this is happening with the latest version from the asset store as well (3.1.3). Any ideas?
     
  8. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @reveriejake

    Sounds good. Not sure if I know of any good algorithms for it aside from what google can find for me. Was culling not possible/efficient through Unity's raycasting?

    The Proshader itself is working well and looks super good in the test scenes I've set up. Is the directional script in the project functioning? Couldn't seem to get it to work.
     
  9. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @vividhelix - Yeah this issue is already known but it shouldn't have issues during run-time. Sorry for the annoyance. Also I got the bug report you sent with the other issues you have run into.

    @Kirbychwan - Culling is possible in Unity's raycasting and it is probably better than what I have setup (not sure). That is why I was saying it might be better for me to just drop the obstructor idea and go back to the 'bulldozer' method. And no the directional light has unfortunately not been finished yet :(.
     
  10. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @reveriejake

    Haha, okay, I'll stop fiddling around with the Directional then. :D I think the obstructor was a good idea in theory, but yeah it seems like there were a bunch of unexpected roadblocks. If it meant that I could easily use the mesh colliders without lots of additional authoring, I'd be in favor of it, though.

    However! Would it be possible to make it so only specified colliders/game objects can obstruct light in the Bulldozer method? The one thing I like about the current one is that the light only collides with things I specify (i.e Obstructors). This way I could make only my level geometry affected by lights, but the collider on my characters won't cast shadows/block lights, etc.
     
  11. Codeninja_Kjetil

    Codeninja_Kjetil

    Joined:
    Jan 28, 2015
    Posts:
    3
    @reveriejake

    Hi
    I was wondering if it's possible to have the VLS2D-light light up the background (and other sprites that isn't covered by an Obstructor) in my otherwise pitch black scene in stead of only being a single color? I'm using the version from GitHub (which I assume is a 4.x version). Is this possible to do with only Unity Free?
     
  12. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @Codeninja_Kjetil

    Like this? http://i.imgur.com/pEMZ0Oq.jpg

    Totally doable, but I have Pro; so not sure how well it would work/if it's possible via Free.
     
  13. Codeninja_Kjetil

    Codeninja_Kjetil

    Joined:
    Jan 28, 2015
    Posts:
    3
    @Kirbychwan

    Yes, something like that (I'm making a platformer game prototype (for my Master thesis) where the playable character uses a flashlight to navigate in the otherwise pitchblack room)

    How did you do it? So that I can see if I can replicate it in Free (it doesn't have to look fantastic since the game is only a prototype/I'm only testing a concept)
     
    Last edited: Jan 29, 2015
  14. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    754
    One way you could do it in Unity free is using two cameras and putting a depth mask shader on the mesh created by 2dVL. You wouldn't get the soft edges like in the screenshot you showed but I think it could work well. Have one camera that renders first that renders only the layer that your light mesh is on and draws black in the background. Then have a second camera that renders everything else (excluding the depth mask layer) and sets it's render depth below that of the first camera. This way for the area that the light mesh covers, it will "cut through" the black rendered by the first camera and show what's rendered for the second camera.

    You would also need to render your ui on a separate camera that displayed above all that.
     
  15. Codeninja_Kjetil

    Codeninja_Kjetil

    Joined:
    Jan 28, 2015
    Posts:
    3
    I have tried this now, but I can't seem to get it to work, I only get white color where the VLS2D-light is (in stead of a "hole" in the black).
    I'm currently using the DepthMask-Shader that comes with VLS2D on the light.
     
  16. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @Codeninja_Kjetil I don't think two cameras are necessary for this effect (for Pro, at least): I believe what I did is set up an additional light layer pass (?) on the camera that essentially placed the dark ambient light layer in front of everything else. When I get home from work tonight I'll check some of my settings and try to figure out what I did.
     
  17. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Hey guys. I was working on the depth shader and script for VLS2D before I posted it to GitHub but I never got around to completing it. Once I get back into coding 2DVLS I will attack that issue. But for now you might have to get creative when using Unity Free.

    Its been another busy month for me so please continue to hang in there. I was hoping that there would be a bit more of a community effort to help get this working properly but so far nobody has committed any changes ;). Oh well that's how it goes I guess lol.

    @Kirbychwan - Some people might not be able to see the "Light Layer Pass" section of the editor. That seems to be a bug that some have been having. It seems to work perfectly fine on my end so I am having a hard time tracking that issue down.

    Jake
     
  18. Greenwar

    Greenwar

    Joined:
    Oct 11, 2014
    Posts:
    44
    I will name my unborn child after whoever creates a tutorial on how to set up and use the github version. Might sound douchey, but I really don't have time learning it all by myself right now without some kind of manual or documentation. :/

    An example scene would do as well, I guess - pro shaders and all. Something to dissect would be awesome.
     
  19. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Im going to package up the current GitHub code into a Unity package today and provide a link to it in the readme file. That way those of you who dont want to use or are not sure how to use GitHub can get it into your project.

    If I have time before work I will also try and get at least a text tutorial up on how to setup Unity Pro scenes.

    Hope that will help!

    Jake
     
  20. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @reveriejake Might be the light vs dark GUI issue again?

    I'd totally commit some stuff if I had any skill in doing so! Haha.
    Have you reached a decision on whether to return to Unity's bulldoze approach?
     
  21. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @Kirbychwan - Yeah I was thinking so too but that doesn't seem to be the case. The dark/light skin issue I had before was because I was rendering a 'box' after all of the other gui elements which for some reason covered up the elements in the light skin but not the dark. This issue seems to be related to the property drawer class but I would think that if that were the case it would be happening on everyone's editor. That doesn't seem to be happening.

    I am pretty new at GitHub myself but so far it seems fairly simple. There are really only a few commands that are important when using the command line.

    I would like to try what I was calling the 'bulldoze' method ;). The only problem with that is that when 2 colliders are overlapping I still need to find that point where they overlap so I can cast a ray at that point as well. That's another issue the Obstructor class was solving for me.
     
  22. eddie312

    eddie312

    Joined:
    Sep 13, 2012
    Posts:
    24
    yes that will help a lot.
    I' m getting hard time to get the depth mask and effect that I want.
    i think it will be nice if people can contribute also in the wiki with tutorial or sample(i'll do it).
     
  23. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @eddie312 - Yeah I was also having a hard time getting the depth mask trick to work when I was trying to code it but I am sure it will come together if I am able to spend a bit more time on it.

    Working on the unitypackage right now... Just commited a few changes to Git including a sample folder with the start of a sample scene for Unity Pro users.

    Jake
     
  24. eddie312

    eddie312

    Joined:
    Sep 13, 2012
    Posts:
    24
    @reveriejake thanks a lot i just try the last git. working with no problems the demo scene works on unity pro (i ll try on free later) i manager to make test in 5 minute.

    i think it will be easy to reproduce stuff like that to
     
  25. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Good to hear!
     
  26. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Just a quick reminder to those who might be new to VLS2D... You can now find the code on my GitHub page for free at the link below!

    VSL2D on GitHub
     
  27. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @reveriejake Oh, version control and github stuff isn't a problem; rather my skill in scripting in general.

    Yeah, that collision issue is an interesting problem to solve (in a way that doesn't kill performance, anyway).
     
  28. eddie312

    eddie312

    Joined:
    Sep 13, 2012
    Posts:
    24
    @reveriejake it will be interesting to put a list of task (google doc or github issue) that you want to be done so we also can help if we can.
     
  29. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    112
    New user here. If I'm not mistaken, I think I may have run across the issue with Light Layer Pass in the editor that is mentioned a few posts up in 4.0. In VLSPro Shader, I can only see "Nothing", "Everything", and "Layer 1" in my game's main scene, which has around 30-something layers (assuming this is the bug referred to?). Is there some sort of quick modification I can do to the code to work around this?

    Edit: I might not have been clear: It's the "Light Layers" list under "Apply VLSLight" that I'm having trouble with. On a side note, I don't see anything under "Extra Layer Passes", but I guess that's a separate issue.

    Edit 2: A second question - I've also been attempting to use 3.x with Unity Pro. The only link I could find for Pro Shaders was from the description in this video. Is the video/package up-to-date for 3.x? I was having some difficulty getting it to work properly.
     
    Last edited: Feb 5, 2015
  30. DreamAlp

    DreamAlp

    Joined:
    Dec 4, 2013
    Posts:
    7
    Those those asking about Ferr2D we used it in our game Light in the Dark with great success. We started with an older version of 2DVLS but had no problems with them at all.

     
    eddie312 likes this.
  31. ShinKazuo

    ShinKazuo

    Joined:
    Oct 28, 2014
    Posts:
    12
    Hey guys, right now I can hide part of a player in the shadows by using cutout shader and putting the sprite in a material and then on the player, but that blocks me from having him being animated because it's not a sprite renderer.

    I believe there is no way to it on the version 3.5 (the one I purchased a few months ago). What about 4.x, how to do that, if that's even possible?

    I do need to have light with no blurring, etc. Anything in the cone of light is shown and anything out of it is completely hidden, like one on the image bellow (but hopefully soon to have animations!)

    Cheers!

     
  32. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    Biggest blockers for me personally are not being able to set up my scenes until the collider/obstructor decision is made, and the directional/area light is not available yet. But I believe Jake is working on those?
     
  33. ShinKazuo

    ShinKazuo

    Joined:
    Oct 28, 2014
    Posts:
    12
    Apparently I can do what I was asking with the GitHub version of the VLS2D!

    The one question I have is, what is all those changes the plugin wants to do on the project settings when I try to open one of the sample scenes? I want to replace the old VLS2D with the GitHub one but I'm afraid of just accepting those new settings because I have no idea what they are and how they would impact the game I already have!

    Any ideas?
     
  34. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    Wow lots of comments and no emails to me about them lol..

    @ShinKazuo - Sample scene requires you to have layers setup... I would LOVE a better way of setting up layers as to not interrupt others scene settings... Any suggestions?
     
  35. vividhelix

    vividhelix

    Joined:
    Mar 20, 2013
    Posts:
    78
    Interestingly, I switched to Unity 5 beta and the scene is no longer marked as dirty! Yay!
     
  36. ShinKazuo

    ShinKazuo

    Joined:
    Oct 28, 2014
    Posts:
    12
    Not sure, I would probably just use the Unity default ones. I never delete nor use them anyway hahaha...

    On the other hand. Trying so hard to switch to the new 2d Lights 4.0. Everything now needs an obstructor and changing that (and any reference in script I had regarding the lightRadius) is taking a looooooong time. :(
     
    Last edited: Feb 8, 2015
  37. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    Yeah, that was my biggest issue as well. Jake has mentioned that he may be returning to the old method, which will be nice since you don't have to place dozens of obstructors in a single scene and instead just utilize the mesh/box/sphere colliders you're already using. It may be better to wait so you don't waste time redoing everything.

    @reveriejake
    I'm confused, does the new package automatically add new layers to your project or something? I remember setting up the layers manually, and that worked well enough. As long as I can choose my own layers for VLS and they don't make any changes to my currently existing stuff, I'm good.
     
  38. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    815
    @Kirbychwan - Just the sample scenes do. It is not required to use the package itself.

    Jake
     
  39. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    Ah, okay. Makes sense.
     
  40. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    112
    I think my question may have gotten lost in the mix, but I'm still having difficulties getting VLS 4.x to work properly in new scenes outside of the Sandbox_PRO scene. Here's the process I just tried, starting with a brand new scene:
    • Add the VLSPro Shader component to my camera
    • Set Ambient Color to a grayish tint
    • Create a VLS2D layer
    • Set my camera’s Culling Mask to not include the VLS2D layer
    • Ensure the camera's lighting is set to Deferred or Forward
    • Create a new VLSRadial Light
    • Set the light to the VLS2D layer
    • Add a background sprite
    Maybe I'm missing a step or two here? I'm not seeing the light appear as it does in the Sandbox_PRO scene. I can't for the life of me figure out what that scene has that I'm missing :p
     
  41. mikkifr

    mikkifr

    Joined:
    Oct 28, 2013
    Posts:
    3
    I'm getting the following error from the Unity console when in Android emulation mode:

    Tiled GPU perf. warning: RenderTexture color surface (200x120) was not cleared/discarded, doing <run with profiler for info>

    I'm seeing this both in the my own scene and in the sandbox scene. It doesn't effect the performance/rendering of VLS2D on my desktop, but on mobile the graphics get jacked up real bad. Any ideas on how I can fix?

    Thanks for the script, loving it!
     
  42. mikkifr

    mikkifr

    Joined:
    Oct 28, 2013
    Posts:
    3
    @Doghelmer

    In my setup, the VLS2D lights were on a blank layer (no name) by default. When assigning them to a named layer in the sandbox project; or letting unity assign them to the "default" layer when adding a new one to the scene, they stopped rendering.

    For me, it turned out the initial VLS2D component was missing the drawers with layer/light mask options. I switched into debug mode and manually added some entries to the VLS2D properties, and when I switched back, they showed up properly.

    I've attached what the property drawers should look like. Prior to me messing around with settings in debug mode, the "Light Layers" properties and "Create Layer" button didn't show. Light layers contain light layer masks, and without the light layer masks properly setup, it seems VLS2D was only rendering to game objects on blank layers (which you can't manually assign them to).


    Windows 8.1 + Unity 4.6.2f1
     

    Attached Files:

  43. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    Huh, good catch. I wonder why I wasn't having that issue.
     
  44. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    112
    Very odd.. Thanks a bunch for the explanation, that was really causing my to bang my head against the wall.
     
  45. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    Hey guys, I thought I'd share my game Sneaky Ninja, a 2D stealth platformer which uses 2DVLS for enemy vision (which unfortunately means you can't actually see it!). We also had been using it for shadows but had to disable it for a bit for performance reasons (not 2DVLS's fault, we're just unoptimized in general :p). Once we get Unity Pro we'll hopefully be able to optimize enough to get it back in there!

    It's also now on Kickstarter!

     
  46. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @SullyTheStrange
    Looking good! That slow-mo example in particular is very cool. The KS goal seems quite low though, are you aiming to use KS primarily as a means of tackling the licensing fees? (And the obvious promotional value of course.)

    I ask mostly out of curiousity, I'm looking at WiiU licensing as well.

    @reveriejake
    Also, any progress updates regarding the obstruction methods?
     
    Last edited: Feb 17, 2015
  47. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    876
    look interessing
     
  48. SullyTheStrange

    SullyTheStrange

    Joined:
    May 17, 2013
    Posts:
    147
    Thanks! Yeah, we have a costs chart towards the bottom breaking it down, it's mostly software licenses and hardware. (And the promotional value doesn't hurt! ;))

    I'm not allowed to say how much the Wii U dev kit costs, but it's not super expensive (not super cheap either though). You're thinking of licensing the game in your sig? Looks awesome, you'd definitely be approved if you apply to be a developer! Which, if you haven't, it wouldn't hurt to do now since it can take a few months for them to get back to you.
     
  49. eddie312

    eddie312

    Joined:
    Sep 13, 2012
    Posts:
    24
    is the new asset is working on IOS for you? i just tester and everything is black
     
  50. Souk21

    Souk21

    Joined:
    Dec 28, 2014
    Posts:
    14
    Hi! Thanks a lot for your great asset! Works perfectly!
    Is there any way to "smooth" shadow edges without Unity Pro ?
     
unityunity