Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity Experimental 2D Lights and Shader Graph support in LWRP

Discussion in '2D Experimental Preview' started by rustum, May 24, 2019.

  1. TyrantNomad

    TyrantNomad

    Joined:
    Jul 4, 2013
    Posts:
    5
    It seems that currently that the cookie for the sprite type light can only be read, but not set, at runtime - will this be officially supported in the future? This would allow for the cookie to be animated in sync with sprites.

    Similarly, are there planned options for the sprite type light to bleed beyond its cookie, in a similar fashion to 3D's bloom?
     
  2. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    52
    We will be looking at the API and trying to make more things public.

    Are you talking about bloom using post process? This was working, but was broken with the introduction of Universal Render Pipeline's own post processing system. This will be working again with the next version of Universal RP.
     
    Zepa and EvOne like this.
  3. TyrantNomad

    TyrantNomad

    Joined:
    Jul 4, 2013
    Posts:
    5
    Those are both great news, thank you very much - I'll be looking forward to those changes!
     
  4. Enixus

    Enixus

    Joined:
    Jul 13, 2019
    Posts:
    5
    I love the easy use of this light-system, but I have a problem with the combination of Textmesh Pro.
    2019-09-12 04_33_21-Window.png
    The whale holds a sign with a white "Textmesh Pro"-object. If I use the default material, the text isn't influenced by light and is completely white. If I'm using a new material with the "Sprite-Lit-Default"-shader above, it's getting nearly black. (see screenshot). What can I do to render the text with the right light?
    (Please note: I'm quite new to Unity...)
     
    Asofi likes this.
  5. Asofi

    Asofi

    Joined:
    Mar 12, 2016
    Posts:
    2
    Have the same problem. Did you solve it?
     
  6. Enixus

    Enixus

    Joined:
    Jul 13, 2019
    Posts:
    5
    Unfortunately not... :( Sadly, I don't know much about shaders, yet. So, let's hope, that an experienced Unity-programmer of this forum can make "Textmesh Pro"-world-objects lit correctly... If you are finding a solution, please don't forget me. :)
     
  7. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    52
    I'll try and look into this issue this week, but it may have to wait until I'm back from vacation in early October.
     
  8. icesid

    icesid

    Joined:
    May 24, 2019
    Posts:
    6
    Hello, I have a problem with light direction. I made asteroid with normal map which is working great with point light to simulate sun. (In my case it would be nice to have global light with direction and normal map support, but for now this works fine except small problem.) I have camera script that is rotating main camera with my ship. Problem is, when I rotate ship with camera, it looks like light is rotating with the camera. In short light direction keeps changing according to camera rotation but only in game view. In scene view it looks fine. It should look the same on game view no matter the camera rotation. Light on asteroid should be changing only when asteroid itself is rotating. Am I missing something obvious?

    upload_2019-9-17_10-54-45.png
     
  9. Instr3x

    Instr3x

    Joined:
    Jan 29, 2018
    Posts:
    1
    Hey, I know that's kinda strange to use 2D lights in semi-3D game, but I happened to try it and it worked fine. Not until I tried adding point lights though, and this is a problem now. I really like the tools 2D lights provide to adjust and configure lighting properly and even animate it in runtime, so I don't want to use sprites with additive blending (must be the most adequate approach in this situation lol). I created some tiny script which just rotates sprites to face the camera, and as you can see in attached gif, point light seems to be rendered to some 2D surface, which itself doesn't rotate with the camera. What can I do to rotate that "surface", or maybe I should go with some other approach... ? Parametric light rotates fine, but I need to use inner and outer angle property in some of the lights, so I must use point lights.
     
  10. Meepo0

    Meepo0

    Joined:
    Nov 24, 2017
    Posts:
    21
    I found this wired annoying bug in the 2D Freeform Light it occurs sometimes when adding a node it causes this issue.

    upload_2019-9-19_10-2-0.png
     
  11. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    52
    The 2D lights are intended to act as though they are projected from behind the camera. If this isn't what you are asking about, can you post a video?

    Unfortunately, this is a known bug. I just need to get some time to fix it.

    Thanks for finding this, we will look into it.
     
  12. icesid

    icesid

    Joined:
    May 24, 2019
    Posts:
    6
    As you can see from video at bottom left corner, light is rotating with camera and ship even thought it's not child of camera or ship and it's static in scene view. So when ship is rotating with camera, light on asteroids is changing and on ship stays still. It should be other way around. I need the light to be static. So I want the light on ship change on rotation and light on asteroids stay the same no matter the camera rotation. How do I do that?

     
  13. pahe4retro

    pahe4retro

    Joined:
    Aug 13, 2019
    Posts:
    10
    @icesid That would explain your problem. I guess you could try to find out if the lights are reacting only to the "main camera" and then, as a work around for now, use two cameras (one static for the light and one for the game).

    Anyway, I'm a bit surprised about this approach. I'd assume that the light is independent from the camera angle/position, 'cause the light source doesn't change position or orientation when the camera moves. Is there any reason why this is implemented like that? Wouldn't that mean that any 2D endless-runner would also face that problem? Or is only the rotation of the camera important?
     
  14. icesid

    icesid

    Joined:
    May 24, 2019
    Posts:
    6
    Thanks for helping. I tried set up multiple cameras, but still getting same result. I tried to play with culling masks and layers, but nothing seems to work. Light is still rotating with camera no matter what camera I am using to see the scene. Maybe I am doing something wrong.
     
  15. Meepo0

    Meepo0

    Joined:
    Nov 24, 2017
    Posts:
    21
    Is this 2D shader graph project available online?
    i would like to see how this is working!


    upload_2019-9-23_10-35-58.png
     

    Attached Files:

    Storm4_, pm007, Kiori and 1 other person like this.
  16. wuzhouu3d

    wuzhouu3d

    Joined:
    Nov 3, 2014
    Posts:
    4
    I have a question. If I use 2d light in the project, how can I render 3d Objects?
     
  17. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,328
    Mindjar likes this.
  18. ManuelMeisen

    ManuelMeisen

    Joined:
    Sep 14, 2019
    Posts:
    3
    Really enjoying this feature.

    The Sprite Lit Graph master node does not support opaque, so the Scene Color node cant be used.
    Thats making it pretty hard to create a distortion shader, for example.
    Any chance we could get opaque support?
     
  19. wuzhouu3d

    wuzhouu3d

    Joined:
    Nov 3, 2014
    Posts:
    4
  20. Mindjar

    Mindjar

    Joined:
    Aug 13, 2013
    Posts:
    28
  21. Meepo0

    Meepo0

    Joined:
    Nov 24, 2017
    Posts:
    21
  22. JayNiize

    JayNiize

    Joined:
    Nov 28, 2018
    Posts:
    8
    Hey! :)
    I already saw the problem on the first page, but it was already fixed by the contributor (with version beta build 4 - I've got version 6.9.1). It is a bug with 360 point light. If you turn on Volume Opacity, there is a gap between 360 and 0 degrees using the 2D Renderer.



    I also wanted to ask how I can make 2D LWRP shaders work? The materials with the shaders are only shown in black and emissions are unfortunately not possible. (like in this tutorial
    )

    Best wishes!
     
    Last edited: Sep 29, 2019
    zIyaGtVm and Storm4_ like this.
  23. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    It's currently not available to the public. We're doing some clean up to the project and then we will release it.
     
    Meepo0 and EvOne like this.
  24. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    This is on our to-do list.
     
    EvOne likes this.
  25. Kruemelchen

    Kruemelchen

    Joined:
    Aug 26, 2019
    Posts:
    18
    I guess it's probably not made for this but I found a way to produce dark light. Could be useful e.g. to fake an occluder.
    2 point lights of which one uses another blend style which is set to substract.
    upload_2019-9-30_18-28-37.png
     
  26. keeps

    keeps

    Joined:
    Mar 24, 2015
    Posts:
    7
    Is there a way to set a freeform Light2d's shape programmatically?
    Light2D.shapePath is a read-only Vector3[] and I see no other method to set the shape
    thanks
     
  27. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    That's exactly what the substract blend mode is designed for. Let us know how do you like it.
     
  28. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    Because the array Light2D.shapePath returns is a reference (not a copy), you can make changes directly to the returned array and your modification will be applied in real time.
     
  29. icesid

    icesid

    Joined:
    May 24, 2019
    Posts:
    6
    is there a way to make 2D light source independent from the camera rotation?
     
    pahe4retro likes this.
  30. pahe4retro

    pahe4retro

    Joined:
    Aug 13, 2019
    Posts:
    10
    Wondering the same. After I talked to Andy Touch at Unite (he did the 2D talk there) and he agreed the the behaviour is strange, I hope @Chris_Chu will tell us that this may be changed in future. Like in your space game, rotating the camera is needed and the lights shouldn't react to the rotation (as the lights are still at the same position).
     
  31. Meepo0

    Meepo0

    Joined:
    Nov 24, 2017
    Posts:
    21
    Ok Thanks for the reply, is there going to be any announcement when it will be releasing cuz i dont want to miss it.
     
  32. icesid

    icesid

    Joined:
    May 24, 2019
    Posts:
    6
    Thanks I hope they do something with it before I finish the game. Otherwise only solution I am thinking of is to rotate light around the ship counter way to the camera rotation which looks like very dirty solution and seems unnecessary.
     
  33. keeps

    keeps

    Joined:
    Mar 24, 2015
    Posts:
    7
    ah thanks
    That is useful but is it limited to setting positions?
    I might be missing something obvious but I still can't see a way to set the amount of points.
    light2D.shapePath = new Vector3[n] is not allowed
    myShapePathRef = new Vector3[n] will lose the correct reference
     
    cparki77 likes this.
  34. jiigga

    jiigga

    Joined:
    Sep 12, 2018
    Posts:
    2
    Any news\progress with shadows?
    Thanks in Advance! :)
     
    BinaryByron likes this.
  35. stephanedupont

    stephanedupont

    Joined:
    Dec 31, 2017
    Posts:
    6
    pahe4retro likes this.
  36. pahe4retro

    pahe4retro

    Joined:
    Aug 13, 2019
    Posts:
    10
    There was a nice talk at the Unite Copenhagen about the new 2D features (in 2019.3+) which contained shadows (i.e. the ShadowCaster component). Seems like the talk isn't uploaded to youtube yet, but you can get a glimpse of it in the Keynote.

    And yes, it is also mentioned in the changelog :)
     
  37. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    Eventually we will provide a setter for Light2D.shapePath. But for now you can try Array.Resize.
     
  38. CodeMonkeyYT

    CodeMonkeyYT

    Joined:
    Dec 22, 2014
    Posts:
    30
    Hey everyone,

    I must be missing something because I can't find anyone else asking this question, where are the Renderer Features (Render Objects)?
    I wanted to play around with the SRP and render a bunch of Layers differently to create a nice effect but the only thing on the 2D Renderer Object is the blend styles.

    Is this something that is being added later?
    Or is the 2D Renderer supposed to work in a completely different way from the normal renderers? (No overrides, Queues, Layers, Stencil, Cameras, etc)
     
  39. Mindjar

    Mindjar

    Joined:
    Aug 13, 2013
    Posts:
    28
    @CodeMonkeyYT - I was wondering, too. I've heard at the Unite, that this will be added later, but it's better to confirm that :)
     
  40. mahdi_jeddi

    mahdi_jeddi

    Joined:
    Jul 18, 2016
    Posts:
    50
    The new 2D lights are amazing but I had to figure out why everything was dark and got a few errors because I didn't have Universal RP installed. The only real problem I encountered till now is that the Freefrom Light's falloff is not uniform in some situations, especially when the shape is long I guess. Here's what I get when I tried to simulate a god ray. The fallout on the lower edge is closer to the edge than the over ones:
     

    Attached Files:

    • 1.png
      1.png
      File size:
      224.2 KB
      Views:
      46
    Last edited: Oct 8, 2019
  41. Svitak7

    Svitak7

    Joined:
    Dec 18, 2017
    Posts:
    1
    Im making light shaft with parametric 2d light like this:
    upload_2019-10-8_23-17-44.png

    problem is the source of the light is above and when i move my camera down the light dissapear becouse the source of the light is too far away from the camera. Can i somehow change the distance value so that my camera will render light all the time? In normal lightsi could use render property and set it to important but here there is no option to do so
     
  42. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    The 2D Renderer uses the same ScriptableRenderer framework as the Forward Renderer does, so technically there is nothing blocking us from supporting Renderer Features. The reason we don't expose Renderer Features on the GUI is the 2D Renderer itself is still experimental and under active development, and our current focus is on the functionality and performance rather than the extendability. But we will enable customization to the 2D Renderer eventually.
     
    paladinlll likes this.
  43. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    You can try adding more vertices to the pointy end of the shape.
     
  44. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    215
    This is a known bug and will be fixed in the next version.
     
  45. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    52
    Hey everyone, sorry if this has been asked before but I didn't see it after searching.

    A couple of questions...

    When I first created my scene using 2019.3 beta 6 URP (LWRP), set everything up for 2D and dragged a sprite to the scene - everything was black. - is this normal? I was able to address this by adding a 2D light to the scene but I am wondering if the black sprite in the initial scene is a bug or the default (that we have to implement lighting)?

    Anyhow, I've got it all working but I am trying now to get post processing ( V2 ) working. I have everything setup properly for bloom but it isn't working. :/ To note, I am using a 2D light at the same time. Are the 2D lights somehow conflicting with the post processing bloom effect and preventing it from working?
     
  46. stephanedupont

    stephanedupont

    Joined:
    Dec 31, 2017
    Posts:
    6
    By default, sprites are using the lit version of the material. If there is no lights on it it will be black indeed.

    You can either change the sprite material to the unlit version, or have a global light in the scene (white light with an intensity of 1 will give you the same effect of unlit materials)
     
    starfoxy likes this.
  47. cparki3

    cparki3

    Joined:
    Jan 13, 2014
    Posts:
    37
    Looks like shadows are in now! Any chance we know when we will have softer shadows so the edges aren't so hard?
    shadows_confirmed.png
     
    Mindjar likes this.
  48. Clockmagnet

    Clockmagnet

    Joined:
    Apr 3, 2014
    Posts:
    1
    So, for this new 2D renderer, what is the alternative of Grab Pass for shaders? As far as I know, _CameraOpaqueTexture doesn't work with sprites anyway, but with that renderer, it doesn't work at all. What I need is to get pixels from behind one rectangular sprite. I'm only learning Unity, so I need to know the best way of doing that before diving into it. Could be that the best solution is to use Render Texture, but the whole idea felt smoother with Grab Pass, to be honest.
     
    Last edited: Oct 12, 2019
  49. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    52

    Thank you for the insight @stephanedupont . Very helpful.

    Any insight into why bloom wouldn't be working with the LWRP/URP 2D and post processing V2?
     
  50. Meepo0

    Meepo0

    Joined:
    Nov 24, 2017
    Posts:
    21
    Unity Version: 2019.2.0f1
    I don't know how this problem is occurring I have disabled Anti Aliasing from my LWRP Pipeline Asset also my camera is using the all the LWRP Pipeline Asset Settings, (I have 2 free form lights in this scene one only affecting the background and the other only the player and the ground) I think it is caused by the light which is affecting the ground as the lines are only seen on the ground area (Pink lines because my Camera has Solid Pink Color background).

    If there is something i am doing wrong with the Settings please let me know,
    Thank You!!

    upload_2019-10-15_10-46-22.png

    upload_2019-10-15_10-55-27.png