Search Unity

[NOW FREE] Light2D - GPU Lighting System.

Discussion in 'Assets and Asset Store' started by SSS135, Mar 14, 2015.

  1. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Right now there is no way to exclude other cameras from lighting. But I think I will implement something like that in next release.
     
    Burletech, kuchaku and DrKucho like this.
  2. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i really hope you do, it has many applications,
     
  3. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Seconding the camera exclusion request! Sometimes lighter-colored sprites just get blown way out by the lights and you can't see anything, it's so bright.

    As a whole though, Light2D is working lovely. :)
     
    DrKucho likes this.
  4. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i can't see te difference between point light and line light , i use the Fountain Example and switch the line light to point light and the result is the same ... ?:confused:
     
  5. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    That may not be visible on such a narrow light. If you make it much wider and place some light obstacles in it, you will certainly see the difference.
     
    DrKucho likes this.
  6. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    another question , i have an offscreen light , it doesn't show properly when i get too far away of it but its ray lights still reach the screen , i guess i have to add the lighting texture size but i am confused with the properties, they documentation is not exact, it does not talk about LightTextureHeight , i see this value increases when i increase LightCameraSizeAdd, but i would like to know exactly what does each property.

    also , seems that these values are only adjustable before start? cause i tweak them during run time and i don't see any change ... ?
     
  7. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    LightCameraSizeAdd was made for solving your problem. To fix offscreen light issue set it to radius of largest light. In current asset version that could cause significant performance overhead, but it's fixed in my development version which will be available within 1-2 weeks.
    All LightSystem configuration values should not be changed after start.
     
    DrKucho likes this.
  8. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Is there a good method to reduce the additiveness of different lights? One of my largest problems right now is that instead of blending, two bright lights will become INTENSELY, way too bright when coming close to each other. If we could cap the brightness at a specific point, somehow...
     
    Last edited: May 20, 2015
  9. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i have to deal with the same issue, something that could work for you is to create a new light sprite which has a constant medium lightness from the center to half distance and then it fades , the default light coming with the package are maybe too bright at the center... now that i just reminded ... im not not in my coding computer right now but i think that the package comes with different lights that gradually keep the brightness more constant as long as it get closer to the edge ... one of those should work, if not edit the sprite in photoshop
     
  10. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    thanks for the answer but still not totally clear about this , two questions
    1.- i understand LightCameraSizeAdd but what is LightTextureHeight then?
    2.- what are the units of LightCameraSizeAdd? pixels , unity units? you said it should be set as big as my biggest light radius, but how to measure this? each light sprite has a own pixel size and then i modify the scale ...

    thanks in advance and looking forward to your updated version , very good job on this plugin!
     
  11. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    To turn off bloom replace existing shader with that one and set Bloom Pow in LightOverlay material to 0.

    LightTextureHeight affects only quality of lighting and measured in pixels. LightCameraSizeAdd controls how much biggeer light camera will be than game camera and measured in unity meters.
     
    DrKucho likes this.
  12. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    hi , is there any way to read the amount of light of a specific point on the screen? this would be useful to allow your hero to hide in shadows from enemies, if light is less than a value, enemies won't detect you :)
     
  13. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    im getting all these errors when i try to build an standalone , please note that im using Unity 4, OSX and i code in javascript so i had to move light2D to Plugins folder

    Loading /Applications/Unity/Unity.app/Contents/PlaybackEngines/BlackBerryPlayer/UnityEditor.BB10.Extensions.dll into Unity Child Domain
    Assets/Plugins/Light2D/Editor/LightingSystemCreationWindow.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Editor/LightingSystemEditor.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/EditorCameraWindow.cs(2,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/HingeAutoRotatorEditor.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/HingeJointUtil.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/LandingLegEditor.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/Point2Drawer.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/ReadOnlyDrawer.cs(1,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/ScriptableObjectCreatorWindow.cs(6,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Editor/LightingSystemCreationWindow.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Editor/LightingSystemEditor.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/EditorCameraWindow.cs(2,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/HingeAutoRotatorEditor.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/HingeJointUtil.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/LandingLegEditor.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/Point2Drawer.cs(4,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/ReadOnlyDrawer.cs(1,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
    Assets/Plugins/Light2D/Examples/Editor/ScriptableObjectCreatorWindow.cs(6,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?
     
  14. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Try to move all Light2D editor scripts to Assets/Plugins/Editor.
     
    DrKucho likes this.
  15. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    it works thank you, please don't forget this other question :

    "is there any way to read the amount of light of a specific point on the screen? this would be useful to allow your hero to hide in shadows from enemies, if light is less than a value, enemies won't detect you"
     
  16. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Not yet, but I plan to implement it within 2 months.
     
    DrKucho likes this.
  17. bubuchenko

    bubuchenko

    Joined:
    Nov 24, 2014
    Posts:
    1
    Hello, do you accept refunds? I'm amazingly impressed by your light system and I read most of these forum posts before buying it, I knew there were risks of it not fitting into my RTS style game with a perspective camera. But reading all the overwhelmingly positive comments I had to bite. I messed around with it for a good two days now, it's really nice to work with. But sadly does not fit into the game the way I wanted it to and now I won't be incorporating it into my game, and an unused $50 plugin does burn a hole into your wallet.

    Anyway, great job with this asset. I'm sure it can and has helped out other games fantastically. :)
     
  18. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Hi, send me your invoice number if you want a refund.
     
  19. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Not sure if this has been asked before, but: is there a way, or any plans to add multiple light obstacle layers?

    Btw, amazing asset :)
     
  20. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Hi, I will think about it, but anyway it won't be soon.
     
  21. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    not sure if this is the place for it but as a feature request - the ability to change global shadow opacity or set a global ambient light level. The shadows are too dark. Adding light obstacles generates a needless amount of objects.
     
  22. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Try to change background color of LightCamera or tweak LightOverlay, LightxxxPoints material. Hope it helps.
     
  23. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I have tried changing the color of the lighting camera, but this seems to have no effect. I did notice that the lighting camera is disabled by default. Changes to The Ambient Light Computer and Light Overlay also don't seem to affect this.
     
  24. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    I gave this a go, but I actually want the bloom to remain, I don't think it's the problem:

    Is there a good way for simply removing shadow WITHOUT contributing to bloom levels? We need a way to have a nice neutral light unaffected by other lights, otherwise, we have no way of simply having an outdoor daytime scene without bloom going crazy.

    For example, a lit torch during the daytime outside results in an overwhelming amount of bloom, because it's mixing the strong ambient daylight with the torch light source. Ideally, we need an additional 'daylight' shader that removes shadow but does not contribute to the additiveness of other light sources. (or something to similar effect)
     
    Last edited: May 29, 2015
  25. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    I'll try to fix camera backround color.

    I have not created daytime scenes, but I'll try and see what could be done. If you can't wait you could duplicate one of the LightxxxPoints shaders and change blend mode to something like "SrcAlpha OneMinusSrcAlpha".
     
  26. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Thanks for looking into it!
     
  27. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    one of the reasons i requested to be able to read the amount of light of a specific point of the screen is to avid what you said about the torchlight + daylight, if you can read how much light there is on the hero area , you can reduce the torch light intensity when he is outside and increase it when he gets into a dark area
     
  28. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Yeah, something like that may help. I'd prefer a built-in solution so I don't have to muddle my way through with my terrible scripting skills, though...
     
  29. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Version 1.3 released. Here is a changelog:

    Normal mapping.
    Ability to turn off bloom. Set BloomPow to 0 in LightOverlay material.
    Ability to select point texture filtering mode for pixelated lights. See LightingSystem.LightTexturesFilterMode.
    Fixed lighting when changing orthographic size of game camera.
    Fixed light camera background color not affecting anything.
    Fixed bugs with camera rotation around Z axis.
     
  30. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    What is that about light camera background color hat has been fixed? Could you please explain this?
     
  31. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Background color in "Light Camera" controls minimal light level.
     
  32. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I just installed this latest version, and without changing anything, my frame rate has dropped significantly from the previous version-- enough that I've had to revert to 1.2.1. Do you have any idea what might have caused this drop, or if there is some new setting that has been added that I might need to change?
     
  33. Kastrye

    Kastrye

    Joined:
    Jun 4, 2015
    Posts:
    3
    Massive fan of the lighting system, works amazingly well. But, I have come across a massive problem for the game I am currently creating and that is you don't support X Z perspective. This would not normally be a issue but A* Pathfinding is to my surprise but not willing to support the X Y perspective. forcing me to either ditch the AI or the very fancy lighting. As you can guess I would like to keep both, So I was wondering is there anyway to get the lighting system to work in a X Z perspective. perhaps by replacing Y with Z? and if so would I be able to do it without a great deal of coding experience?

    Hopefully that all did not sound too insane, I'm typing this all out fairly late at night after a long day of bashing my head against a wall.

    - MrGrandOp
     
  34. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    Maybe "Normal mapping" checkbox in LightingSystem got checked somehow. Could you please see it and uncheck if it was checked.

    ZX plane with orthographic camera have been working some versions ago. I will check it and try to fix it if something got broken.
     
  35. Kastrye

    Kastrye

    Joined:
    Jun 4, 2015
    Posts:
    3
    That's relief to hear, was starting to think Z X was not going to be getting any support.

    Just to be a little bit more help on the matter, I have token two screenshots of my test scene, both images are of the same spot, only difference is the light position. The light sources are displayed via the white dot and the camera is looking downwards to mimic a topdown game.

    As you can see the left image is working fine, the light is currently on x0y0z0. where as the image to the right, the light source has been moved via its Z to x0y0z-4, right in front of the block blocking the light. as you can see, the shadow gos right over the light. This would even happen if I move the light to x0y0z4 what would be in front of a block on the opposite side of the image.

    This bug dose not happen though If I move the light via its X, no matter what as long I keep the Z to 0.
    Lighting Working.png Light Not Working.png

    Hopefully that's enough information, if you need to know anything feel free to ask me.
     
  36. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    It looks like the Normal Mapping box was unchecked-- so unfortunately that wasn't the problem. I tried messing around with the new settings in LightingSystem, but I wasn't able to increase my frame rate.
     
  37. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Can anyone else test the background color for the lighting camera affecting shadows?

    I still seem to be getting the same results as the previous versions - the color still does not seem to affect anything.

    EDIT: Nevermind, replacing the lighting system did the trick!
     
    DrKucho likes this.
  38. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Had trouble building for mobile until I added this to LightingSystem.cs
    Code (csharp):
    1.  
    2. #if UNITY_EDITOR
    3. using UnityEditor;
    4. #endif
    5.  
    Also getting an avg of 48 FPS on an HTC M7 :)
     
    Last edited: Jun 5, 2015
    DrKucho likes this.
  39. abatcat

    abatcat

    Joined:
    Feb 8, 2015
    Posts:
    70
    Can you post an example of what the normal maps look like with your system?
     
  40. kuchaku

    kuchaku

    Joined:
    Oct 14, 2014
    Posts:
    37
    Hi. I'm very interested in your lighting system as I'm developing a Terraria style game and it appears like a potential solution, but being able to exclude a layer is extremely important for conveying the scene properly (E.G. your torch shouldn't light the sky or mountains behind you). Are you still intending to implement this feature?

    I do have another question as well: is any flexibility included in this system for 'light penetration' amounts of the obstacles? In sandbox platformers, lights are allowed to pass through a certain amount of wall tiles so you can see some of what can be dug out.

    Final question, how much performance does each light take proportionally? In a user made game, where players can place torches for example. I can't be in control of how many light sources the player creates.

    Regardless, This is definitely the prettiest system I've seen thus far, and my efforts of using the CPU have not been nearly as impressive. If I am making a game I'm confident would would be appropriate for it, I'd love to use something this beautiful. It even has penumbras. Really nice job.
     
    DrKucho likes this.
  41. SamTheBay

    SamTheBay

    Joined:
    Jan 11, 2014
    Posts:
    14
    Hey Guys. I am hitting an issue where the shadows are turning purple in the web player. Running on windows in the editor they look black like they are configured. Any ideas why the shadows would change color like this? Example screen shots are below. The first one you can see the rocks turn purple (web player) but the second they look black like they are supposed to (editor).

    purpleLight.png blackshadows.png
     
  42. SamTheBay

    SamTheBay

    Joined:
    Jan 11, 2014
    Posts:
    14
    I figured this out. It seems that somehow the material got removed from the Light Obstacle Generators. I set it back to DualColor material and now it looks correct. Thanks for the awesome asset!
     
  43. snarlynarwhal

    snarlynarwhal

    Joined:
    Jan 16, 2014
    Posts:
    30
    Has anyone tried this plugin with Destructible 2D?

    If not, think it would work?
     
  44. DJVDJV

    DJVDJV

    Joined:
    Sep 11, 2014
    Posts:
    70
    Just bought this asset. Is it possible to get work with 2dtk tilemaps? Like some tiles are obstacles and some not? If so how?

    Before I had 2d volymetric lights that was affected by colliders.
     
    Last edited: Jun 11, 2015
  45. abatcat

    abatcat

    Joined:
    Feb 8, 2015
    Posts:
    70
    Have you thought about adding something like layers? So that you would be able to handle objects located at different depth on a Z axis? I'm not really sure if its possible at all, but it would be great to be able to have some kind of a parallax effect in a 2d platformer game for example.
     
  46. Gelo_Man

    Gelo_Man

    Joined:
    Jun 6, 2015
    Posts:
    9
    Hey SSS135,

    I have a similar question to MrGrandOp - I'm trying to get the asset to work on the XZ plane (which is supported per your earlier post) but am having no luck. I recreated the sample scene in the youtube tutorial and got it to work fine in standard YX plane. I then took my background, light obstacles, and light and simply rotated them 90 degrees on the X axis (i.e. from a side view to a top-down view). When I do this none of the shadows work properly. Here's a screenshot of the standard YX view:



    Now, here is the exact same scene flipped onto the XZ plane (top-down view). As you can see, moving the light around the Z axis has no effect on the shadows which stay put.





    Am I just going about setting up a XZ scene in the wrong way or is there a parameter I need to change in the scripts?

    Thanks!
     
  47. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    1) I am not sure if layers will be implemented, but you will be able to exclude from lighting everything rendered in previous cameras.
    2) Yes, there is a light penetration. It depends on light obstacle color.
    3) It depends on shader, size, but generally each light is taking very small amount of performance if normal mapping is not used.

    You should create separate tile map for obstacles and set layer to light obstacles layer.

    It was supported some versions ago, but now seems to be broken. It is on high priority to fix.
     
    AntonioModer and kuchaku like this.
  48. Gelo_Man

    Gelo_Man

    Joined:
    Jun 6, 2015
    Posts:
    9
    Hey SSS135,

    Thanks for the quick reply :). Just for project planning purposes, how long until you expect the fixed version will be released?
     
  49. SSS135

    SSS135

    Joined:
    Nov 26, 2012
    Posts:
    65
    About 1-2 weeks.
     
  50. Kastrye

    Kastrye

    Joined:
    Jun 4, 2015
    Posts:
    3
    That's great to hear, I will be looking forward to the patch.