Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[NOW FREE] Light2D - GPU Lighting System.

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

  1. SoftwareGeezers

    SoftwareGeezers

    Joined:
    Jun 22, 2013
    Posts:
    902
    Doesn't work at all now. Just tried, get a shader error, and no shadows in the examples.
     
  2. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    51
    I get the version on Github and all examples are working.
    Tested with Unity 2017.1
     
  3. doomin85

    doomin85

    Joined:
    Oct 24, 2015
    Posts:
    1
    in unity 2017.1 i can't build game because i have error like „Shader error in 'Light2D/Light Auto Points': undeclared identifier 'PATH_TRACKING_SAMPLES' at Assets/Light2D/Resources/Shaders/LightBase.cginc(93) (on d3d11)”

    somebody know how fix it?

    in editor works fine, error is shown when i trying to build
     
  4. ViralArt

    ViralArt

    Joined:
    Apr 17, 2015
    Posts:
    11
    A little tip for people that have trouble with the point of origin light bleeding into the objects infront of the light.
    You can edit the light base shader to ignore the obstruct multiplier (which controls the amount of bleeding)
    Instead have black blockers with around 20% alpha this gives bleeding and light blocking.
    (Note) To much alpha and you have the same problem again.
    It can likely be done abit better and you loss abit of control. But it works

    Edit: I use that feature again and now use a 2nd cammera and some masking to get this effect
     
    Last edited: Oct 23, 2017
  5. ViralArt

    ViralArt

    Joined:
    Apr 17, 2015
    Posts:
    11
    Edit:
    Could not get the normal map to work, but it does work with the mesh combiner
     
    Last edited: Oct 24, 2017
  6. JAMiller

    JAMiller

    Joined:
    Apr 2, 2009
    Posts:
    78
    I was able to fix this by adding #define PATH_TRACKING_SAMPLES 90 near the top in LightBase.cginc.

    But this causes all lights to have a hard-coded number of path tracking samples, so I'll probably look into a better fix when I can.
     
  7. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Super broken as of 2017.2 it seems.

    Had to update a few scripts, but running into that shader issue above. Adding
    #define PATH_TRACKING_SAMPLES 90
    didn't seem to affect it; still a pink broken shader.

    Update:

    Each shader had a file path hardcoded into it... Since my Light2D is not in root, I had to go through and modify each one.
     
    Last edited: Feb 6, 2018
  8. Ergoboss

    Ergoboss

    Joined:
    Jul 13, 2016
    Posts:
    1
    I have a problem with the project build using version 2017.3.0f3

    when the scene starts, the light also does not work ((
    below attached screenshots
     

    Attached Files:

    Last edited: Feb 10, 2018
  9. vovx

    vovx

    Joined:
    Mar 26, 2018
    Posts:
    2
    Cant even create lighting system in Unity 2017.4.0f1.
    Seems like light2d isn't works anymore without fixes..
     
  10. ZubakIVAN

    ZubakIVAN

    Joined:
    Sep 21, 2015
    Posts:
    2
    On my new pc with Directx11 i got error
    "Shader error in 'LightAuto': undeclared identifier 'PATH_TRACKING_SAMPLES'"

    But on my old laptop DirextX10.1 i dont get error...
    what is going on? Maybe grapich card is issue?
     
  11. blanktarget

    blanktarget

    Joined:
    Aug 28, 2017
    Posts:
    20
    Example files working fine in 2018unity beta build. In my own project files though everything is dark and blurry.
     
  12. blanktarget

    blanktarget

    Joined:
    Aug 28, 2017
    Posts:
    20
    Update: It's working fine in editor now but I am getting a build error:
    Shader error in 'Light2D/Light Auto Points': 'PATH_TRACKING_SAMPLES' : undeclared identifier at Assets/Light2D/Resources/Shaders/LightBase.cginc(93) (on gles)

    Code (CSharp):
    1. Shader error in 'Light2D/Light Auto Points': 'PATH_TRACKING_SAMPLES' : undeclared identifier at Assets/Light2D/Resources/Shaders/LightBase.cginc(93) (on gles)
    2.  
    3. Compiling Vertex program with ORTHOGRAPHIC_CAMERA
    4. Platform defines: UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_ENABLE_REFLECTION_BUFFERS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_NO_CUBEMAP_ARRAY UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 SHADER_API_MOBILE UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING
    5.  
    I have no idea what this means.

    I did some digging and added the #define PATH_TRACKING_SAMPLES 90 to the top of my LightBase.cginc file, then hard coded the path in the light shaders I used since they were not in root. In my case the path was:
    Code (CSharp):
    1. Shader "Light2D/Resources/Shaders/Light 60 Points"
    instead of
    Code (CSharp):
    1. Shader "Light2D/Light 60 Points"
     
    Last edited: May 2, 2018
  13. SpaghettinoHieu

    SpaghettinoHieu

    Joined:
    May 3, 2018
    Posts:
    2
    The solution I just found is from here :https://answers.unity.com/questions/1426341/undeclared-identifier-free-2d-shader-on-the-asset.html
     
  14. blanktarget

    blanktarget

    Joined:
    Aug 28, 2017
    Posts:
    20
    Oh great! I will try that one out.
     
  15. blanktarget

    blanktarget

    Joined:
    Aug 28, 2017
    Posts:
    20
    That worked! It's building on android now.
     
  16. DanteAlighieri_

    DanteAlighieri_

    Joined:
    Jul 7, 2015
    Posts:
    1
    Unity2017.4
    Shadows in editor work perfectly, but in the build some of the cast shadows are reddish?
    There a way to fix this?
     
  17. theultimatepwn

    theultimatepwn

    Joined:
    Dec 14, 2012
    Posts:
    6
    Does anyone know how to go about implementing tilemap support? It works as far as the shadow casting but I cant seem to get it to render the tilemap like you can with regular sprites where it partially renders the sprite that is illuminated.
     
  18. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    106
    Hi all! I know its an old post but I was wondering if I could get any help

    I assigned the layer "Player" in the code so the main character would cast a shadow, I need the player with that tag as others elements are using it to locate the player,I'm even thinking about make everything cast a shadow (so I would add only exceptions in the code), the problem is that the shadow is covering the sprite itself, I have being trying for hours without any result

    this is what is happening:

    upload_2018-6-23_4-7-39.png

    I would like to have something similar to this:

    upload_2018-6-23_4-15-27.png

    do someone have any idea of how to make the shadow be behind the sprite? I saw someone saying to add a material instead of leave it in Sprites-default but the character have a lot of animations,so an static image is not an option
     
  19. OfficialAshez

    OfficialAshez

    Joined:
    Aug 28, 2017
    Posts:
    26

    My picture on the left.

    How can i make it more smooth like the right side?
     
  20. project2051

    project2051

    Joined:
    Jul 22, 2018
    Posts:
    7
    Hi, try to decrease "Light pixel size" in camera's light system script.
    ---------

    I do also have an problem with this lighting system. I have seen people discuss about disabling the lighting on background layers. Some people were able to fix this with camera tricks and render textures but I haven't been able to solve it. Version 1.4 of the tool (available in github, not in asset store) should also have this feature:

    https://github.com/SSS135/Light2D/blob/master/Assets/Light2D/changelog.txt
    Single camera mode. See "Affect Only This Camera" in LightingSystem. If checked lighting will affect only what is rendered in camera with LightingSystem script.


    I tried to enable this option in light system script and run the demo. It seems to render on a texture, but how do I make it visible on screen? And since the texture has the light rays rendered I do not understand why they would not be visible when this texture is rendered on top of the background.

    Does anyone have more knowledge about this feature?
     
  21. project2051

    project2051

    Joined:
    Jul 22, 2018
    Posts:
    7
    This question is already one month old, so maybe you have solved it, but I hope this helps someone with similar issue. If I understood correctly your problem is that you assigned layer Player as light obstacle layer. This means that player sprite is not rendered, but it is only used as a light obstacle. Create a new layer "LightObstacle" and use that as a light obstacle layer in the light system script. Then add Light Obstacle Generator for your player. This will automatically generate all the objects required by the lighting system to create shadows and it won't affect rendering of your character.
     
  22. project2051

    project2051

    Joined:
    Jul 22, 2018
    Posts:
    7
    I was able to solve this by modifying LightSystem.cs. I commented out everything in OnRenderObject function and added following lines at the end of the OnRenderImage function (right after every render function call):

    Code (CSharp):
    1.  
    2. if (Application.isPlaying && AffectOnlyThisCamera)
    3. {
    4.     _camera.targetTexture = null;
    5.     Graphics.Blit(_renderTargetTexture, null, _alphaBlendedMaterial);
    6. }
    7.  
    I use one camera to render background layers and another camera to render foreground layers that will be affected by the lighting. The foreground camera also has the LightingSystem script and parameter "Affect only this camera" set to true. Calling Graphics.Blit second parameter null will draw the renderTexture on camera. I'm happy with the solution since it was just luck and trying out different options as I do not have very good understanding of the rendering process.
     
  23. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
  24. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    here the light obstacle generator dosnt work, its dissapear on start and it ask for a mesh renderer... but i want to use sprite renderer so im confussed
     
  25. project2051

    project2051

    Joined:
    Jul 22, 2018
    Posts:
    7
    Light2D supports only one layer for light blocking obstacles, so what you can do is that you add a white textured sprite or mesh to players, vehicles etc. and add this texture to light blocking layer. Then you can change the opacity of the texture to allow objects entirely block, or partially pass some light through them.

    You don't have to use the light obstacle generator, but it should be compatible with both sprite and mesh. I don't use it either but I create and update light blocking obstacles with my own mesh deform code - this is however used for dynamic destructible environment. In your case you can just add some light blocking texture to the character prefab like I described above. The point is that you just need to add some white texture on light blocking layer, but light obstacle generator can automate this for you.
     
    Last edited: Aug 6, 2018
  26. OfficialAshez

    OfficialAshez

    Joined:
    Aug 28, 2017
    Posts:
    26
    Hello! I dont have any "Light Pixel Size" on my cameras script.
     
  27. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    173
    Some of my shadows display weird vertical lines when near the edge of the screen.

    What can I do about that? Do you recognize the issue?

     
  28. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    173
    Bump. Really need help with this.
     
  29. MaccyDBoy

    MaccyDBoy

    Joined:
    May 25, 2017
    Posts:
    30
    Hi !


    I wanted to know if there was a way to put the lights BEHIND UI canvases.. because so far everytime i pause the game, the lights is in front of the panel :(

    Thanks !