Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

URP - Limited number of pixel lights, why ?

Discussion in 'Universal Render Pipeline' started by xDenny8, Jan 29, 2021.

  1. xDenny8

    xDenny8

    Joined:
    Feb 12, 2017
    Posts:
    16
    Hello,

    I am making shooter similar to doom/quake/unreal tournament and I just decided to add point light to my projectiles just to make it prettier. And as expected, I reached the limit of 8 pixel lights very fast.

    upload_2021-1-29_20-21-5.png

    If you look at Unreal Tournament (game from 1999), then you can see that projectiles were emiting light. And since its multiplayer game, there could be hundreds of those lights and the game had no problems at all.

    upload_2021-1-29_20-31-22.png
    upload_2021-1-29_20-31-49.png

    Now, over 20 years later I am limited by 8 real time lights which I really don't understand as my knowledge about rendering is very basic.

    So could someone please explain to me why is that ? Maybe these are not actual lights but just some kind of a "fake" lights since it has to be very performant ?? But since it actually enlightens dark areas I am very confused..

    I am using URP with forward rendering and I would love to achieve similar effect without being limited to 8 lights.

    Thank you very much for answers.
     
    brainwipe, Zelgadis87 and Gekigengar like this.
  2. xgonzal2

    xgonzal2

    Joined:
    Jul 3, 2012
    Posts:
    52
    In URP's defense UT wasn't doing PBR and I think I remember it mostly used vertex lighting instead of pixel lights. However, you are totally right about the light limit being too low. They should at least make that configurable for the forward renderer.

    That said I don't think the light limit will really change anytime soon unless their deferred renderer doesn't share that limitation. For the forward renderer to scale well they would need to do something like tiled forward or cluster shading instead of the brute force loop they do at this point. I also don't recall URP being able to mix vertex and pixel lighting either like built-in can do once you have too many pixel lights. So at this point if the deferred renderer can't get around this then I don't think you can do anything about it with vanilla URP.
     
  3. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    8
    Hey!
    For many small lights (like in your example) it definitely makes sense to use deferred rendering.
    This is soon to be released for URP. Actually you can try it out on the Unity-Technologies/Graphics master branch right now if you'd like.
    This gif running the deferred renderer hopefully shows that what you want is possible:
    DeferredBattle.gif
     
  4. Bosozuki

    Bosozuki

    Joined:
    Dec 19, 2013
    Posts:
    62
    That is such a tease! Cant wait to experiment

     
    Gekigengar likes this.
  5. xDenny8

    xDenny8

    Joined:
    Feb 12, 2017
    Posts:
    16
    thank you guys.. so I'll be looking forward to deferred renderer. Hopefuly its very close to release :)
     
    Gekigengar likes this.
  6. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
    Hi @Jonas-Mortensen - I've upgraded my 2021.1 project to URP 12 from Master.
    I tried to create a new Deferred Renderer Data to assign to a URP Asset's Renderer List, but when I click Create->Rendering->Universal Rendering Pipeline-> it only lists Forward Renderer. Is that because there's no such thing as Deferred Renderer Data and we're just supposed to use Forward Renderer Data asset? If I just switch to Deferred Lighting in that I get warnings in the URP Asset about both OpenGLES2 and OpenGLES3 not being supported. Does this mean WebGL isn't capable of it? Which Graphics APIs are supported (or will be)? Thanks !
     
  7. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    19
    We also have a forward+ renderer in progress, which is adding a novel form of light tiling to our existing forward renderer. This will allow you to go well beyond the 8 light per object limit with the forward renderer without the inherent limitations of deferred rendering (deferred renderers do not support msaa and we also need to fallback to the forward renderer for transparent complex lit materials):
    https://portal.productboard.com/unity/1-unity-graphics/c/261-forward-renderer-support

    The reason there is currently an 8 light limit per object is because of performance considerations. Ideally, light data should fit entirely into constant buffers, because they are consistently fast universally across all platforms, whereas structured buffers are a lot slower on a lot of platforms. Without tiled/clustered lighting, there is a per object classification for the forward renderer, as we need to loop over all lights over all objects O(num_objects*num_lights), but with forward+, the performance will only be relative to the number of visible lights within each tile.

    We are considering making the light limit configurable, but this would require us to use the slow structured buffer path, which will potentially keep your games from being able to run on lower tier hardware. We are making URP as fast as possible across all hardware, but every new feature requested adds complexity to the existing renderer, so we are working very closely with all hardware vendors to define a universal fast path.
     
  8. xgonzal2

    xgonzal2

    Joined:
    Jul 3, 2012
    Posts:
    52
    We just recently finished our own version of a cluster shading forward renderer in URP and I can say it has been invaluable to have. We don't have to worry about old devices so I think the work was much simpler but this is something you guys should have in the near future. I look forward to it!
     
    nigeljw_unity likes this.
  9. Bosozuki

    Bosozuki

    Joined:
    Dec 19, 2013
    Posts:
    62
    Awesome!

    Curious will you guys do a forum/blog/documentation post going into details about the deferred, forward+, and original URP forward?
     
    charleshendry and polemical like this.
  10. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    19
  11. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
    Cool - thanks :)
     
  12. BobFlame

    BobFlame

    Joined:
    Nov 12, 2018
    Posts:
    62
    To enable deferred renderer in project, after adding packages to local package folder, you need to add Scripting Define Symble "ENABLE_RENDERING_PATH_UI" in project settings player. After that rendering mode will appear in Forward Renderer Data's UI, and there you go.
     
    cultureulterior likes this.
  13. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
    enable_deferred_lighting_for_urp_12.jpg

    It's now available to select - thanks! I'll see if I can get the unlimited-ish point lights feature running in my project this weekend for a glance at compatibility/performance implications. I might have to wait on Forward+ but it's worth a look either way. WebGL 2.0 is currently my baseline platform and I haven't heard back yet from @nigeljw_unity :D
     
    laurentlavigne likes this.
  14. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    250
    great news on Forward+ that's really beneficial for stylized projects that can't rely on the deferred gbuffer but want more lights.
    Is there a specific branch on the graphics github or is it still early compared to Deferred?
     
    leslviv likes this.
  15. Casual909

    Casual909

    Joined:
    Mar 3, 2021
    Posts:
    4
    Did you get the unlimited point lights to work? I did choose the deferred option but it actually did not change anything. Did you follow a specific step that I missed? It still just turns on 8 lights a time.
     
  16. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
    It's not compatible with WebGL.. I got as far into trying as seeing the warnings.

    I didn't actually realize this was the reason I could pick up to 8 lights now though, just figured that was a recent change I hadn't noticed :rolleyes:
     
  17. Casual909

    Casual909

    Joined:
    Mar 3, 2021
    Posts:
    4
    I am not using WebGL. Does the function for you work without?
     
    polemical likes this.
  18. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
    I just confirmed it's working in Windows 10:
    50_realtime_point_lights.jpg
    50_realtime_point_lights_2.jpg

    Instructions..

    - create new URP template project (I'm using 2021.2.0a9)
    - in Hierarchy, delete everything except "Main Camera" and "Post-process Volume"
    - add the ENABLE_RENDERING_PATH_UI thing noted above
    - change Lighting to Deferred (select ForwardRenderer in Project window)
    - create a new 3d object->plane
    - drag the 'Ground_Mat' material from Project window onto it
    - add the DeferredPointLightsTest component to it
    - enter play mode
    - during play mode, select the Plane with the component, then in the Inspector,
    - drag/change the number of lights and animation shape

    DeferredPointLightsTest.cs
    Code (CSharp):
    1. // @polemical, Unity Forum
    2. using UnityEngine;
    3. public class DeferredPointLightsTest : MonoBehaviour
    4. {
    5.   public float animationShape = 1;
    6.   public int numberOfLights = 50;
    7.   private int prevNumberOfLights = 0;
    8.   public Vector3 offset = new Vector3(-5, 0.2f, 0);
    9.   public Vector3 spread = new Vector3(10, 0, 0);
    10.  
    11.   private GameObject[] instances;
    12.  
    13.   private Vector3[] instanceOrigins;
    14.   private void Start()
    15.   {
    16.     Regenerate();
    17.     prevNumberOfLights = numberOfLights;
    18.   }
    19.   private void Regenerate()
    20.   {
    21.     Clear();
    22.     numberOfLights = Mathf.Clamp(numberOfLights, 1, 50);
    23.     Vector3 instanceStep = spread / numberOfLights;
    24.     Vector3 instanceCenterOffset = instanceStep * 0.5f;
    25.  
    26.     GameObject prefab = new GameObject();
    27.     Light light = prefab.AddComponent<Light>();
    28.     light.type = LightType.Point;
    29.     light.intensity = 1;
    30.  
    31.     instances = new GameObject[numberOfLights];
    32.     instanceOrigins = new Vector3[numberOfLights];
    33.     for (int i = 0; i < numberOfLights; i++)
    34.     {
    35.       instanceOrigins[i] = offset + instanceCenterOffset + (instanceStep * i);
    36.       instances[i] = Instantiate(prefab, transform);
    37.       instances[i].GetComponent<Light>().color = GetRandomLightColor();
    38.       instances[i].transform.localPosition = instanceOrigins[i];
    39.       instances[i].name = (i + 1).ToString();
    40.     }
    41.     prevNumberOfLights = numberOfLights;
    42.     Destroy(prefab);
    43.   }
    44.   private void Update()
    45.   {
    46.     if (prevNumberOfLights != numberOfLights) Regenerate();
    47.     if (instances == null) return;
    48.     for (int i = 0; i < instances.Length; i++)
    49.     {
    50.       instances[i].transform.localPosition = instanceOrigins[i] + new Vector3(
    51.         0, 0, Mathf.Sin((Time.time + (i * 100)) * animationShape)
    52.       );
    53.     }
    54.   }
    55.   private void Clear()
    56.   {
    57.     if (instances != null)
    58.     {
    59.       for (int i = 0; i < instances.Length; i++)
    60.       {
    61.         Destroy(instances[i]);
    62.       }
    63.       instances = null;
    64.     }
    65.   }
    66.   private Color GetRandomLightColor()
    67.   {
    68.     return new Color(
    69.       Random.Range(0.5f, 1.0f),
    70.       Random.Range(0.5f, 1.0f),
    71.       Random.Range(0.5f, 1.0f)
    72.     );
    73.   }
    74.   private void OnDestroy()
    75.   {
    76.     Clear();
    77.   }
    78. }
    :)
     
    Xskey likes this.
  19. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,209
    I think URP has an 8 lights limit on the number of lights in front of the camera
    Why do you need more than 8 lights in front of the camera at the same time durin play mode ?
    The lights are generally fixed and use a light shaft and projector for real-time light simulation in other multiplayer players...
    The difference between a projector and real light is in casting shadows
    The use of too many lights is a sign of weakness in the design
     
  20. polemical

    polemical

    Joined:
    Jun 17, 2019
    Posts:
    921
  21. xDenny8

    xDenny8

    Joined:
    Feb 12, 2017
    Posts:
    16
    Apparently URP does not support projector. "URP is not compatible with the Projector component. URP does not currently include an alternative solution."
     
  22. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,209
    There is no logical reason to use URP

    Built_in pipeline with lowest preset (plus some limitations)= URP
     
  23. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,209
    This is just the projector solution showcase
    For URP you must find compatible projector
    The performance is maxed out:
    If you want maxed our performance, you must use shaft (flare) textures as bloom effect
    1.jpg
    3.jpg
    2.jpg
     
  24. Zelgadis87

    Zelgadis87

    Joined:
    Nov 14, 2016
    Posts:
    6
    I'm having the same problem with the maximum amount of ligthing on my scene. I'm developing a top down twin stick shooter in URP, and wanted to put a simple point light on my projectiles. It works perfectly fine on walls / obstacles, but I'm having problems for the ground, which is giant plane, the size of the whole screen. With 4 moving spotlights on the scene and more than 4 projectiles flying around (basically always), some of the lights suddenly turn off, ruining the whole scene. I have the same problem on my UI (again, a single plane), as there are could be more than 8 lights at once (with no shadows). I don't think there would be any performance problems, as the number of vertexes is particularly low (a plane).

    I have no prior experience with rendering and lightning. What would you suggest it to be the best approach?
    Splitting the plane in multiple objects? Sounds a bit ugly and harder to maintain, and I have no guarantees that there will be less than 8 lights on any place at any given time.
    Switching to deferred renderer? I have no idea what the implications would be, especially since it is not yet ufficially released. Can someone explain it to me?

    Thanks in advance!
     
  25. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    250
    game engines are in year 2021 now, not 2006
     
  26. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,209
    We are talking about the low-end platform / pipeline
    No mobile can still render real-time light at high frames
    URP is built to apply the same limitations to have safe performance on low-end platforms
    Low-end platforms are not built for real-time lighting
     
    Xskey likes this.
  27. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    29
    Is it known, will this Deferred Renderer for URP work on mobile devices so that I'd be able to have a few dynamic lights in my game without it dropping FPS down to the floor?
     
  28. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    267
    Trying the URP deferred renderer with Unity 2021.1.2f1 and URP 11.0.0 and everything is becoming grey. Anybody else has that too?
     
  29. o-san

    o-san

    Joined:
    Jun 23, 2018
    Posts:
    25
    FYI. If you are relying on the new SSAO render feature the deferred lighting path will currently break that (2021.1.5f1)
     
  30. nigeljw_unity

    nigeljw_unity

    Unity Technologies

    Joined:
    Oct 7, 2020
    Posts:
    19
    @polemical WebGL 2.0 is an important platform for URP. We can't confirm support for the forward+ feature on specific platforms until it has undergone proper validation. As soon as I can give you an official response on this, this will be the first place I post it. Our initial focus for forward+ is broad platform support without the limitations of deferred. Thanks for your awesome feedback on using deferred in the alpha release. I will share the documentation for deferred as soon as it is live. Unfortunately, there is no support for deferred rendering for WebGL at this point.

    @sinaari Deferred rendering inherently has several hard limitations such as incompatibility with both msaa and transparents, and also heavy bandwidth usage without additional renderpass optimizations, so the current implementation of deferred is not well suited for mobile platforms, though immediate mode platforms should perform well using deferred with many lights (but still with the hard limitations).

    @XRA both deferred and forward+ are in progress. As soon as an alpha release is available with the initial forward+ implementation, I will post it here.

    @xDenny8 Decal projector support is in progress:
    https://portal.productboard.com/unity/1-unity-platform-rendering-visual-effects/c/33-decals

    @o-san the fixes for SSAO with deferred have already landed in the 2021.2 alpha release. If you see any remaining issues, can you submit an official support request? This helps us prioritize the issues a lot. https://issuetracker.unity3d.com
     
    exblade, o-san, sinaari and 3 others like this.
  31. iDerp69

    iDerp69

    Joined:
    Oct 27, 2018
    Posts:
    16
    I successfully turned on deferred in a test version of my project... is there a way to get point lights to allow objects to cast real time shadows on other objects?
     
  32. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    477
    Hi is this coming to, or compatible with 2020 LTS?
     
    Last edited: Jun 12, 2021
    charleshendry likes this.
  33. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    27,208
    Hoping speed wins out, since if people want more, the deferred renderer is still available. But Forward+ with non configurable sounds perfect for real developers who want the fastest performing compromise...

    I don't need lots of options, I need lots of speed :)
     
    nigeljw_unity likes this.
  34. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    477
    Oh, I did not know deferred is slower than forward.
     
  35. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    27,208
    Deferred is faster than forward if forward has to deal with a lot of lights. But if you have a set amount and want MSAA which is also faster than FXAA and other antialiasing solutions on mobile etc, you would want forward+ a whole lot. VR for example will be considerably better under forward+ if lots of lights are your thing.
     
  36. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    477
    Thanks for the info! I am on a VR project and I hope this comes to 2021 LTS (URP 10) also.
     
  37. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    27,208
    I have similar circumstances. URP has only recently began to step up with VR quality and engineering in Unity, but it seems to be ongoing so I hope the staff will feel encouraged to work on this knowing it's very much appreciated by us here.
     
unityunity