Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

    19.0%
  2. Important

    28.6%
  3. Nice-To-Have

    52.4%
  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 ..
     
  2. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    193
    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:
    316
    You forgot there is moon light.
    it's important to support two directional lights blending together to get a smooth day night cycle.
     
    iDerp69 likes this.
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    533
    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:
    95
    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 Moderator

    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:
    878
    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?
     
  10. Genebris

    Genebris

    Joined:
    Mar 18, 2013
    Posts:
    56
    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:
    680
    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:
    29
    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... :(