Search Unity

Feature Request 2 or more directional lights simultaneously

Discussion in 'High Definition Render Pipeline' started by Deleted User, Apr 13, 2022.

?

How important is this feature to you/your workflow?

  1. Critical

    40.7%
  2. Important

    34.6%
  3. Nice-To-Have

    24.7%
  1. Deleted User

    Deleted User

    Guest

    With all HDRP power, it can't do a simple thing even built-in RP could: 2 or more directional lights that cast shadows in a scene simultaneously.

    For the love of god, implement this basic feature for the Cutting-Edge Render Pipeline already ..
     
    AntonioModer likes this.
  2. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    202
    Clearly, you have no idea what you are doing. Directional Light acts as the Sun. It is designed that way. In the real world, there are no two suns casting shadows. If you need multiple lights to cast shadows, try using things like spotlights with large angles or point&area lights.
     
    ontrigger, shikhrr and AydinDeveloper like this.
  3. LumaPxxx

    LumaPxxx

    Joined:
    Oct 3, 2010
    Posts:
    339
    You forgot there is moon light.
    it's important to support two directional lights blending together to get a smooth day night cycle.
     
    GubaLord, scionious and iDerp69 like this.
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    You can use two or more direction lights, the limitation is that only one can cast shadows.
    While not impossible to implement, it seems to be a very niche case where you'd need two directional cascaded shadowmaps (keep in mind, this can be costly) simultaneously .
    In you example, the sun light would wash out the moon light totally due to the difference of intensity, until the sn is way below the horizon and doesn't cast shadows anymore (but lights by indirect lighting through the sky atmosphere bounces).
    So basically, the solution is to switch the shadows from one to the other when the sun gets below the horizon.
     
  5. Deleted User

    Deleted User

    Guest

    It's not always a matter of photorealism and pure accuracy, HDRP is Not solely meant for that; From your own docs:

    Screenshot 2022-04-13 191109.png

    for a unique stylized and unparalleled look, you'll Need 2+ directional lights that cast shadows to achieve your goal. I see no reason why not to support such a basic feature for an RP that's meant to surpass built-in in every direction.


    Built-In RP supported it out-of-the-box, why HDRP cannot?
     
  6. DrSeltsam

    DrSeltsam

    Joined:
    Jul 24, 2019
    Posts:
    101
    There are scenarios where two shadow-casting directional lights would be indeed useful, especially in day-night-cycles where both the sun and moon are visible simultaneously (during dawn and dusk). If only one light can cast shadows, we can't have sun and moon light at the same time.

    It's not necessarily about the shadows themselves: If one of the light doesn't cast shadows, it affects volumetric fog through walls, and specular highlights are also visible through walls.

    Unreal Engine supports more than one shadow-casting directional light. I understand that this has performance implications, but IMHO it would be better if it's up to the user to decide whether or not he's willing to spend his frame budget on this.

    However, I find it a bit more concerning that HDRP sticks to the "single main light mechanic" in general... volumetric clouds can only be affected by a single directional light, only a single directional light can be accessed from shader graph etc.

    Don't get me wrong, I love HDRP, and it's a huge step forwards compared to BIRP in most areas, but the workflow is only nice if you do exactly what Unity excplicitly wants you to do - if you do anything else, you'll have a hard time.
     
    Last edited: Apr 14, 2022
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's a dot product to add an extra dir light for almost free in any shadergraph, basically. Pop that in emmisive output and profit. That would be the highest performing option.

    (Any kind of directional light shader like this would not be physically based, but you just want a cheap second directionally lit effect).
     
  8. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi, we are all agree that it would be nice to support multiple directional cascaded shadowed light.
    But we have made the choice in our design to not support it for performance reasons (VGPR pressure, memory allocation, CPU time...) and also to limit shader variant explosion. HDRP architecture is different from builtin which make this feature harder to implement in practice (i.e tile lighting vs multipass algorithm).

    Still we support Box light which can be think of as local direction light which support shadow map (not cascaded shadow map, just regular shadow map) - you can increase the size of the box to mimic the regular directional light -, and you can have many of them. This is not a replacement for sun/moon cascaded shadow scenario - that should follow Remy's description instead with swap of shadow), but maybe it could help in your scenario case?
     
  9. Deleted User

    Deleted User

    Guest

    Sounds like a good solution, but: will it replace directional light and be a perfect mimicking substitute(since the difference in cascades)?

    Imagine (e.g.) a scenario of an exciting game where you wake up in an exotic planet with 2+ suns (whether the game be stylized or photorealistic); Is there any way to mimic the other sun perfectly with no difference in shadows? If there's already one, I'm willing to listen. Of course, this is just one heck of a droplet example/scenario in a whole ocean; Imagination is your only limit.

    Performance/Quality budget decision should be left for the user to decide, just like DrSeltsam said. This will (including but not limited to):
    • Allow artists to work freely without obstacles hindering their workflow
    • Open limitless possibilities of innovative and great ideas for Film, TV, Animation, Cinematics and Games

    - And also, I don't think it's a valid argument .. my project won't necessarily utilise the full power of HDRP, but it could use 2+ directional lights instead.


    Guys, take my advice: Without allowing the user to customise their workflow and roaming freely, we'll still keep saying "Oh, you can't do that in Unity", which is the last phrase you want to hear from your users.


    Seeing as HDRP & URP are going to replace legacy BIRP, then the future should be brighter than the past; don't you think?
     
    Roman_M likes this.
  10. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    144
    Shadows aren't the only problem, I can accept no shadows from the moon. But for some reason the light with shadows enabled always seems to be considered "main" directional light even when it's intensity is 0,1. Which means clouds turn all black even though there's a bright second directional light in the scene.

    Is it possible to manually specify what light should HDRP consider as main light? I assume no as this must be intentionally related to shadows. But at least we need an ability to specify which light sky and clouds use.

    If you just look at asset store "solutions" for day night cycle in HDRP, they all have ugly transition from day to night. At least to me this is a clear indication that this needs better support from Unity.
     
    Last edited: Dec 1, 2022
  11. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    I think requiring a single "main" directional light is very shortsighted. First there's the case where there actually are 2 suns -- maybe it's set on a planet with a binary star system, maybe a wizard decided to split the sun into a big red one and a big blue one, or maybe it's just needed for a particular effect.

    There's also some big workflow gains from having 2 shadow-casting directional lights, IMO. Lighting is one of the later stages in level design. Slapping 2 shadowed directional lights at oblique angles with slightly different colors/intensities is a quick way to get a reasonable approximation of lighting when laying out your scene (especially indoor scenes). It's not realistic, but when setting up a scene and moving props around and stuff, you don't want realism. Then an artist can come through and fix the lighting to be more realistic later.

    I guess the assumption by the HDRP team is that most users will create the scene in Maya/Blender/whatever and then just import it into HDRP?
     
    iDerp69 likes this.
  12. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    56
    I have to agree, I understand that it has a major performance impact, but if I want to spend my frame budget on multiple shadow casting directional lights, and trade that off for other visual effects to make up the lost performance, I would like the ability to do that. But I don't need to reiterate what's already been said :p. A simple warning when you turn on shadows on a second directional light saying "this will incur a performance cost" or something would be sufficient.

    Besides, it's not like HDRP is particularly "beginner friendly" to begin with, it seems more tailored for advanced users who really want to push the customization of rendering much higher. So while I could maybe understand keeping things simple for something like URP (although I don't necessarily think the limitation should be there either), HDRP for sure could open the gates on something like that to offer more customization for the artists and developers who could face this as a major roadblock for using Unity entirely. A scene with two suns and only one shadow does not look very good... :(
     
  13. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I am actually in this situation. I need to create two shadows for my characters (the reasons do not really matter, but they are valid) and I can't. I have tried using spot lights but the shadows cast by these lights are way too faint compared to the direct lights ones and I have to turn the direct light intensity all the way down to see the shadows so the environment ends up too dark.
    Maybe I am doing something wrong but I can't get the desired effect right now without 2 direct lights.
    I will try box light next. But my guess is that I will get a similar effect as the spot lights?
     
    Last edited: Jul 15, 2023
  14. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
  15. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    595
    Aka Spot with Box shape
     
    Last edited: Jul 16, 2023
  16. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    482
    Wrong. It's a spot light with box shape
     
  17. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    595
    Ah yes of course, I was thinking of soft box set ups based on another thread. Well spotted.
     
  18. eliphat

    eliphat

    Joined:
    Jul 4, 2017
    Posts:
    48
    I am not producing games with HDRP, but instead CG animation. I think unity have been marketing HDRP for films and CG animations too. In these cases, performance impact of shadowmaps, memory impact of shader variants -- these really are not an issue. I accept anything that does not break the interactivity in my quasi-realtime workflow -- I guess that would be down to <10 fps before it becomes so laggy that productivity starts to deteriorate. This may be one extreme case indicating unity should allow us to trade performance for productivity since real-time performance is meaningless here.

    I sometimes have plots on planets with two suns in my animation -- I'm simulating them now with spotlights, but the process is quite tricky. With directional lights, you can easily set up (or at least getting close to) the lighting and the exposure by using physically grounded values, but with spotlights it is hard to make the values correct for another sun.
     
  19. AntonioModer

    AntonioModer

    Joined:
    Jul 29, 2014
    Posts:
    65
    Minimum need 2 cascade shadows, my reason is below (this is my subjective opinion).

    I have scene with meshes in many million polygons.
    I try make two directional lights for draw shadow optimization:
    1. directional light for static objects with million polygons (light layer 1): ShadowsUpdateMode=OnDemand (60 fps), high resolution shadows.
    2. directional light for dynamic objects (light layer default): realtime shadows, low resolution shadows.
    If ShadowsUpdateMode=OnDemand (60 fps) for dynamic objects, then will be shadows glitches when dynamic object moving.
     
  20. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    324
    You can do shadow caching of only static objects (On Demand), while rendering dynamic object shadows every frame (there is a checkbox "always draw dynamic" or something like that). This is done with one directional light, not two. This approach uses extra memory if I'm not mistaken - maintaining static shadow cascades + dynamic shadow cascaces.